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

Update kommunetv.py #32931

wants to merge 1 commit into from

Conversation

hmlb-no
Copy link

@hmlb-no hmlb-no commented Sep 26, 2024

Look at https://www.aventia.no/kommunetv/vare-kunder/

They are also in Sweeden.

Here is a problem tho.

https://stavanger.kommunetv.no/live/841

https://stavanger.kommunetv.no/archive/841

what if there is a live and a archive at the same time? how dose that work?

Please follow the guide below

  • You will be asked some questions, please read them carefully and answer honestly
  • Put an x into all the boxes [ ] relevant to your pull request (like that [x])
  • Use Preview tab to see how your pull request will actually look like

Before submitting a pull request make sure you have:

In order to be accepted and merged into youtube-dl each piece of code must be in public domain or released under Unlicense. Check one of the following options:

  • I am the original author of this code and I am willing to release it under Unlicense
  • I am not the original author of this code but it is in public domain or released under Unlicense (provide reliable evidence)

What is the purpose of your pull request?

  • Bug fix
  • Improvement
  • New extractor
  • New feature

Description of your pull request and other information

Explanation of your pull request in arbitrary form goes here. Please make sure the description explains the purpose and effect of your pull request and is worded well enough to be understood. Provide as much context and examples as possible.

Look at https://www.aventia.no/kommunetv/vare-kunder/

They are also in Sweeden.

Here is a problem tho.

https://stavanger.kommunetv.no/live/841

https://stavanger.kommunetv.no/archive/841

what if there is a live and a archive at the same time? how dose that work?
@dirkf
Copy link
Contributor

dirkf commented Oct 1, 2024

Here is a problem tho.

https://stavanger.kommunetv.no/live/841

https://stavanger.kommunetv.no/archive/841

what if there is a live and a archive at the same time? how dose that work?

If those are not the same thing (eg .../live/nnnn while live and .../archive/nnnn afterwards), the id could contain the last two elements of the path instead of the just the last element. Or some id that is unique across both path types may be hidden in the page, in which case that should be used.

@@ -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+)'

_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.

@hmlb-no
Copy link
Author

hmlb-no commented Oct 3, 2024

Here is a problem tho.
https://stavanger.kommunetv.no/live/841
https://stavanger.kommunetv.no/archive/841
what if there is a live and a archive at the same time? how dose that work?

If those are not the same thing (eg .../live/nnnn while live and .../archive/nnnn afterwards), the id could contain the last two elements of the path instead of the just the last element. Or some id that is unique across both path types may be hidden in the page, in which case that should be used.

Yes they are different content. The central difference is that the 'live' ID is for ween they are live and then after they are live the get converted into a archive but with a different ID. But ween a there exist a archive and ween they are livestraming tehy are not downloading the live but instead youtube-dl downloads the archive woon.

For instance https://stavanger.kommunetv.no/live/841 gets converted into a new ID and that is https://stavanger.kommunetv.no/archive/1142

@dirkf
Copy link
Contributor

dirkf commented Oct 3, 2024

live/841 corresponds to streamType=2&id=841 in the API;
archive/1142 corresponds to streamType=1&id=1142 in the API.

Maybe the id format should be 2_841, 1_1142?

If the live id gives 404 (no longer live), the page tries https://stavanger.kommunetv.no/api/search/live/{live_id}/related which, if it succeeds, gives the archive id at [data][0]['id'].

@@ -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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants