It is currently April 26th, 2024, 4:10 am

Code Concept Question

General topics related to Rainmeter.
User avatar
UnstoppableDave
Posts: 30
Joined: May 22nd, 2010, 6:51 pm

Code Concept Question

Post by UnstoppableDave »

Hey guys,
I need a little help here, my brain is about to explode trying to think about this... :(
I'm wanting to make a new skin, similar to my Steam headlines skin, only with the Steam Specials instead.
The problem is that sometimes there aren't very many sales going on, like right now, just three.
This means that a simple linear parser will not work, since if I put in a single parser for say, 12 items, and there's only html for three, it will break the parser.

The only way I can think to get around this is to write 12 (or whatever) different parser measures, and deactivate them all except one depending on how many items there are, which is stated on the page. In case it helps, here's the url I'm referring to:
http://store.steampowered.com/search/?specials=1

Is there a much easier way of doing this that I am missing?

Thanks,
Image
User avatar
JpsCrazy
Posts: 667
Joined: April 18th, 2010, 2:16 pm
Location: NY, USA

Re: Code Concept Question

Post by JpsCrazy »

http://rainmeter.net/cms/Tips-GoogleReaderRSS
Tips and Tricks wrote: -The link to 8 items (if they exist -- the RegExp won't fail if less than 8 items are available)
User avatar
UnstoppableDave
Posts: 30
Joined: May 22nd, 2010, 6:51 pm

Re: Code Concept Question

Post by UnstoppableDave »

Hm... ok. I thought I tried it and it broke. I'll try some more.
Image
User avatar
JpsCrazy
Posts: 667
Joined: April 18th, 2010, 2:16 pm
Location: NY, USA

Re: Code Concept Question

Post by JpsCrazy »

It breaks unless you're using the google reader trick
User avatar
UnstoppableDave
Posts: 30
Joined: May 22nd, 2010, 6:51 pm

Re: Code Concept Question

Post by UnstoppableDave »

I don't think the Google Reader trick is going to work for this. The number of current sales is always changing. And I only want to display the current sales, not the last 12 sales in history. I did find an RSS feed, but the parser like you said breaks because I don't match the number exactly in the parser.
Would there be a way to fetch the number of current sales from the steam site and then dynamically change the parser or something to show only that many from the Google Reader feed?
Image
User avatar
JpsCrazy
Posts: 667
Joined: April 18th, 2010, 2:16 pm
Location: NY, USA

Re: Code Concept Question

Post by JpsCrazy »

Possibly.
If there is you'd almost certainly have to use !RainmeterWriteKeyValue to change the number of times you run the same sections of your RegExp
User avatar
jsmorley
Developer
Posts: 22630
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Code Concept Question

Post by jsmorley »

Why are we not just pointing this guy to "look ahead assertions" in Regular Expressions? What am I missing?

http://www.regular-expressions.info/lookaround.html
User avatar
JpsCrazy
Posts: 667
Joined: April 18th, 2010, 2:16 pm
Location: NY, USA

Re: Code Concept Question

Post by JpsCrazy »

Because reg exp and analog clocks are my weakpoints. ><
Never read anything about look aheads in here that helped.
poiru
Developer
Posts: 2872
Joined: April 17th, 2009, 12:18 pm

Re: Code Concept Question

Post by poiru »

jsmorley wrote:Why are we not just pointing this guy to "look ahead assertions" in Regular Expressions? What am I missing?

http://www.regular-expressions.info/lookaround.html
In case you're lazy:
(?(?=.*<item>)<item>(.*)</item>)

Which means if <item> exists, apply <item>(.*)</item>. Repeat that 12 times (or however many you want). For example:

RegExp="(?siU)(?(?=.*<item>)<item>(.*)</item>)(?(?=.*<item>)<item>(.*)</item>)(?(?=.*<item>)<item>(.*)</item>)(?(?=.*<item>)<item>(.*)</item>)"

And you also get multiple index for one if:
(?(?=.*<item>)<item>(.*)</item>.*<otheritem>(.*)</otheritem>)
User avatar
jsmorley
Developer
Posts: 22630
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Code Concept Question

Post by jsmorley »

JpsCrazy wrote:Because reg exp and analog clocks are my weakpoints. ><
Never read anything about look aheads in here that helped.
Analog clocks are a mystery to me too.. ;-) I just steal from an existing one and hope for the best.