Skip to content

Commit

Permalink
Bug fix for #29 and #25
Browse files Browse the repository at this point in the history
- Fix for #29
- Fix for #28
- Fix for #25
  • Loading branch information
Xonshiz committed Jun 6, 2021
1 parent ffcde68 commit 969681f
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ hulusubs_dl/dev_test/main_test.py
hulusubs_dl/Hulusubs_dl_Error_Log.log
*.log
venv/*
hulusubs_dl/.DS_Store
4 changes: 3 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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".
- Added support to download subtitles of "movies".
- Fix for #29 and #28
- Fix for #25
4 changes: 3 additions & 1 deletion docs/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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".
- Added support to download subtitles of "movies".
- Fix for #29 and #28
- Fix for #25
Binary file modified hulusubs_dl/.DS_Store
Binary file not shown.
11 changes: 7 additions & 4 deletions hulusubs_dl/cust_utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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


Expand Down
5 changes: 2 additions & 3 deletions hulusubs_dl/hulu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 8 additions & 3 deletions hulusubs_dl/hulu_subs_dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 969681f

Please sign in to comment.