It is currently September 14th, 2024, 10:27 pm

YouTube View/Sub Counter HELP!

Get help with creating, editing & fixing problems with skins
Nefarious
Posts: 3
Joined: June 13th, 2020, 5:12 am

YouTube View/Sub Counter HELP!

Post by Nefarious »

Soooo i had a viewer/sub counter for youtube and honestly it worked fine for quite some time. It seems that something recently changed that made it so that now i can see the channel name but the view/sub count no longer registers.... ive tried playing with the RegExp alittle but to no avail.. I would highly highly appreciate if someone who knows rainmeter better than me helped me fix this. Ive done most of the work, some of it i wrote and some from examples of ones i downloaded but even with everything ive tried nothing has worked. Heres what i got, the channel name is showing but no subs and no views, again just to reiterate, this exact skin worked like 2 weeks ago and randomly stopped working. If anyone is interested, ill even pay like 20 bucks PayPal for a nice one.


Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1

[Metadata]
Name=Youtube Channel Sub/View Counter
Author=Nefarious

[Variables]
Channel=https://www.youtube.com/channel/UC11iIc7c3xemjl1pvsCx1Gg/about
Font=Ubuntu

; Time between checks/updates for stats/picture
UpdateTime=3600

;Font color in RGB format
RGBFontColor=255,255,255

[StatsSubs]
Measure=Plugin
Plugin=WebParser
URL=#Channel#
RegExp=(?siU)subscriber-count.*>(.*)</span>
StringIndex=1
UpdateRate=#UpdateTime#
debug=1

[StatsViews]
Measure=Plugin
Plugin=WebParser
URL=#Channel#
RegExp=(?siU)&bull; <b>(.*)</b>
StringIndex=2
UpdateRate=#UpdateTime#

[StatsUsername]
Measure=Plugin
Plugin=WebParser
URL=#Channel#
RegExp=meta property="og:title" content="(.*)">
StringIndex=1
UpdateRate=#UpdateTime#

[Subscribers]
Meter=String
MeasureName=StatsSubs
StringAlign=Right
Y=50
X=490
FontSize=18
FontFace=#Font#
FontColor=#RGBFontColor#
AntiAlias=1

[Views]
Meter=String
MeasureName=StatsViews
StringAlign=Right
Y=90
X=490
FontSize=18
FontFace=#Font#
FontColor=#RGBFontColor#
AntiAlias=1

[Username]
Meter=String
MeasureName=StatsUsername
StringAlign=Right
X=565
Y=1
FontFace=#Font#
FontSize=22
FontColor=#RGBFontColor#
StringStyle=Bold
AntiAlias=1

[ProfilePictureDownload]
Measure=Plugin
Plugin=WebParser
UpdateRate=#UpdateTime#
Url=[StatsPic]
StringIndex=1
DynamicVariables=1
Download=1

[SubscribersLabel]
Meter=String
DynamicVariables=1
Text=SUBS
StringAlign=Right
X=560
Y=57
AntiAlias=1
FontFace=#Font#
FontSize=15
FontColor=#RGBFontColor#

[ViewsLabel]
Meter=String
DynamicVariables=1
Text=VIEWS
StringAlign=Right
X=560
Y=96
AntiAlias=1
FontFace=#Font#
FontSize=15
FontColor=#RGBFontColor#
nopeless
Posts: 2
Joined: June 13th, 2020, 10:12 am

Re: YouTube View/Sub Counter HELP!

Post by nopeless »

[StatsSubs]
RegExp=subscriberCountText":{"simpleText":"(.+?)"

[StatsViews]
RegExp=viewCountText":{"simpleText":"(.+?)"


maybe try this



It's better to use the youtube API
but I'm assuming that it would be more complicated for you to get an API key and work with that so...
Nefarious
Posts: 3
Joined: June 13th, 2020, 5:12 am

Re: YouTube View/Sub Counter HELP!

Post by Nefarious »

WOW, that worked man! Thank you so much man. Do you want the paypal money that i mentioned in post? Id be glad to give it to you man.
nopeless
Posts: 2
Joined: June 13th, 2020, 10:12 am

Re: YouTube View/Sub Counter HELP!

Post by nopeless »

