-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sourcery refactored master branch #1
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,8 +109,7 @@ def find_smallest_video_asset_url(wistia_hashed_id, s=session): | |
assets = media_data['assets'] | ||
video_assets = [a for a in assets if a['contentType'] == 'video/mp4'] | ||
smallest_video = sorted(video_assets, key=lambda v: v['fileSize'])[0] | ||
video_file_url = smallest_video['url'] + '.mp4' # Append extension | ||
return video_file_url | ||
return smallest_video['url'] + '.mp4' | ||
|
||
|
||
def show_media(wistia_hashed_id, s=session): | ||
|
@@ -120,8 +119,7 @@ def show_media(wistia_hashed_id, s=session): | |
r = s.get(url) | ||
if not r.ok: | ||
r.raise_for_status() | ||
media_data = r.json() | ||
return media_data | ||
return r.json() | ||
Comment on lines
-123
to
+122
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
|
||
def download_file(file_url): | ||
|
@@ -130,8 +128,7 @@ def download_file(file_url): | |
|
||
|
||
def autosub_video_file(video_file_name): | ||
srt_file_name = autosub.generate_subtitles(source_path=video_file_name) | ||
return srt_file_name | ||
return autosub.generate_subtitles(source_path=video_file_name) | ||
Comment on lines
-133
to
+131
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
|
||
def upload_subtitle_file_to_wistia_video( | ||
|
@@ -152,20 +149,19 @@ def upload_subtitle_file_to_wistia_video( | |
captions_list = r.json() | ||
replaceable_captions = [c for c in captions_list if c['language'] == language_code] | ||
|
||
base_url = 'https://api.wistia.com/v1' | ||
url_template = '{base_url}/medias/{media_hashed_id}/captions/{language_code}.json' | ||
if replace and replaceable_captions: | ||
base_url = 'https://api.wistia.com/v1' | ||
url_template = '{base_url}/medias/{media_hashed_id}/captions/{language_code}.json' | ||
detail_url = url_template.format( | ||
base_url=base_url, | ||
media_hashed_id=wistia_hashed_id, | ||
language_code=language_code, | ||
) | ||
r = s.put(detail_url, files=files) | ||
r.raise_for_status() | ||
|
||
else: | ||
r = s.post(list_url, data=dict(language_code=language_code), files=files) | ||
r.raise_for_status() | ||
|
||
r.raise_for_status() | ||
Comment on lines
-155
to
+164
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
|
||
def get_media_url(media_hashed_id): | ||
|
@@ -280,8 +276,7 @@ def parse_arguments(): | |
help='Print a list of all projects in your Wistia account', | ||
action='store_true', | ||
) | ||
args = parser.parse_args() | ||
return args | ||
return parser.parse_args() | ||
Comment on lines
-283
to
+279
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
|
||
if __name__ == '__main__': | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
find_smallest_video_asset_url
refactored with the following changes:inline-immediately-returned-variable
)This removes the following comments ( why? ):