It is currently March 29th, 2024, 12:28 pm

Parsing Avatar image from a YT channel?

Get help with creating, editing & fixing problems with skins
User avatar
StArL0rd84
Posts: 424
Joined: February 8th, 2015, 10:07 pm
Location: EU, Denmark.

Parsing Avatar image from a YT channel?

Post by StArL0rd84 »

REALLY gotten into parsing lately, quite addictive ;P
And i am making a YoutubeRSS skin which shows the latest uploads from a channel.
Yeah, Youtube has RSS!

Not finished skin:
YTRSS_1.0.rmskin
nrw2.png
The feed has everything listed that i need, EXCEPT the avatar for the channel. :-(
https://www.youtube.com/feeds/videos.xml?channel_id=UCD-4g5w1h8xQpLaNS_ghU4g

Right now i am just parsing the image url i got from right-clicking on the avatar and selecting 'Copy image address'
This is not optimal!

I had to do it that way because iv'e had no luck just straight parsing the image address from the channel.
Please take a look and see if it would even be possible to straight parse it from the channel.
Im getting better at parsing by the min.
But i figured ill try and ask some of you guys with a lot more experience.

Inspecting channel HTML in Google Chrome:
yt.png
HTML Code:

Code: Select all

<img id="img" class="style-scope yt-img-shadow" width="80" src="https://yt3.ggpht.com/-Xu7S2jroemo/AAAAAAAAAAI/AAAAAAAAAAA/rgrIxGlIIWQ/s288-c-k-no-mo-rj-c0xffffff/photo.jpg">
Code to parse the channel not working:

Code: Select all

[mAvatar]
 Measure=Plugin
 Plugin=Plugins\WebParser.dll
 URL=https://www.youtube.com/channel/UCD-4g5w1h8xQpLaNS_ghU4g
 RegExp=(?siU)src="(.*)">
 UpdateRate=1800
 UpdateDivider=-1
 StringIndex=1
 Download=1
 DownloadFile="Avatar.jpg"
You do not have the required permissions to view the files attached to this post.
Last edited by StArL0rd84 on July 11th, 2017, 5:43 pm, edited 2 times in total.
([mWorkTime] = 1 ? #Work# : ([mEnergyLoss:%] >= 70% ? #Chillmode# : </>))
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Parsing Avatar image from a YT channel?

Post by jsmorley »

I'm not finding the regular expression you are using when I visit that site in my browser. I did get this to work however:

Code: Select all

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

[mAvatar]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=https://www.youtube.com/channel/UCD-4g5w1h8xQpLaNS_ghU4g
RegExp=(?siU)<meta property="og:image" content="(.*)"
UpdateRate=1800
StringIndex=1
Download=1
DownloadFile="Avatar.jpg"

[MeterImage]
Meter=Image
W=200
PreserveAspectRatio=1
MeasureName=mAvatar
1.png
You do not have the required permissions to view the files attached to this post.
User avatar
StArL0rd84
Posts: 424
Joined: February 8th, 2015, 10:07 pm
Location: EU, Denmark.

Re: Parsing Avatar image from a YT channel?

Post by StArL0rd84 »

Wow tnx! That works.
With this working i only have to ask the user of the skin for the channel id to make it work.
Where and how did you find the RegExp?
Did you use chrome?

Looked again and couldn't find:
<meta property="og:image" content="
([mWorkTime] = 1 ? #Work# : ([mEnergyLoss:%] >= 70% ? #Chillmode# : </>))
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Parsing Avatar image from a YT channel?

Post by jsmorley »

StArL0rd84 wrote:Wow tnx! That works.
With this working i only have to ask the user of the skin for the channel id to make it work.
Where and how did you find the RegExp?
Did you use chrome?

Looked again and couldn't find:
<meta property="og:image" content="
Yes, I used Google Chrome. the safest bet, to be sure that a site is not tailoring the output to the detected browser or your detected location, is to add:

Debug=2

On the parent WebParser measure. That will cause the measure to download the entire output HTML from the site to a file called WebParserDump.txt in the same folder as the skin.

You can then load that in a text editor to check for what you want to use as the RegExp option, and you can be certain that what you are using is actually what WebParser will get from that site.

Then just remove that Debug=2 line from the skin once you have things working.
User avatar
StArL0rd84
Posts: 424
Joined: February 8th, 2015, 10:07 pm
Location: EU, Denmark.

Re: Parsing Avatar image from a YT channel?

Post by StArL0rd84 »

jsmorley wrote:Yes, I used Google Chrome. the safest bet, to be sure that a site is not tailoring the output to the detected browser is to add:

Debug=2

On the parent WebParser measure. That will cause the measure to download the entire site to a file called WebParserDump.txt in the same folder as the skin.

You can then load that in a text editor to check for what you want to use as the RegExp option, and you can be certain that what you are using is actually what WebParser will get from that site.

Then just remove that Debug=2 line from the skin once you have things working.
Awesome, Thanks i'll remember this!
([mWorkTime] = 1 ? #Work# : ([mEnergyLoss:%] >= 70% ? #Chillmode# : </>))