From e769dcc6b1d0bee269f9847bd56c5e8dd727ae25 Mon Sep 17 00:00:00 2001 From: Xonshiz Date: Mon, 7 Jun 2021 09:50:09 +0530 Subject: [PATCH] Fix for #31 - Closes #31 - Subtitles will now show proper language names instead of 'en', 'es', etc. --- Changelog.md | 4 +++- docs/Changelog.md | 4 +++- hulusubs_dl/__version__.py | 2 +- hulusubs_dl/cust_utils/utils.py | 9 +++++++++ hulusubs_dl/hulu.py | 6 ++++-- 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Changelog.md b/Changelog.md index 06d62cb..ee24ebb 100644 --- a/Changelog.md +++ b/Changelog.md @@ -9,4 +9,6 @@ - Fixed #27 - Added support to download subtitles of "movies". - Fix for #29 and #28 -- Fix for #25 \ No newline at end of file +- Fix for #25 +- Fix for #31 +- Subtitles will now show proper language names instead of 'en', 'es', etc. \ No newline at end of file diff --git a/docs/Changelog.md b/docs/Changelog.md index 06d62cb..ee24ebb 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -9,4 +9,6 @@ - Fixed #27 - Added support to download subtitles of "movies". - Fix for #29 and #28 -- Fix for #25 \ No newline at end of file +- Fix for #25 +- Fix for #31 +- Subtitles will now show proper language names instead of 'en', 'es', etc. \ No newline at end of file diff --git a/hulusubs_dl/__version__.py b/hulusubs_dl/__version__.py index 2edf4fa..32a0fa0 100644 --- a/hulusubs_dl/__version__.py +++ b/hulusubs_dl/__version__.py @@ -1,4 +1,4 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -__version__ = "2021.06.05" +__version__ = "2021.06.07" diff --git a/hulusubs_dl/cust_utils/utils.py b/hulusubs_dl/cust_utils/utils.py index c1fef21..c76f998 100644 --- a/hulusubs_dl/cust_utils/utils.py +++ b/hulusubs_dl/cust_utils/utils.py @@ -138,3 +138,12 @@ def get_clean_path_name(path_name): for cha in '\/*?:"<>|,;\'': path_name = path_name.replace(cha, ' -') return path_name + + +def get_language_name(lang_code): + lang_dict = { + 'en': 'English', + 'es': 'Spanish', + 'jp': 'Japanese' + } + return lang_dict.get(lang_code, lang_code) diff --git a/hulusubs_dl/hulu.py b/hulusubs_dl/hulu.py index 51851ed..be3f8e3 100644 --- a/hulusubs_dl/hulu.py +++ b/hulusubs_dl/hulu.py @@ -58,10 +58,12 @@ def episode_link(self, url, cookie_value, language, extension, download_location logging.debug('\n----\nvideo_metadata: {0}\n----\n'.format(video_metadata)) video_metadata = dict(list(video_metadata)[0]) 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, - language, extension) + file_name = '{0} - S{1}E{2} [{3} Sub].{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) 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)