It is currently May 2nd, 2024, 11:47 pm

Web Parser Issues

Get help with creating, editing & fixing problems with skins
User avatar
Dice2121
Posts: 10
Joined: August 18th, 2011, 10:48 pm

Web Parser Issues

Post by Dice2121 »

Hey there,

Rainmeter is throwing a hissy fit and I'm not sure how to fix it. I am parsing a Wikipedia page for an image. Namely this one and I'm attempting to download the cover art without any input from the user. I've found the code of the URL of said image, and am able to parse it, but it lacks the "http" in front. Like this:

Code: Select all

<img alt="The Elder Scrolls V Skyrim cover.png" src="//upload.wikimedia.org/wikipedia/en/1/15/The_Elder_Scrolls_V_Skyrim_cover.png" width="250" height="315" />
The src image is the one I'm after, and like I said I'm able to retrieve what's inside the quotes, but Rainmeter can't download it. I'm thinking it's because there's no "http" as I've said.

Any way to fix this? Or is this the "fault" of the Wikipedia developers? It's not their problem, I know, but I'm curious if there's a way around it.
User avatar
Brian
Developer
Posts: 2689
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Web Parser Issues

Post by Brian »

Add http: in front of your child webparser measure Url.
Something like this:URL=http:[ParentMeasure]

-Brian
User avatar
Dice2121
Posts: 10
Joined: August 18th, 2011, 10:48 pm

Re: Web Parser Issues

Post by Dice2121 »

Brian wrote:Add http: in front of your child webparser measure Url.
Something like this:URL=http:[ParentMeasure]

-Brian
You've just made my day. Thanks.
User avatar
Dice2121
Posts: 10
Joined: August 18th, 2011, 10:48 pm

Re: Web Parser Issues

Post by Dice2121 »

This is off topic of the original post, but I didn't want to create another thread for this.

I have the name of a certain game set as a variable. For example:

GameTitle1=The Elder Scrolls V: Skyrim

I want to have a link leading to the official website of any game I have stored as a variable. So to do this I use Google's "I'm Feeling Lucky" search option to search for the game title and pick the first website that comes up which is usually the official website.

The problem is that Rainmeter takes exactly what I wrote without substituting the proper variable name. Like so:

LeftMouseUpAction=http://www.google.com/search?q=#GameTitle1#&btnI

This will send that exact URL without "The Elder Scrolls V: Skyrim" in place of #GameTitle1#.

Any way to work around this?
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Web Parser Issues

Post by jsmorley »

Works for me, as long as one step is taken:

Code: Select all

[Rainmeter]
Update=1000

[Variables]
GameTitle1=GameTitle1=The Elder Scrolls V: Skyrim

[MeterOne]
Meter=Image
SolidColor=255,255,255,255
W=25
H=25
LeftMouseUpAction=http://www.google.com/search?q=#GameTitle1#&btnI
This does not work, as you can't have spaces in a URL. What you have to do is use some online tool like http://www.albionresearch.com/misc/urlencode.php and URLEncode that string to send spaces as %20 (and any other special chars will be encoded as needed as well).

Code: Select all

[Rainmeter]
Update=1000

[Variables]
GameTitle1=The%20Elder%20Scrolls%20V%3A%20Skyrim

[MeterOne]
Meter=Image
SolidColor=255,255,255,255
W=25
H=25
LeftMouseUpAction=http://www.google.com/search?q=#GameTitle1#&btnI
Works just fine for me.
User avatar
Dice2121
Posts: 10
Joined: August 18th, 2011, 10:48 pm

Re: Web Parser Issues

Post by Dice2121 »

Figured out my initial problem. The actual variable in my UserVariables.inc was "Game1Title" as opposed to "GameTitle1" which was in the skin. Simple mistake, but at least it explains why Rainmeter sent #GameTitle1# within the URL.

Anyways, thank you JSMorley for pointing out the issues with spaces and special characters. I might have to use some Substitution within a measure to switch out the characters because I don't see another way to have the process completely automated, which is the primary goal for this skin.

Thanks for the help.

Edit:
I got it working for the most part. The system isn't foolproof as I'm relying on Google to find the official website, which it sometimes does poorly. For example, a Google search of "Fallout: New Vegas" will bring the IGN webpage up first and the official website second. Again, not completely bug free, but that's with everything right?

For the reference of others, here is the code I used:

Code: Select all

[MeasureGame1TitleEncoder]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=file://#ROOTCONFIGPATH#\Shared\UserVariables.inc
RegExp="(?siU).*Game1Title=(.*)Game2Title=(.*)Game3Title=(.*)Game4Title=(.*)Game5Title=(.*)Game6Title=(.*)Game1ImagePath"
UpdateRate=86400
StringIndex=1
Substitute=":":"%3A"," ":"%20","!":"%21",'"':"%22","#":"%23","$":"%24","&":"%26","'":"%27","(":"%28",")":"%29","*":"%2A","+":"%2B",",":"%2C","-":"%2D",".":"%2E","/":"%2F",";":"%3B"

[GameTitle]
Meter=String
X=10
Y=(#CoverArtGap# + 20 + (#CoverArtHeight# * 2))
Text=The Elder Scrolls V: Skyrim
MeterStyle=StyleGameTitleH
LeftMouseUpAction=http://www.google.com/search?q=[MeasureGame1TitleEncoder]&btnI
This code is copy pasted so use it as a reference. It's not an example type code.

In summary, UserVariables.inc contains, among other things, six game titles of which the parser searches for. After finding them it substitutes the characters specified. Finally I use the name of the Measure in the URL to send it to Windows.