Skip to content

Commit

Permalink
Adding YoutubeShort to documentation & fixing some type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
Yomguithereal committed Feb 29, 2024
1 parent eb152c4 commit 1f273f2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1837,12 +1837,16 @@ from ural.youtube import (
# You can also import the named tuples if you need them
YoutubeVideo,
YoutubeUser,
YoutubeChannel
YoutubeChannel,
YoutubeShort,
)

parse_youtube_url('https://www.youtube.com/watch?v=otRTOE9i51o')
>>> YoutubeVideo(id='otRTOE9i51o')

parse_youtube_url('https://www.youtube.com/shorts/GINlKobb41w')
>>> YoutubeShort(id='GINlKobb41w')

parse_youtube_url('https://lemonde.fr')
>>> None

Expand Down
2 changes: 1 addition & 1 deletion ural/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def parse_youtube_url(url, fix_common_mistakes=True):
_, _, path, query, fragment = parsed

# youtu.be
if parsed.hostname.endswith("youtu.be"):
if parsed.hostname and parsed.hostname.endswith("youtu.be"):

if path.count("/") > 0:
v = pathsplit(path)[0]
Expand Down
7 changes: 4 additions & 3 deletions ural/youtube.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ from ural.types import AnyUrlTarget

class YoutubeVideo(NamedTuple):
id: str
playlist: Optional[str]

class YoutubeUser(NamedTuple):
id: str
id: Optional[str]
name: str

class YoutubeChannel(NamedTuple):
id: str
name: str
id: Optional[str]
name: Optional[str]

class YoutubeShort(NamedTuple):
id: str
Expand Down

0 comments on commit 1f273f2

Please sign in to comment.