Private GIT

Skip to content
Snippets Groups Projects
Commit e7e8a9fa authored by miigotu's avatar miigotu
Browse files

Merge pull request #77 from medariox/develop

Adds support for subtitles with language for PP
parents 5643fd13 efc0e936
No related branches found
No related tags found
No related merge requests found
......@@ -39,6 +39,7 @@ from sickbeard.name_parser.parser import NameParser, InvalidNameException, Inval
from sickrage.helper.encoding import ek
from sickrage.helper.exceptions import EpisodeNotFoundException, EpisodePostProcessingFailedException, ex
from sickrage.helper.exceptions import ShowDirectoryNotFoundException
from babelfish import language_converters
import adba
from sickbeard.helpers import verify_freespace
......@@ -190,9 +191,16 @@ class PostProcessor(object):
checklist = glob.glob(ek(os.path.join, ek(os.path.dirname, globbable_file_path), '*')) # get a list of all the files in the folder
for filefound in checklist: # loop through all the files in the folder, and check if they are the same name even when the cases don't match
file_name = filefound.rpartition('.')[0]
file_extension = filefound.rpartition('.')[2]
if not base_name_only:
file_name = file_name + '.'
if file_name.lower() == base_name.lower().replace('[[]', '[').replace('[]]', ']'): # if there's no difference in the filename add it to the filelist
new_file_name = file_name + '.'
if new_file_name.lower() == base_name.lower().replace('[[]', '[').replace('[]]', ']'): # if there's no difference in the filename add it to the filelist
filelist.append(filefound)
elif file_extension in common.subtitleExtensions:
language_extensions = tuple('.' + c for c in language_converters['opensubtitles'].codes)
if file_name.lower().endswith(language_extensions) and (len(filefound.rsplit('.', 2)[1]) is 2 or 3):
filelist.append(filefound)
elif file_name.lower().endswith('pt-br') and len(filefound.rsplit('.', 2)[1]) is 5:
filelist.append(filefound)
for associated_file_path in filelist:
......@@ -299,7 +307,10 @@ class PostProcessor(object):
# check if file have subtitles language
if os.path.splitext(cur_extension)[1][1:] in common.subtitleExtensions:
cur_lang = os.path.splitext(cur_extension)[0]
if cur_lang in sickbeard.subtitles.wantedLanguages():
if cur_lang:
cur_lang = cur_lang.lower()
if cur_lang == 'pt-br':
cur_lang = 'pt-BR'
cur_extension = cur_lang + os.path.splitext(cur_extension)[1]
# replace .nfo with .nfo-orig to avoid conflicts
......@@ -313,7 +324,7 @@ class PostProcessor(object):
else:
new_file_name = helpers.replaceExtension(cur_file_name, cur_extension)
if sickbeard.SUBTITLES_DIR and cur_extension in common.subtitleExtensions:
if sickbeard.SUBTITLES_DIR and cur_extension[-3:] in common.subtitleExtensions:
subs_new_path = ek(os.path.join, new_path, sickbeard.SUBTITLES_DIR)
dir_exists = helpers.makeDir(subs_new_path)
if not dir_exists:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment