plugin.youtube: find video id in page, fall back to API#1746
Conversation
6b81321 to
7ab5661
Compare
Codecov Report
@@ Coverage Diff @@
## master #1746 +/- ##
=========================================
+ Coverage 49.86% 50% +0.13%
=========================================
Files 238 238
Lines 13976 14025 +49
=========================================
+ Hits 6969 7013 +44
- Misses 7007 7012 +5 |
|
While processing this, wouldn't be nice to be able to set custom API in plugin options? On the other hand protected videos might play with fallback method. |
|
@Twilight0 you mean to be able to set a custom API key? |
|
Yes I meant custom API key. |
|
It could be added (I wrote the code already), but it might not be needed now. |
| # find the videoRenderer object, where there is a LVE NOW badge | ||
| for x in search_dict(data, 'videoRenderer'): | ||
| for blabel in search_dict(x.get("badges", {}), "label"): | ||
| if blabel == "LIVE NOW": |
There was a problem hiding this comment.
if blabel == "LIVE NOW":
won't work as this string changes with every different youtube language version
maybe you can use the
'style': 'BADGE_STYLE_TYPE_LIVE_NOW'
maybe this work,
tested on
some urls from the header will work too
| match = _channelid_re.search(res.text) | ||
| if not match: | ||
| return | ||
| res = http.get(self.url, headers={"User-Agent": useragents.CHROME}) |
There was a problem hiding this comment.
could you also force the chrome header on the whole plugin and remove all the other headers
if the youtube stream is embedded,
the User-Agent can change to something else from the previous plugin and might break some regex
def _get_streams(self):
+ http.headers.update({'User-Agent': useragents.CHROME})|
Good points, thanks @back-to |
|
Thank you for adding the custom option for user-set API Key. |
|
This looks good. Do you still want to perform more testing on live channels or are you okay with getting this in now @beardypig. |
|
I've tested it on quite a few live videos and it seems to work well for me - there is always the fallback to the API if it does break or doesn't work for some channels :) |
|
Okay merging then, thanks @beardypig. |
|
Just tested this on a few live streams myself using 13.0 and these updated YouTube plugin files and it's working again. |
As discussed in #1728 with @back-to, this PR modifies the YouTube plugin to search for the channel's video ID in the page first before trying the API. This should alleviate the pressure on the YouTube API key.
Also added some better error logging if there is an error when calling the API.
Requires testing on more channels
Fixes #1728