Skip to content

Commit

Permalink
Added clarifications to video_url. Check video URLs for all available…
Browse files Browse the repository at this point in the history
… video qualities (Fixes #257)
  • Loading branch information
tehkillerbee committed Sep 11, 2024
1 parent c0a6aef commit 39ada55
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 16 additions & 1 deletion tests/test_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from dateutil import tz

import tidalapi
from tidalapi import VideoQuality
from tidalapi.exceptions import MetadataNotAvailable, ObjectNotFound
from tidalapi.media import (
AudioExtensions,
Expand All @@ -32,7 +33,6 @@
MimeType,
Quality,
)

from .cover import verify_image_resolution, verify_video_resolution


Expand Down Expand Up @@ -341,8 +341,23 @@ def test_video_no_release_date(session):
]


def test_video_not_found(session):
with pytest.raises(ObjectNotFound):
session.video(12345678)


def test_video_url(session):
# Test video URLs at all available qualities
video = session.video(125506698)
session.video_quality = VideoQuality.low
url = video.get_url()
assert "m3u8" in url
verify_video_resolution(url, 640, 360)
session.video_quality = VideoQuality.medium
url = video.get_url()
assert "m3u8" in url
verify_video_resolution(url, 1280, 720)
session.video_quality = VideoQuality.high
url = video.get_url()
assert "m3u8" in url
verify_video_resolution(url, 1920, 1080)
Expand Down
2 changes: 1 addition & 1 deletion tidalapi/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ def _get(self, media_id: str) -> Video:
return cast("Video", video)

def get_url(self) -> str:
"""Retrieves the URL for a video.
"""Retrieves the URL to the m3u8 video playlist
:return: A `str` object containing the direct video URL
:raises: A :class:`exceptions.URLNotAvailable` if no URL is available for this video
Expand Down

0 comments on commit 39ada55

Please sign in to comment.