diff --git a/test/youtube_test.py b/test/youtube_test.py index 4a7d668..72c4b94 100644 --- a/test/youtube_test.py +++ b/test/youtube_test.py @@ -243,6 +243,11 @@ YoutubeShort(id="U5Bn8mMxj4o"), "https://www.youtube.com/shorts/U5Bn8mMxj4o", ), + ( + "https://www.youtube.com/shorts/", + None, + "https://www.youtube.com/shorts/", + ), ] diff --git a/ural/youtube.py b/ural/youtube.py index bd4a8b0..04fbf66 100644 --- a/ural/youtube.py +++ b/ural/youtube.py @@ -374,7 +374,10 @@ def parse_youtube_url(url, fix_common_mistakes=True): elif path.startswith("/shorts/"): splitted_path = pathsplit(path) - v = pathsplit(path)[1] + if len(splitted_path) < 2: + return None + + v = splitted_path[1] if fix_common_mistakes: v = v[:11]