Skip to content

plugins.lnk: add new plugin #4364

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

Merged
merged 3 commits into from
Mar 1, 2022
Merged

Conversation

justinas
Copy link
Contributor

LNK is a Lithuanian broadcasting group with several TV channels under it. Those are freely streamed at https://lnk.lt/tiesiogiai .

Copy link
Member

@bastimeyer bastimeyer left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. Adding a plugin for this site should be fine since this includes a live news channel.

Are the channel IDs static? According to the https://lnk.lt/api/main/content-page-by-program/tiesiogiai API endpoint, the IDs are episodeIds with certain endDates, so this suggests that they are dynamic.

The plugin code also needs some rework. I have fixed and improved it locally, so if you don't mind, I can add a commit to your PR branch.

@mkbloke
Copy link
Member

mkbloke commented Feb 25, 2022

It looks like some of the content is geo-restricted. Ideally, you should note that in the plugin matrix. You could probably test for it, provide an info level message then just return.

data["videoInfo"]["contentRestrict"] appears to be the bool you should look for. When true, data["videoInfo"]["videoUrl"] is an empty string.

You could also look at using schema validation for the returned JSON.

Also, as it's available, you could consider adding self.id = data["videoInfo"]["id"] and self.title = data["videoInfo"]["title"] for the plugin metadata.

@bastimeyer
Copy link
Member

Yes, I have done all of that already, but before pushing onto someone else's branch, I usually ask first.

@justinas
Copy link
Contributor Author

justinas commented Feb 25, 2022

Thank you both for the quick review.

@bastimeyer

Are the channel IDs static? According to the https://lnk.lt/api/main/content-page-by-program/tiesiogiai API endpoint, the IDs are episodeIds with certain endDates, so this suggests that they are dynamic.

The endDate seems to refer for the currently broadcasted programme, however the ID itself seems to remain static for the channel for a longer time. E.g. https://lnk.lt/api/video/video-config/137535 currently includes this:

    "airDate": "2020-12-28T12:58:16.674",
    "airDateText": "2020-12-28 12:58",

which makes me believe that the IDs do not change very often 🙂 It might be more correct to request https://lnk.lt/api/main/content-page-by-program/tiesiogiai first and parse the data from there. But I'm not sure if it's worth the hassle and complexity if the channel IDs are stable.

The plugin code also needs some rework. I have fixed and improved it locally, so if you don't mind, I can add a commit to your PR branch.

Absolutely, please go ahead! I am very new to the codebase, so I can't exactly say I know better.

@mkbloke Thank you for your notes, will try to look into the issues you mentioned as well.

@mkbloke
Copy link
Member

mkbloke commented Feb 25, 2022

@bastimeyer, OK. I was only making suggestions for the OP. That wasn't intended for you, it just happened to come after your reply.

@bastimeyer
Copy link
Member

Let's wait and check if the IDs change. If they change, then this static channel map obviously can't stay.

E.g.: `https://lnk.lt/tiesiogiai` would previously raise
"[plugins.lnk][error] Unknown channel: None".
This is because, per Python's docs, matchdict:

> Return a dictionary containing all the named subgroups of the match,
> keyed by the subgroup name. The default argument is used for groups
> that did not participate in the match; it defaults to None.

Therefore, get("channel", "lnk") would return the value of `None`,
as the key exists, rather than falling back to `"lnk"`.
@justinas
Copy link
Contributor Author

Hi again, reporting a couple days later, the IDs have not changed.

$ date -u
Sun Feb 27 08:04:35 PM UTC 2022
$ curl -sS https://lnk.lt/api/main/content-page-by-program/tiesiogiai | jq -r '.components[1].component.channels[] | [.channel, .episodeId] | @csv'
"LNK",137535
"BTV",137534
"2TV",95343
"Info TV",137748
"TV1",106791

@bastimeyer bastimeyer merged commit 1c0164c into streamlink:master Mar 1, 2022
Billy2011 pushed a commit to Billy2011/streamlink-27 that referenced this pull request Mar 3, 2022
Co-Authored-By: bastimeyer <mail@bastimeyer.de>
light4 pushed a commit to light4/streamlink that referenced this pull request Dec 9, 2022
Co-authored-by: bastimeyer <mail@bastimeyer.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants