Skip to content

Commit

Permalink
Improve language code file suffix handling
Browse files Browse the repository at this point in the history
  • Loading branch information
emericg committed May 18, 2021
1 parent 558d16a commit db8c946
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions OpenSubtitlesDownload.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,12 @@ def dependencyChecker():
if opt_language_suffix == 'auto' and languageCount_search > 1:
opt_language_suffix = 'on'

if opt_language_suffix_size == 'auto':
languagePrefixSize = 0
for language in languageList:
languagePrefixSize += len(language)
opt_language_suffix_size = (languagePrefixSize // languageCount_search)

# ==== Get file hash, size and name
videoTitle = ''
videoHash = hashFile(currentVideoPath)
Expand Down Expand Up @@ -815,8 +821,8 @@ def dependencyChecker():

# Write language code into the filename?
if (opt_language_suffix == 'on'):
if (str(opt_language_suffix_size) == 'auto' and len(currentLanguage) == 2) or str(opt_language_suffix_size) == '2': subLangId = opt_language_suffix_separator + subtitlesResultList['data'][subIndex]['ISO639']
elif (str(opt_language_suffix_size) == 'auto' and len(currentLanguage) == 3) or str(opt_language_suffix_size) == '3': subLangId = opt_language_suffix_separator + subtitlesResultList['data'][subIndex]['SubLanguageID']
if (opt_language_suffix_size == 2 or opt_language_suffix_size == '2'): subLangId = opt_language_suffix_separator + subtitlesResultList['data'][subIndex]['ISO639']
elif (opt_language_suffix_size == 3 or opt_language_suffix_size == '3'): subLangId = opt_language_suffix_separator + subtitlesResultList['data'][subIndex]['SubLanguageID']
else: subLangId = opt_language_suffix_separator + currentLanguage

subPath = subPath.rsplit('.', 1)[0] + subLangId + '.' + subtitlesResultList['data'][subIndex]['SubFormat']
Expand Down

0 comments on commit db8c946

Please sign in to comment.