From 933d9e074c76299cc9da9429237e2584271b9fbf Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 27 Feb 2022 01:16:51 -0800 Subject: [PATCH] Option to show audio/subtitle language on movie details (first two unique languages will be shown) (cherry picked from commit c10677dfe7098295fde39517b3983e8f3f22823d) --- .../MovieFile/Editor/MovieFileEditorRow.css | 7 ++++ .../Editor/MovieFileEditorRow.css.d.ts | 2 ++ .../MovieFile/Editor/MovieFileEditorRow.js | 18 ++++++++++ .../Editor/MovieFileEditorTableContent.js | 10 ++++++ frontend/src/MovieFile/MediaInfo.js | 35 +++++++++++++++++++ frontend/src/MovieFile/mediaInfoTypes.js | 2 ++ src/NzbDrone.Core/Localization/Core/en.json | 2 ++ 7 files changed, 76 insertions(+) diff --git a/frontend/src/MovieFile/Editor/MovieFileEditorRow.css b/frontend/src/MovieFile/Editor/MovieFileEditorRow.css index 63d8d7570..a0ace4ada 100644 --- a/frontend/src/MovieFile/Editor/MovieFileEditorRow.css +++ b/frontend/src/MovieFile/Editor/MovieFileEditorRow.css @@ -34,6 +34,13 @@ width: 100px; } +.audioLanguages, +.subtitles { + composes: cell from '~Components/Table/Cells/TableRowCell.css'; + + width: 165px; +} + .releaseGroup { composes: cell from '~Components/Table/Cells/TableRowCell.css'; diff --git a/frontend/src/MovieFile/Editor/MovieFileEditorRow.css.d.ts b/frontend/src/MovieFile/Editor/MovieFileEditorRow.css.d.ts index 18a0c576e..21444b886 100644 --- a/frontend/src/MovieFile/Editor/MovieFileEditorRow.css.d.ts +++ b/frontend/src/MovieFile/Editor/MovieFileEditorRow.css.d.ts @@ -3,6 +3,7 @@ interface CssExports { 'actions': string; 'age': string; + 'audioLanguages': string; 'customFormatScore': string; 'download': string; 'formats': string; @@ -12,6 +13,7 @@ interface CssExports { 'relativePath': string; 'releaseGroup': string; 'size': string; + 'subtitles': string; } export const cssExports: CssExports; export default cssExports; diff --git a/frontend/src/MovieFile/Editor/MovieFileEditorRow.js b/frontend/src/MovieFile/Editor/MovieFileEditorRow.js index b119388ce..3a941b0f4 100644 --- a/frontend/src/MovieFile/Editor/MovieFileEditorRow.js +++ b/frontend/src/MovieFile/Editor/MovieFileEditorRow.js @@ -117,6 +117,24 @@ class MovieFileEditorRow extends Component { /> + + + + + + + + translate('AudioInfo'), isVisible: true }, + { + name: 'audioLanguages', + label: () => translate('AudioLanguages'), + isVisible: true + }, + { + name: 'subtitleLanguages', + label: () => translate('SubtitleLanguages'), + isVisible: true + }, { name: 'size', label: () => translate('Size'), diff --git a/frontend/src/MovieFile/MediaInfo.js b/frontend/src/MovieFile/MediaInfo.js index 75b264d58..fa6f87f04 100644 --- a/frontend/src/MovieFile/MediaInfo.js +++ b/frontend/src/MovieFile/MediaInfo.js @@ -1,12 +1,37 @@ +import _ from 'lodash'; import PropTypes from 'prop-types'; import React from 'react'; import * as mediaInfoTypes from './mediaInfoTypes'; +function formatLanguages(languages) { + if (!languages) { + return null; + } + + const splitLanguages = _.uniq(languages.split(' / ')); + + if (splitLanguages.length > 3) { + return ( + + {splitLanguages.slice(0, 2).join(', ')}, {splitLanguages.length - 2} more + + ); + } + + return ( + + {splitLanguages.join(', ')} + + ); +} + function MediaInfo(props) { const { type, audioChannels, audioCodec, + audioLanguages, + subtitles, videoCodec } = props; @@ -31,6 +56,14 @@ function MediaInfo(props) { ); } + if (type === mediaInfoTypes.AUDIO_LANGUAGES) { + return formatLanguages(audioLanguages); + } + + if (type === mediaInfoTypes.SUBTITLES) { + return formatLanguages(subtitles); + } + if (type === mediaInfoTypes.VIDEO) { return ( @@ -46,6 +79,8 @@ MediaInfo.propTypes = { type: PropTypes.string.isRequired, audioChannels: PropTypes.number, audioCodec: PropTypes.string, + audioLanguages: PropTypes.string, + subtitles: PropTypes.string, videoCodec: PropTypes.string }; diff --git a/frontend/src/MovieFile/mediaInfoTypes.js b/frontend/src/MovieFile/mediaInfoTypes.js index 5e5a78e64..425b3d98b 100644 --- a/frontend/src/MovieFile/mediaInfoTypes.js +++ b/frontend/src/MovieFile/mediaInfoTypes.js @@ -1,2 +1,4 @@ export const AUDIO = 'audio'; +export const AUDIO_LANGUAGES = 'audioLanguages'; +export const SUBTITLES = 'subtitles'; export const VIDEO = 'video'; diff --git a/src/NzbDrone.Core/Localization/Core/en.json b/src/NzbDrone.Core/Localization/Core/en.json index aef1af7bf..dcf5b0165 100644 --- a/src/NzbDrone.Core/Localization/Core/en.json +++ b/src/NzbDrone.Core/Localization/Core/en.json @@ -74,6 +74,7 @@ "AptUpdater": "Use apt to install the update", "AsAllDayHelpText": "Events will appear as all-day events in your calendar", "AudioInfo": "Audio Info", + "AudioLanguages": "Audio Languages", "AuthBasic": "Basic (Browser Popup)", "AuthForm": "Forms (Login Page)", "Authentication": "Authentication", @@ -1099,6 +1100,7 @@ "Studio": "Studio", "Style": "Style", "SubfolderWillBeCreatedAutomaticallyInterp": "'{0}' subfolder will be created automatically", + "SubtitleLanguages": "Subtitle Languages", "SuggestTranslationChange": "Suggest translation change", "Sunday": "Sunday", "System": "System",