Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various small fixes #24

Merged
merged 4 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Play one of the svt channels.
- service: svt_play.play_channel
entity_id: media_player.living_room_tv
data:
channel: svt1 # Available channels: svt1, svt2, svtbarn, kunskapskanalen, svt24
channel: svt1 # Available channels: svt1, svt2, barnkanalen, kunskapskanalen, svt24
```
### Play video id
If a specific video should be played, its "id" can be extracted from the url. For example `jXvZLoG` is the id found in the following url: `https://www.svtplay.se/video/jXvZLoG/ifs-invandrare-for-svenskar/avsnitt-3`
Expand Down
11 changes: 8 additions & 3 deletions custom_components/svt_play/video_url_fetch/live_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ def test_rapport_by_suggested():
assert url.startswith('http')


def test_svt1():
url = video_url_by_channel("svt1")
assert url.startswith('http')
def test_channels():
errors = []

for channel in ['svt1', 'svt2', 'barnkanalen', 'kunskapskanalen', 'svt24']:
url = video_url_by_channel(channel)
if not url.startswith('http'):
errors.append(channel)
assert not errors


def test_not_found_by_time():
Expand Down
4 changes: 2 additions & 2 deletions custom_components/svt_play/video_url_fetch/video_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def video_url_by_channel(channel_id, formats=default_formats):

def video_url_from_videoplayer_api(url, formats):
data = get(url).json()
if 'message' in data:
if 'error' in data:
raise Exception(
"Could not fetch video url: {}".format(data['message'])
"Could not fetch video url: {} {}".format(data['error'], url)
)

for format in formats:
Expand Down
2 changes: 1 addition & 1 deletion info.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Play one of the svt channels.
- service: svt_play.play_channel
entity_id: media_player.living_room_tv
data:
channel: svt1 # Available channels: svt1, svt2, svtbarn, kunskapskanalen, svt24
channel: svt1 # Available channels: svt1, svt2, barnkanalen, kunskapskanalen, svt24
```
### Play video id
If a specific video should be played, its "id" can be extracted from the url. For example `jXvZLoG` is the id found in the following url: `https://www.svtplay.se/video/jXvZLoG/ifs-invandrare-for-svenskar/avsnitt-3`
Expand Down
Loading