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

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

$
0
0
Hi!, I am building a 1x3 LED screen (64x192 dots), and i need a youtube sub counter, i tried code from 4 years ago.

I have "362" Subs, the skin shows "15" as seen in the image.
That's because in the page source (which you can view in Chrome by right clicking and choosing View Page Source) the number of subscribers from your channels (15 and 18) seem to be in front / before the total number of subscribers for your account - doing a CTRL+F to find "subscriberCountText" makes that obvious. To further "complicate" matters, the syntax before those 15, 18 and 362 values in the page source is exactly the same.

The solution to this is to choose the last subscriber count. In regular expressions this is done by "anchoring" the pattern to a relevant point for your case - say, the beginning of the string aka ^ - and then ignoring / skipping as many characters as possible - done by temporarily "inverting" the ?U ungreedy flag at the start by adding a ? after .* and make mtatching greedy - before matching the desired text. So, something like this should do (added the UserAgent and some Flags just in case, see the WebParser measure):

Code:

[Rainmeter]Update=1000AccurateText=1DynamicWindowSize=1BackgroundMode=2SolidColor=0,0,0,255[Variables][StatsSubs]Measure=WebParserURL=https://www.youtube.com/dasiunUserAgent=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)^.*?"subscriberCountText":.*"[^"]*text":"([^"]*)"StringIndex=1UpdateRate=3600debug=2[Subscribers]Meter=StringMeasureName=StatsSubsStringAlign=LeftY=0X=0FontSize=37FontColor=55EE55AntiAlias=1Text=Subs: %1
I removed the "header" part as it didn't make much sense here, since it has 7 occurrences in the page source (a regex pattern is the more effective as its parts are more rare in the string, ideally the only such parts).

Statistics: Posted by Yincognito — Today, 9:50 pm



Viewing all articles
Browse latest Browse all 1528

Trending Articles