From 969681f23208867861c5d178f7d33e88cf465ca0 Mon Sep 17 00:00:00 2001 From: Xonshiz Date: Sun, 6 Jun 2021 19:42:30 +0530 Subject: [PATCH] Bug fix for #29 and #25 - Fix for #29 - Fix for #28 - Fix for #25 --- .gitignore | 1 + Changelog.md | 4 +++- docs/Changelog.md | 4 +++- hulusubs_dl/.DS_Store | Bin 6148 -> 6148 bytes hulusubs_dl/cust_utils/utils.py | 11 +++++++---- hulusubs_dl/hulu.py | 5 ++--- hulusubs_dl/hulu_subs_dl.py | 11 ++++++++--- 7 files changed, 24 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index efec097..e027973 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ hulusubs_dl/dev_test/main_test.py hulusubs_dl/Hulusubs_dl_Error_Log.log *.log venv/* +hulusubs_dl/.DS_Store diff --git a/Changelog.md b/Changelog.md index 5616ea4..06d62cb 100644 --- a/Changelog.md +++ b/Changelog.md @@ -7,4 +7,6 @@ - `#22` was still happening. Verified and fixed it. - Updated TravisCI Configs to do a Github Release. - Fixed #27 -- Added support to download subtitles of "movies". \ No newline at end of file +- Added support to download subtitles of "movies". +- Fix for #29 and #28 +- Fix for #25 \ No newline at end of file diff --git a/docs/Changelog.md b/docs/Changelog.md index 5616ea4..06d62cb 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -7,4 +7,6 @@ - `#22` was still happening. Verified and fixed it. - Updated TravisCI Configs to do a Github Release. - Fixed #27 -- Added support to download subtitles of "movies". \ No newline at end of file +- Added support to download subtitles of "movies". +- Fix for #29 and #28 +- Fix for #25 \ No newline at end of file diff --git a/hulusubs_dl/.DS_Store b/hulusubs_dl/.DS_Store index f253c957682e03a0ac3194748bc673eca1c94860..dc85f6240385382d81a8cf85a840ef0db9de7db0 100644 GIT binary patch delta 67 zcmZoMXfc=|#>B`mu~2NHo+2a5#DLw5ER%VdHg7)4?8LJ90y7)aW_AvK4xp0F2bsS! VPv#e~g1?m;q#95O@Fp delta 322 zcmZoMXfc=|#>B)qu~2NHo+2a9#DLw4FEBDP@=WGo++5Gfki<~Rkjaq4kdl*b7@VA+ zTfhJUbJ&goNhI0ad>5Cboctu9D2JVymVD~vLyqVwQV6Ih$Uw4T@du#xdIlDT6rlCR z3?(SmrzW`qW#MwjmKRB;PKR2KB#*Efn>>oesSqCm&1YcPe45dVWivYmKL;>`HXmgC V&ODi4#FB%NfdPns(g7k{m;rX0ONsyh diff --git a/hulusubs_dl/cust_utils/utils.py b/hulusubs_dl/cust_utils/utils.py index 1fe2b65..c1fef21 100644 --- a/hulusubs_dl/cust_utils/utils.py +++ b/hulusubs_dl/cust_utils/utils.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- from . import path_util -DEFAULT_SUB_EXT = ['vtt', 'ttml', 'smi'] +DEFAULT_SUB_EXT = ['webvtt', 'ttml', 'smi'] def get_value_from_list(value, list_object): @@ -117,9 +117,12 @@ def create_file_binary_mode(file_path, file_name, data_to_write): print("Empty data provided for {0}".format(file_name)) return False file_location = path_util.get_abs_path_name(file_path, file_name) - with open(file_location, 'wb') as f: - f.write(data_to_write) - f.flush() + try: + with open(file_location, 'wb') as f: + f.write(data_to_write) + f.flush() + except Exception as ex: + print("Exception Happened while writing: {0}".format(ex)) return True diff --git a/hulusubs_dl/hulu.py b/hulusubs_dl/hulu.py index 687737a..51851ed 100644 --- a/hulusubs_dl/hulu.py +++ b/hulusubs_dl/hulu.py @@ -75,9 +75,8 @@ def episode_link(self, url, cookie_value, language, extension, download_location download_location + os.sep + series_name + os.sep + season_number) if path_created: if extension == 'srt': - subtitle_content = subtitle_processing.convert_content(subtitle_content.decode('utf-8')) - file_written = utils.create_file_binary_mode(path_created, os.sep + file_name, - subtitle_content.encode('utf-8')) + subtitle_content = subtitle_processing.convert_content(subtitle_content.decode('utf-8')).encode('utf-8') + file_written = utils.create_file_binary_mode(path_created, os.sep + file_name, subtitle_content) if file_written: return True else: diff --git a/hulusubs_dl/hulu_subs_dl.py b/hulusubs_dl/hulu_subs_dl.py index 6973bca..10311a8 100644 --- a/hulusubs_dl/hulu_subs_dl.py +++ b/hulusubs_dl/hulu_subs_dl.py @@ -15,8 +15,8 @@ class HuluSubsDl: def __init__(self, argv, cwd): cookie_file_name = '/.cookie' config_file_name = '/.config' - supported_languages = ['en', 'es'] - supported_extensions = ['srt', 'vtt', 'smi', 'ttml'] + supported_languages = ['en', 'es', 'jp'] + supported_extensions = ['srt', 'webvtt', 'smi', 'ttml'] self.max_tries_for_cookie = 5 cookie_file_data = None config_file_data = None @@ -99,7 +99,10 @@ def __init__(self, argv, cwd): if not self.subtitle_lang: self.subtitle_lang = utils.get_value_from_list(args.subtitle_language[0], supported_languages) if not self.subtitle_extension: - self.subtitle_extension = utils.get_value_from_list(args.file_extension[0], supported_extensions) + self.subtitle_extension = utils.get_value_from_list(args.subtitle_extension[0], supported_extensions) + # If user provides VTT, we have to make it webvtt + if self.subtitle_extension.lower().strip() == "vtt": + self.subtitle_extension = "webvtt" if not self.download_location: if args.download_directory: self.download_location = args.download_directory[0] @@ -185,6 +188,8 @@ def get_cookie_from_user(): cookie = None while not cookie: cookie = input("Paste Hulu Cookie Value : ") + # Fix for #25 + cookie = cookie.replace('\\u2026', '') return cookie @staticmethod