diff --git a/hulusubs_dl/hulu.py b/hulusubs_dl/hulu.py index d2e1eb8..cdc9a89 100644 --- a/hulusubs_dl/hulu.py +++ b/hulusubs_dl/hulu.py @@ -25,6 +25,7 @@ def __init__(self, url, cookie_value, language, extension, download_location, pr def episode_link(self, url, cookie_value, language, extension, download_location, proxy=None): logging.debug('Called: episode_link()') + is_dub = False transcript_urls = {} eab_id = str(url).split('/watch/')[-1].replace('/', '') logging.debug('initial eab_id: {0}'.format(eab_id)) @@ -57,13 +58,26 @@ def episode_link(self, url, cookie_value, language, extension, download_location video_metadata = dict(hulu_api.get_eab_id_metadata(eab_id, cookie_value, language)).get('items', {}) logging.debug('\n----\nvideo_metadata: {0}\n----\n'.format(video_metadata)) video_metadata = dict(list(video_metadata)[0]) + episode_title = video_metadata.get('name', None) + if episode_title and "(dub)" in str(episode_title).lower(): + is_dub = True series_name = utils.get_clean_path_name(video_metadata.get('series_name', video_metadata.get("name", "No Name Found"))) is_movie = True if video_metadata.get('_type', None) == "movie" else False season_number = video_metadata.get('season', "01") episode_number = video_metadata.get('number', "01") - file_name = '{0} - S{1}E{2} [{3} Sub].{4}'.format(series_name, season_number, episode_number, utils.get_language_name(language), extension) + if not is_dub: + file_name = '{0} - S{1}E{2} [{3} Sub].{4}'.format(series_name, season_number, episode_number, + utils.get_language_name(language), extension) + else: + file_name = '{0} - S{1}E{2} [{3} Dub].{4}'.format(series_name, season_number, episode_number, + utils.get_language_name(language), extension) if is_movie: - file_name = '{0} [{1} Sub].{2}'.format(series_name, utils.get_language_name(language), extension) + if not is_dub: + file_name = '{0} [{1} Sub].{2}'.format(series_name, utils.get_language_name(language), + extension) + else: + file_name = '{0} [{1} Dub].{2}'.format(series_name, utils.get_language_name(language), + extension) logging.debug('\n----\nfile_name: {0}\n----\n'.format(file_name)) print("Downloading Subtitle For {0}".format(file_name)) selected_extension = transcript_urls.get(extension, None)