Skip to content

Commit

Permalink
Fix for #32
Browse files Browse the repository at this point in the history
Closes #32
  • Loading branch information
Xonshiz committed Jul 4, 2021
1 parent 9e45992 commit e8b5fae
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions hulusubs_dl/hulu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e8b5fae

Please sign in to comment.