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

Add duration to video metadata #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions youtube_api/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def parse_video_metadata(item):
"video_comment_count" : item["statistics"].get("commentCount"),
"video_like_count" : item["statistics"].get("likeCount"),
"video_dislike_count" : item["statistics"].get("dislikeCount"),
"duration" : item["contentDetails"]["duration"],
"video_thumbnail" : item["snippet"]["thumbnails"]["high"]["url"],
"video_tags" : video_tags,
"collection_date" : datetime.datetime.now()
Expand Down
10 changes: 5 additions & 5 deletions youtube_api/youtube_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ def get_channel_metadata(self, channel_id, parser=P.parse_channel_metadata,


def get_video_metadata_gen(self, video_id, parser=P.parse_video_metadata,
part=['statistics','snippet'], **kwargs):
part=['statistics','snippet','contentDetails'], **kwargs):
'''
Given a `video_id` returns metrics (views, likes, comments) and metadata (description, category) as a dictionary.
Given a `video_id` returns metrics (views, likes, comments, duration) and metadata (description, category) as a dictionary.

Read the docs: https://developers.google.com/youtube/v3/docs/videos/list

Expand Down Expand Up @@ -238,12 +238,12 @@ def get_video_metadata_gen(self, video_id, parser=P.parse_video_metadata,
else:
yield parser(None)
else:
raise Expection('This function only takes iterables!')
raise Exception('This function only takes iterables!')


def get_video_metadata(self, video_id, parser=P.parse_video_metadata, part=['statistics','snippet'], **kwargs):
def get_video_metadata(self, video_id, parser=P.parse_video_metadata, part=['statistics','snippet','contentDetails'], **kwargs):
'''
Given a single or list of `video_id` returns metrics (views, likes, comments) and metadata (description, category) as a dictionary.
Given a single or list of `video_id` returns metrics (views, likes, comments, duration) and metadata (description, category) as a dictionary.

Read the docs: https://developers.google.com/youtube/v3/docs/videos/list

Expand Down