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 be80b26
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
16 changes: 16 additions & 0 deletions 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 Down Expand Up @@ -341,8 +342,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
3 changes: 2 additions & 1 deletion tidalapi/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,7 @@ def _get(self, media_id: str) -> Video:
:param media_id: TIDAL's identifier of the video
:return: A :class:`Video` object containing all the information about the video.
:raises: A :class:`exceptions.ObjectNotFound` if video is not found or unavailable
"""

try:
Expand All @@ -886,7 +887,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 be80b26

Please sign in to comment.