Skip to content

Commit

Permalink
add type to pyi and to normalize url function
Browse files Browse the repository at this point in the history
  • Loading branch information
Kelly Christensen committed Feb 29, 2024
1 parent 0b874d5 commit 736221f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ural/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,4 +429,8 @@ def normalize_youtube_url(url):

return YOUTUBE_CHANNEL_NAME_URL_TEMPLATE % parsed.name

if isinstance(parsed, YoutubeShort):
if parsed.id is not None:
return YOUTUBE_SHORT_URL_TEMPLATE % parsed.id

raise TypeError("normalize_youtube_url: impossible path reached")
3 changes: 3 additions & 0 deletions ural/youtube.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ class YoutubeChannel(NamedTuple):
id: str
name: str

class YoutubeShort(NamedTuple):
id: str

def is_youtube_url(url: AnyUrlTarget) -> bool: ...
def is_youtube_video_id(value: str) -> bool: ...
def is_youtube_channel_id(value: str) -> bool: ...
Expand Down

0 comments on commit 736221f

Please sign in to comment.