From 0e72bb23b2d4df2e0fc23962927c33608beac719 Mon Sep 17 00:00:00 2001 From: sfaulds Date: Tue, 27 Jun 2017 11:51:01 +1000 Subject: [PATCH] add cc to name is subtitle is available --- addon.xml | 2 +- resources/language/English/strings.po | 4 ++++ resources/lib/functions.py | 15 +++++++++++---- resources/settings.xml | 1 + 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/addon.xml b/addon.xml index 2aeb457..9b88aea 100644 --- a/addon.xml +++ b/addon.xml @@ -1,7 +1,7 @@ diff --git a/resources/language/English/strings.po b/resources/language/English/strings.po index f306be3..1bd7a09 100644 --- a/resources/language/English/strings.po +++ b/resources/language/English/strings.po @@ -226,6 +226,10 @@ msgctxt "#30162" msgid "Add Season Number" msgstr "" +msgctxt "#30163" +msgid "Add (cc) if subtitle is available" +msgstr "" + msgctxt "#30166" msgid "Select Server" msgstr "" diff --git a/resources/lib/functions.py b/resources/lib/functions.py index eccdc9a..5132e8a 100644 --- a/resources/lib/functions.py +++ b/resources/lib/functions.py @@ -319,6 +319,10 @@ def addGUIItem(url, details, extraData, folder=True): if (countsAdded == False and addResumePercent and details.get('title') != None and cappedPercentage != None): listItemName = listItemName + " (" + str(cappedPercentage) + "%)" + subtitle_available = settings.getSetting('addSubtitleAvailable') == 'true' + if subtitle_available and extraData.get("SubtitleAvailable", False): + listItemName += " (cc)" + # update title with new name, this sets the new name in the deailts that are later passed to video info details['title'] = listItemName @@ -713,9 +717,9 @@ def processDirectory(results, progress, params): audiocodec = '' height = '' width = '' - aspectratio = '1:1' aspectfloat = 0.0 subtitle_lang = '' + subtitle_available = False mediaStreams = item.get("MediaStreams") if (mediaStreams != None): for mediaStream in mediaStreams: @@ -724,7 +728,7 @@ def processDirectory(results, progress, params): height = str(mediaStream.get("Height")) width = str(mediaStream.get("Width")) aspectratio = mediaStream.get("AspectRatio") - if aspectratio != None and len(aspectratio) >= 3: + if aspectratio is not None and len(aspectratio) >= 3: try: aspectwidth, aspectheight = aspectratio.split(':') aspectfloat = float(aspectwidth) / float(aspectheight) @@ -734,7 +738,9 @@ def processDirectory(results, progress, params): audiocodec = mediaStream.get("Codec") channels = mediaStream.get("Channels") if mediaStream.get("Type") == "Subtitle": - subtitle_lang = mediaStream.get("Language") + subtitle_available = True + if mediaStream.get("Language") is not None: + subtitle_lang = mediaStream.get("Language") # Process People director = '' @@ -883,7 +889,8 @@ def processDirectory(results, progress, params): 'UnWatchedEpisodes': str(UnWatchedEpisodes), 'NumEpisodes': str(NumEpisodes), 'itemtype': item_type, - 'SubtitleLang': subtitle_lang} + 'SubtitleLang': subtitle_lang, + 'SubtitleAvailable': subtitle_available} extraData["Path"] = item.get("Path") diff --git a/resources/settings.xml b/resources/settings.xml index f34b5e2..0e41532 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -40,6 +40,7 @@ +