Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions wistitler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Copy link
Author

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:

This removes the following comments ( why? ):

# Append extension



def show_media(wistia_hashed_id, s=session):
Expand All @@ -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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function show_media refactored with the following changes:



def download_file(file_url):
Expand All @@ -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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function autosub_video_file refactored with the following changes:



def upload_subtitle_file_to_wistia_video(
Expand All @@ -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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function upload_subtitle_file_to_wistia_video refactored with the following changes:



def get_media_url(media_hashed_id):
Expand Down Expand Up @@ -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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function main.parse_arguments refactored with the following changes:



if __name__ == '__main__':
Expand Down