Skip to content

Commit

Permalink
fix: you can download live streams now
Browse files Browse the repository at this point in the history
  • Loading branch information
Hetari committed Jun 28, 2024
1 parent 1abf621 commit eaa9792
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
10 changes: 1 addition & 9 deletions pyutube/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", [
Expand Down Expand Up @@ -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"),
Expand Down
8 changes: 7 additions & 1 deletion pyutube/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down

0 comments on commit eaa9792

Please sign in to comment.