Skip to content

Commit

Permalink
Adding more info to YT video outputs
Browse files Browse the repository at this point in the history
Fix #948
  • Loading branch information
Yomguithereal committed Mar 28, 2024
1 parent 9f0e6cf commit 741e064
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ftest/youtube_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

client = YouTubeAPIClient(config["youtube"]["key"])
console.print(
client.video("https://www.youtube.com/watch?v=uH7e9wumYWg", raw=True),
client.video("https://www.youtube.com/watch?v=auPMtIFJGsQ", raw=False),
highlight=True,
)
3 changes: 3 additions & 0 deletions minet/youtube/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class YouTubeVideo(YouTubeVideoSnippet):
has_captions: bool
category_id: str
category: Optional[str]
topics: List[str]
tags: List[str]

@classmethod
Expand All @@ -98,6 +99,7 @@ def from_payload(cls, payload) -> "YouTubeVideo":
stats = payload["statistics"]
details = payload["contentDetails"]
category_id = snippet["categoryId"]
topics = getpath(payload, ("topicDetails", "topicCategories"), [])

return cls(
video_id=payload["id"],
Expand All @@ -117,6 +119,7 @@ def from_payload(cls, payload) -> "YouTubeVideo":
duration=details["duration"],
has_captions=details["caption"] == "true",
tags=snippet.get("tags", []),
topics=topics,
)


Expand Down
5 changes: 4 additions & 1 deletion minet/youtube/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ def playlist_videos(self, playlist_id: str, token: Optional[str]) -> str:
def videos(self, ids: Iterable[str]) -> str:
return self.format(
path="videos",
args={"id": ids, "part": ["snippet", "statistics", "contentDetails"]},
args={
"id": ids,
"part": ["snippet", "statistics", "contentDetails", "topicDetails"],
},
)

def channels(self, ids: Iterable[str]) -> str:
Expand Down

0 comments on commit 741e064

Please sign in to comment.