I just debugged the HTML file response using WebParser's built-in debug mode
Found out that your regex is outdated

It might be possible that the regex I made will get outdated too since YouTube is not obligated to keep their HTML files consistent.
The discord really helped me learn a lot in a day(you are the first one I helped after learning rainmeter) so I want to direct the kudos to all the kind people there who linked me the docs and explained stuff.

But if you really want to thank in some way, maybe gift me nitro 10$ on nope#7777

Glad my response worked.
Nefarious
Posts: 3
Joined: June 13th, 2020, 5:12 am

Re: YouTube View/Sub Counter HELP!

Post by Nefarious »

Accept my friend request, i gifted it for you. :)
pugshot
Posts: 2
Joined: June 6th, 2020, 7:36 pm

Re: YouTube View/Sub Counter HELP!

Post by pugshot »

Hello! I tried using the new RegExp snippets, and it shows a wrong sub count for my channel. I tried with 2 channels, the other it seems to show correctly, but the other one it doesn't. It always shows 1.1K despite me having 3.9K subs. I tried with both the permanent URL about page, as well as the letternumber combo version of the channel name, and neither worked.

I'd also like to know if there is a way to remove the "subscribers" text after the number.

Code:

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1

[Metadata]
Name=YouTube Subscribers and View Counter
Author=ANB
Information=Edit the file and change the channel variable
License=Creative Commons Attribution 4.0 International License
Version=1.0.0.0

[Variables]
; Post the YouTube channel About page below.
Channel=https://www.youtube.com/channel/UCV7rj-XuKNNcc0ucr7S6Ddg/about

;Any installed Windows Font Supported
Font=Pixel

; Time between checks/updates for stats/picture
UpdateTime=3600

;Font color in RGB format
RGBFontColor=255,255,255

[StatsSubs]
Measure=Plugin
Plugin=WebParser
URL=#Channel#
FontFace=LLPixel
RegExp=subscriberCountText":{"simpleText":"(.+?)"
StringIndex=1
UpdateRate=#UpdateTime#
debug=2

[StatsViews]
Measure=Plugin
Plugin=WebParser
URL=#Channel#
RegExp=viewCountText":{"simpleText":"(.+?)"

StringIndex=1
UpdateRate=#UpdateTime#

[StatsUsername]
Measure=Plugin
Plugin=WebParser
URL=#Channel#
FontFace="LLPixel Regular"
RegExp=meta property="og:title" content="(.*)">
StringIndex=1
UpdateRate=#UpdateTime#

[Subscribers]
Meter=String
MeasureName=StatsSubs
StringAlign=Left
Y=50
X=10
FontSize=37
FontFace=LLPixel
FontColor=#RGBFontColor#
AntiAlias=0

User avatar
Yincognito
Rainmeter Sage
Posts: 8127
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: YouTube View/Sub Counter HELP!

Post by Yincognito »

pugshot wrote: July 1st, 2020, 4:40 pm Hello! I tried using the new RegExp snippets, and it shows a wrong sub count for my channel. I tried with 2 channels, the other it seems to show correctly, but the other one it doesn't. It always shows 1.1K despite me having 3.9K subs. I tried with both the permanent URL about page, as well as the letternumber combo version of the channel name, and neither worked.

I'd also like to know if there is a way to remove the "subscribers" text after the number.
Well, since no one else jumped in, there you go:

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1

[Metadata]
Name=YouTube Subscribers and View Counter
Author=ANB
Information=Edit the file and change the channel variable
License=Creative Commons Attribution 4.0 International License
Version=1.0.0.0

[Variables]
; Post the YouTube channel About page below.
Channel=https://www.youtube.com/channel/UCV7rj-XuKNNcc0ucr7S6Ddg/about

;Any installed Windows Font Supported
Font=Pixel

; Time between checks/updates for stats/picture
UpdateTime=3600

;Font color in RGB format
RGBFontColor=255,255,255

