Thanks to visit codestin.com
Credit goes to github.com

Skip to content

plugins.lnk: add new plugin#4364

Merged
bastimeyer merged 3 commits into
streamlink:masterfrom
justinas:add-plugin-lnk
Mar 1, 2022
Merged

plugins.lnk: add new plugin#4364
bastimeyer merged 3 commits into
streamlink:masterfrom
justinas:add-plugin-lnk

Conversation

@justinas

Copy link
Copy Markdown
Contributor

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

@bastimeyer bastimeyer left a comment

Copy link
Copy Markdown
Member

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

mkbloke commented Feb 25, 2022

Copy link
Copy Markdown
Member

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
Copy Markdown
Member

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

@justinas

justinas commented Feb 25, 2022

Copy link
Copy Markdown
Contributor Author

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

mkbloke commented Feb 25, 2022

Copy link
Copy Markdown
Member

@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
Copy Markdown
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
Copy Markdown
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
light4 pushed a commit to light4/streamlink that referenced this pull request Dec 9, 2022
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