Quantcast
Channel: Rainmeter Forums
Viewing all articles
Browse latest Browse all 1452

Help: Rainmeter Skins • Re: Problem with YouTube Subs Counter, Part2

$
0
0
I'm having a problem with the web parser's RegExp. I need to adjust or expand it so that a larger number of uploaded videos is displayed.

For example, the BCC channel, which has around 25,000 videos , RegExp can not fetch the data. Maybe someone can help me with how to expand the RegExp. Youtube-Chanel link: https://www.youtube.com/@BBCNews
Not even YouTube is crazy enough to have 25000 videos on a single page. If I CTRL+F to find "gridVideoRenderer" after right clicking to View Page Source on that page, I get only the first 96 occurrences (each of them with multiple identical videoId fields that you can grab). As for getting those, try something like the below (this works on my system, might not work on yours as YouTube could serve different page sources to different users) - very important, only use the online URL the first time, after that, work on the WebParserDump.txt file URL during the testing phase, so that you're not blocked / banned for polling the site too much or too frequently:

Code:

[Rainmeter]Update=1000AccurateText=1DynamicWindowSize=1[YoutubeChannel]Measure=WebParserURL=https://www.youtube.com/@BBCNews;URL=file://#CURRENTPATH#WebParserDump.txtUserAgent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36Flags=ForceReload | NoCookiesRegExp=(?siU).*"gridVideoRenderer".*"videoId":"(.*)".*"subscriberCountText":.*"[^"]*text":"(.*) .*"UpdateRate=1800FinishAction=[!UpdateMeter Result][!Redraw]Debug=2[SubsCount]Measure=WebParserURL=[YoutubeChannel]StringIndex=1[VideoId1]Measure=WebParserURL=[YouTubeChannel]StringIndex=2[Result]Meter=StringStringAlign=LeftY=0X=0SolidColor=0,0,0,255FontColor=255,255,255,255FontSize=37AntiAlias=1MeasureName=SubsCountMeasureName2=VideoId1Text=Subs Count: %1#CRLF#VideoId #1: %2
For getting all the VideoId parts (which could be 96 or less, depending on how many clips the first page of the channel has):
- see the note here: https://docs.rainmeter.net/manual/measures/webparser/#StringIndex
- see the tutorial here: https://docs.rainmeter.net/tips/webparser-lookahead-assertions-in-regexp/
To get the rest after the first page, well, that could be a problem. Even on the Videos tab for the channel, I can only find 30 "videoRenderer" parts (each with their own "videoId" parts), since the rest is feeded to the 'computed' version of the page trhough Javascript, which is not accessible to WebParser as it only gets the 'original' version. Even more so, YouTube doesn't use a standard page system (with different URL addresses, for example) for that list, it simply expands its <div> tags to list the extent desired by the user.

Statistics: Posted by Yincognito — Today, 8:27 am



Viewing all articles
Browse latest Browse all 1452

Trending Articles