[StatsSubs]
Measure=Plugin
Plugin=WebParser
URL=#Channel#
FontFace=LLPixel
RegExp=(?siU)^.*"subscriberCountText":\{"runs":\[\{"text":"([^"]*)"\}\]\}
StringIndex=1
UpdateRate=#UpdateTime#
debug=2
RegExpSubstitute=1
Substitute=" .*$":""

[StatsViews]
Measure=Plugin
Plugin=WebParser
URL=#Channel#
RegExp=(?siU)^.*"viewCountText":\{"runs":\[\{"text":"([^"]*)".*\}\]\}
StringIndex=1
UpdateRate=#UpdateTime#

[StatsUsername]
Measure=Plugin
Plugin=WebParser
URL=#Channel#
FontFace="LLPixel Regular"
RegExp=(?siU)^.*meta property="og:title" content="([^"]*)">
StringIndex=1
UpdateRate=#UpdateTime#

[Subscribers]
Meter=String
MeasureName=StatsSubs
StringAlign=Left
Y=50
X=10
FontSize=37
FontFace=LLPixel
FontColor=#RGBFontColor#
AntiAlias=0
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
pugshot
Posts: 2
Joined: June 6th, 2020, 7:36 pm

Re: YouTube View/Sub Counter HELP!

Post by pugshot »

Yincognito wrote: July 3rd, 2020, 4:39 pm Well, since no one else jumped in, there you go:
Thanks, it worked. However, can you educate me why two channels need two different regexp codes to work? I have 2 channels, and if I swap these regexp snippets, both stop working and don't show anything.

The other channel needs them like this:
RegExp=(?siU)^.*"subscriberCountText":\{"runs":\[\{"text":"([^"]*)"\}\]\}
RegExp=(?siU)^.*"viewCountText":\{"runs":\[\{"text":"([^"]*)".*\}\]\}

and the other channel like this:
RegExp=subscriberCountText":{"simpleText":"(.+?)"
RegExp=viewCountText":{"simpleText":"(.+?)"

If they are swapped, both stop working. Why don't both work with the same values?
User avatar
Yincognito
Rainmeter Sage
Posts: 8127
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: YouTube View/Sub Counter HELP!

Post by Yincognito »

pugshot wrote: July 4th, 2020, 2:05 pm Thanks, it worked. However, can you educate me why two channels need two different regexp codes to work? I have 2 channels, and if I swap these regexp snippets, both stop working and don't show anything.

The other channel needs them like this:
RegExp=(?siU)^.*"subscriberCountText":\{"runs":\[\{"text":"([^"]*)"\}\]\}
RegExp=(?siU)^.*"viewCountText":\{"runs":\[\{"text":"([^"]*)".*\}\]\}

and the other channel like this:
RegExp=subscriberCountText":{"simpleText":"(.+?)"
RegExp=viewCountText":{"simpleText":"(.+?)"

If they are swapped, both stop working. Why don't both work with the same values?
Yeah, I noticed that as well (or I thought I did before). The reason is that the page source that we get the above data from has a slightly different structure in those cases. Why a different structure, I don't know - maybe it's related to the fact that some "channels" are in the form of https://www.youtube.com/user/<SomeUserHere>/about and others are in the form of https://www.youtube.com/channel/<SomeChannelHere>/about... :confused:

However, once I formatted the source HTML, it became clearer what should be done. So, replace your regexes with:

Code: Select all

RegExp=(?siU)"header":.*"subscriberCountText":.*"[^"]*text":"([^"]*)"

Code: Select all

RegExp=(?siU)"channelAboutFullMetadataRenderer":.*"viewCountText":.*"[^"]*text":"([^"]*)"
and see if it works. This should handle both types of "channels" - if not, post the link of the channel not working with this code, in order to see where the problem is located.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
bkweibley
Posts: 5
Joined: July 14th, 2023, 2:49 pm

Re: YouTube View/Sub Counter HELP!

Post by bkweibley »

nopeless wrote: June 14th, 2020, 10:32 am I just debugged the HTML file response using WebParser's built-in debug mode
Found out that your regex is outdated

It might be possible that the regex I made will get outdated too since YouTube is not obligated to keep their HTML files consistent.
The discord really helped me learn a lot in a day(you are the first one I helped after learning rainmeter) so I want to direct the kudos to all the kind people there who linked me the docs and explained stuff.

But if you really want to thank in some way, maybe gift me nitro 10$ on nope#7777

Glad my response worked.
How do I find this discord server?