From eaa97927184bfa1eb273813792efde9c6e493572 Mon Sep 17 00:00:00 2001 From: Hetari Date: Fri, 28 Jun 2024 20:54:26 +0300 Subject: [PATCH] fix: you can download live streams now --- CHANGELOG.md | 5 +++++ pyutube/tests/test_utils.py | 10 +--------- pyutube/utils.py | 8 +++++++- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d862d2..cd103e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Pyutube Changelog +## 1.2.9 + +- fix: improve cancel behavior in video quality selection +- fix: you can download live streams now + ## 1.2.8 - Add: if you download half of the playlist, you can resume the others without having to download them again. diff --git a/pyutube/tests/test_utils.py b/pyutube/tests/test_utils.py index 5266038..e76a4ab 100644 --- a/pyutube/tests/test_utils.py +++ b/pyutube/tests/test_utils.py @@ -4,12 +4,6 @@ from pyutube.utils import is_youtube_link from pyutube.utils import is_youtube_video -from pyutube.utils import clear - -# Test IDs for parametrization -HAPPY_PATH_ID = "happy_path" -EDGE_CASE_ID = "edge_case" -ERROR_CASE_ID = "error_case" @pytest.mark.parametrize("link, expected_result, test_id", [ @@ -55,9 +49,7 @@ False, "error_missing_question_mark"), ("https://youtu.be/dQw4w9WgXcQextra", True, "error_extra_characters"), ("https://www.youtube.com/watch?time_continue=1&v=dQw4w9WgXcQ", - True, "error_unexpected_params"), - ("https://www.youtu.be/dQw4w9WgXcQ?list=PLA7dr9B2F8mN5WLzcpC3sB9YR_ATCf90F", - True, "error_playlist_included"), + False, "error_unexpected_params"), ("https://example.com/watch?v=dQw4w9WgXcQ", False, "non_youtube_domain"), ("https://www.youtube.com/watchv=dQw4w9WgXcQ", False, "typo_in_query"), diff --git a/pyutube/utils.py b/pyutube/utils.py index e891504..e342097 100644 --- a/pyutube/utils.py +++ b/pyutube/utils.py @@ -115,8 +115,14 @@ def is_youtube_video(link: str) -> bool: Returns: bool: True if the link is a YouTube video, False otherwise. """ + # video_pattern = re.compile( + # r'(?:https?://)?(?:www\.)?(?:youtube\.com/(?:(?:live/?[a-zA-Z0-9_-]{11}\?si=)|(?:(?:watch\?v=)|(?:embed/))|youtu\.be/|youtube.com/share\?v=)([a-zA-Z0-9_-]{11}))') + # video_pattern = re.compile( + # r'(?:https?://)?(?:www\.)?(?:youtube\.com/(?:(?:watch\?v=)|(?:embed/))|youtu\.be/|youtube.com/share\?v=)([a-zA-Z0-9_-]{11})') video_pattern = re.compile( - r'(?:https?://)?(?:www\.)?(?:youtube\.com/(?:(?:watch\?v=)|(?:embed/))|youtu\.be/|youtube.com/share\?v=)([a-zA-Z0-9_-]{11})') + # "https://www.youtube.com/watch?time_continue=1&v=dQw4w9WgXcQ" + r"^(?:https?://)?(?:www\.)?(?:youtube(?:-nocookie)?\.com/(?:(watch\?v=|watch\?feature\=share\&v=)|embed/|v/|live_stream\?channel=|live\/)|youtu\.be/)([a-zA-Z0-9_-]{11})" + ) return bool(video_pattern.match(link))