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

Update kommunetv.py #32931

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion youtube_dl/extractor/kommunetv.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@


class KommunetvIE(InfoExtractor):
_VALID_URL = r'https://(\w+).kommunetv.no/archive/(?P<id>\w+)'
_VALID_URL = r'https?://\w+\.kommun(?:etv\.no|\.tv)/(?:archive|live)/(?P<id>\w+)'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_VALID_URL = r'https?://\w+\.kommun(?:etv\.no|\.tv)/(?:archive|live)/(?P<id>\w+)'
_VALID_URL = r'(?P<where>https?://\w+\.kommun(?:etv\.no|\.tv))/(?P<what>archive|live)/(?P<id>\w+)'

Then use the where group in the API URL (maybe Stavanger.kommunetv.no/api has diferent data from Oslo.kommunetv.no/api ?). Use the what to generate the correct streamType for the API, using ._download_json_handle(..., expected_status=404) for the live case and then chasing down the archive content if the live is gone.


_TEST = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this

    _TESTS = [{
...
    }]

and add tests for the various URL types.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I have considered doing something like that, but I'm unsure how to obtain the MD5 values.

Alternatively, I could create a new function specifically for live streams.

Copy link
Contributor

@dirkf dirkf Oct 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MD5 values may not be critical, especially as the site is sending adaptive formats where the value could vary. Anyhow, just draft a test case with url, id, ext; the test harness will tell you what other values must be included. For optional items like md5, include a dummy value and the test harness will show the correct value.

'url': 'https://oslo.kommunetv.no/archive/921',
'md5': '5f102be308ee759be1e12b63d5da4bbc',
Expand Down
Loading