It is currently April 28th, 2024, 4:43 pm

Social Media Counter

General topics related to Rainmeter.
bkweibley
Posts: 5
Joined: July 14th, 2023, 2:49 pm

Social Media Counter

Post by bkweibley »

I am brand new to Rainmeter was was curious if anyone has seen any posts on adding Social Media counters to their Rainmeter layout. I searched the forum but did not see any. Thanks in advance!
User avatar
Yincognito
Rainmeter Sage
Posts: 7179
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Social Media Counter

Post by Yincognito »

bkweibley wrote: July 14th, 2023, 2:52 pm I am brand new to Rainmeter was was curious if anyone has seen any posts on adding Social Media counters to their Rainmeter layout. I searched the forum but did not see any. Thanks in advance!
Yes, there are. Can't tell if they match what you're looking for or post any links as I'm on my phone right now, but I know for sure that I've seen at least a YT viewer counter or something along those lines. As long as the info is exposed in the webpage source, it can be retrieved by a WebParser measure in Rainmeter.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16184
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Social Media Counter

Post by balala »

Yincognito wrote: July 14th, 2023, 3:05 pm As long as the info is exposed in the webpage source, it can be retrieved by a WebParser measure in Rainmeter.
Unless logon is required. But in this case, I think a logon is absolutely necessary, so I better would say it is not quite possible. Might be wrong, but this is my thought.
User avatar
Yincognito
Rainmeter Sage
Posts: 7179
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Social Media Counter

Post by Yincognito »

balala wrote: July 14th, 2023, 6:58 pm Unless logon is required. But in this case, I think a logon is absolutely necessary, so I better would say it is not quite possible. Might be wrong, but this is my thought.
I believe you're right - didn't think about that aspect, thanks. This doesn't make it impossible though, just possible if you're already logged on. Of course, if you already are, you should be able to see the data from that social media app even without a Rainmeter skin showing it, but that's another story.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16184
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Social Media Counter

Post by balala »

Yincognito wrote: July 14th, 2023, 7:15 pm This doesn't make it impossible though, just possible if you're already logged on.
Yep, but I think the question was to see in a Rainmeter skin what the counter returns. For this, is not enough to be logged on in the browser, should have be in the skin, which unless the source supports HTTP authentication, is not possible, at least as far as I can tell.
User avatar
Yincognito
Rainmeter Sage
Posts: 7179
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Social Media Counter

Post by Yincognito »

balala wrote: July 14th, 2023, 7:25 pm Yep, but I think the question was to see in a Rainmeter skin what the counter returns. For this, is not enough to be logged on in the browser, should have be in the skin, which unless the source supports HTTP authentication, is not possible, at least as far as I can tell.
Quite likely, you might be right... again. :lol:
I guess I was going by the scenario from this thread, and not taking into account that in that case the info is publicly available to anyone, unlike most of the other cases which require authentication. But then, I'm far from being the most social media person, so unless the scenario the OP has in mind isn't specified and an attempt is made, what you said should be the standard answer to this.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16184
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Social Media Counter

Post by balala »

Yincognito wrote: July 14th, 2023, 7:42 pm Quite likely, you might be right... again. :lol:
I guess I was going by the scenario from this thread, and not taking into account that in that case the info is publicly available to anyone, unlike most of the other cases which require authentication. But then, I'm far from being the most social media person, so unless the scenario the OP has in mind isn't specified and an attempt is made, what you said should be the standard answer to this.
Yep, So:
bkweibley wrote: July 14th, 2023, 2:52 pm I am brand new to Rainmeter was was curious if anyone has seen any posts on adding Social Media counters to their Rainmeter layout. I searched the forum but did not see any. Thanks in advance!
What Social Media counter would you like to display?
bkweibley
Posts: 5
Joined: July 14th, 2023, 2:49 pm

Re: Social Media Counter

Post by bkweibley »

I assumed this would be an API type thing. I was looking for Instagram, Tiktok, and Youtube. I know that companies make counters that you can sit around your house and Im almost positive they are using API, thats why I thought maybe this sort of thing would also be possible with Rainmeter. I was able to find this thread when looking around, this looks like scraping instead of API im assuming, but since my profile is public im assuming this still works. Im not quite understanding the solution though, I guess I dont understand exactly what I would be doing with it.
https://stackoverflow.com/questions/63709996/how-to-get-instagram-follower-count-from-instagram-public-account-after-2020-ins
User avatar
Yincognito
Rainmeter Sage
Posts: 7179
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Social Media Counter

Post by Yincognito »

bkweibley wrote: July 15th, 2023, 12:28 am I assumed this would be an API type thing. I was looking for Instagram, Tiktok, and Youtube. I know that companies make counters that you can sit around your house and Im almost positive they are using API, thats why I thought maybe this sort of thing would also be possible with Rainmeter. I was able to find this thread when looking around, this looks like scraping instead of API im assuming, but since my profile is public im assuming this still works. Im not quite understanding the solution though, I guess I dont understand exactly what I would be doing with it.
https://stackoverflow.com/questions/63709996/how-to-get-instagram-follower-count-from-instagram-public-account-after-2020-ins
Well, like I said, as long as the info is exposed in the webpage source (whatever that may be), it can be retrieved by a WebParser measure in Rainmeter:

Code: Select all

; Reference: https://stackoverflow.com/a/73376216/8418085

[Variables]
UserName=Madonna
UserAgent=Instagram 76.0.0.15.395 Android (24/7.0; 640dpi; 1440x2560; samsung; SM-G930F; herolte; samsungexynos8890; en_US; 138226743)

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
BackgroundMode=2
SolidColor=47,47,47,255

---Measures---

[InstagramFollowers]
Measure=WebParser
URL=https://i.instagram.com/api/v1/users/web_profile_info/?username=#UserName#
RegExp=(?siU)"edge_followed_by":.*"count":(.*)[},]
StringIndex=1
UpdateRate=-1
Flags=Resync | NoCookies
UserAgent=#UserAgent#
RegExpSubstitute=1
Substitute="^(?:|null)$":"0"
; Debug=2

---Meters---

[Result]
Meter=String
FontFace=Consolas
FontColor=255,255,255,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
MeasureName=InstagramFollowers
Text=#UserName# has %1 followers on Instagram
DynamicVariables=1
Instagram Followers.jpg
You did well posting a SO link about it, because it was key to get the desired info (and the header is essential for it to work, just as the answer said, by the way). I don't know for how long this will work, obviously, but for now it does its job quite nicely.

There are a bunch of other stuff in that webpage source that might interest a skin designer of such a thing, something one can easily see by uncommenting (i.e. remove the starting ; from) the Debug=2 line. This is actually recommended when testing things out, since the page is downloaded as WebParserDump.txt in the current / skin folder, making it easier to try various regular expressions (regexes) to get other data from the offline local file, without worrying that your IP might be banned or flagged if polling the Instagram site too often.

P.S. The skin will take a couple of moments to get the data from the site, and during that time the output will be 0 via the Substitute option. This is intentional, in case the data is the "null" value, but you can remove the substitute options if you don't want this behavior.
You do not have the required permissions to view the files attached to this post.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
bkweibley
Posts: 5
Joined: July 14th, 2023, 2:49 pm

Re: Social Media Counter

Post by bkweibley »

This is an awesome explaination of things, I really appreciate it. Im trying to figure out exactly where this code goes though? I am not seeing a webparserdump.txt file in the skins folder or any folder inside of the skins folder. Sorry for asking such a rookie question.