It is currently March 28th, 2024, 11:16 am

Toggling WebParser Contents

Get help with creating, editing & fixing problems with skins
Post Reply
User avatar
Seahorse
Posts: 1175
Joined: June 9th, 2010, 5:56 pm
Location: Locks heath, UK
Contact:

Toggling WebParser Contents

Post by Seahorse »

I am tinkering with an Instagram skin, I am parsing a feed for 8 items in a StringIndex perfectly happily and the quick & dirty test skin works but clearly needs some tweaking (later):
Capture.PNG
What I want to do is toggle through the first 5 images (5 x 8=40) in a slideshow fashion. The current approach would mean the parse would pull 40 items including images, I could then use a timer to toggle the next image (and 8 items) which seems simple enough.

Thinking about it this seems a clunky way of doing it, particularly maintaining a large webparse and the number of !bangs it would involve.

What I am after is a more efficient approach which is where I would appreciate some input :thumbup:
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Toggling WebParser Contents

Post by jsmorley »

This is going to be something that is relatively easy in Lua, you will only need 1 WebParser measure and 5 meters.

It would be easier if you can post at least the URL and RegExp you are using to get the 40 captures though, so I don't have to re-invent the wheel.
User avatar
KreAch3R
Posts: 608
Joined: February 7th, 2011, 7:27 pm
Location: Thessaloniki, GR

Re: Toggling WebParser Contents

Post by KreAch3R »

Take a look also in my GoogleReaderTiny.lua script (inlcuded in Edge), it includes cycling over feed items. Or let jsmorley do it. :p ;-)
User avatar
Seahorse
Posts: 1175
Joined: June 9th, 2010, 5:56 pm
Location: Locks heath, UK
Contact:

Re: Toggling WebParser Contents

Post by Seahorse »

kreacher - I'll take a look thanks.

JSM - skin code, weparse & URL. It's still a bit scruffy as I am fiddling with it... :sly:

Current code:

Code: Select all

[Rainmeter]
Author=Seahorse (AKA Osric Wuscfrea) mr.seahorse@gmail.com
Update=1000
BackgroundMode=2
SolidColor=0,0,0,1
Blur=1
BlurRegion=2,0,0,210,285,25

[Metadata]
Name=Cobalt Rainstagram
Version=1.0.2
License=Creative Commons BY-NC-SA 3.0
Information=Description: Slideshow webstagram from your PC. | Instructions: See comments in the skin .ini between the ********** sections.  If you want to alter the refresh interval edit "UpdateDivider=15" (SECONDS) IN [Random].  15=15 Seconds, so 30 Minutes=60*30=1800 e.g."UpdateDivider=1800". | Credits: Nil.

;1.0 - Release

;===============================================================================================
;Variables
;===============================================================================================

[Variables]

;Fonts & Colours
@include="#SKINSPATH#Cobolt\Settings.inc"

URLPop=http://widget.stagram.com/rss/popular/
URLPotD=http://widget.stagram.com/rss/n/photooftheday

;===============================================================================================
;Measures
;===============================================================================================

;(?siU).*</dc:date>.* <title>(.*)</title>.*<link>(.*)</link>.*<a href="(.*)"><img src="(.*)".*@(.*)</a>.*<img src="(.*)" .*color:red;">(.*)</span>.*COMMENTS:">(.*)</p>.*<author>Webstagram</author>.* <title>(.*)</title>.*<link>(.*)</link>.*<a href="(.*)"><img src="(.*)".*@(.*)</a>.*<img src="(.*)" .*color:red;">(.*)</span>.*COMMENTS:">(.*)</p>.*
;<author>Webstagram</author>break for duplicates

[MeasureWebstagram]
Measure=Plugin
Plugin=WebParser
UpdateRate=1800
Url=#URLPop#
RegExp="(?siU).*</dc:date>.* <title>(.*)</title>.*<link>(.*)</link>.*<a href="(.*)"><img src="(.*)".*@(.*)</a>.*<img src="(.*)" .*color:red;">(.*)</span>.*COMMENTS:">(.*)</p>"

[MeasureTitle]
Measure=Plugin
Plugin=WebParser
Url=[MeasureWebstagram]
StringIndex=1
Substitute="'":"'"

[MeasureLinktoBig]
Measure=Plugin
Plugin=WebParser
Url=[MeasureWebstagram]
StringIndex=2
;use for URL click through, not for display

[MeasureLinktoUserPage]
Measure=Plugin
Plugin=WebParser
Url=[MeasureWebstagram]
StringIndex=3
;use for URL click through, not for display

[MeasureProfilePic]
Measure=Plugin
Plugin=WebParser
Url=[MeasureWebstagram]
StringIndex=4
Download=1

[MeasureUserName]
Measure=Plugin
Plugin=WebParser
Url=[MeasureWebstagram]
StringIndex=5

[MeasureImage]
Measure=Plugin
Plugin=WebParser
Url=[MeasureWebstagram]
StringIndex=6
Download=1

[MeasureLikes]
Measure=Plugin
Plugin=WebParser
Url=[MeasureWebstagram]
StringIndex=7

[MeasureComments]
Measure=Plugin
Plugin=WebParser
Url=[MeasureWebstagram]
StringIndex=8


;===============================================================================================
;Meters
;===============================================================================================

[MeterProfilePic]
Meter=IMAGE
MeasureName=MeasureProfilePic
X=10
Y=10
H=30
W=30
LeftMouseUpAction=["[MeasureLinktoUserPage]"]

[MeterUserName]
Meter=String
MeasureName=MeasureUsername
X=R
Y=10
H=16
W=160
MeterStyle=StringStyleNoClip
StringStyle=Bold
FontColor=#Colour2#
FontSize=13
LeftMouseUpAction=["[MeasureLinktoUserPage]"]

[MeterLikesImage]
Meter=Image
ImageName=#@#Images\Likes.png
X=2r
Y=R

[MeterLikes]
Meter=String
MeasureName=MeasureLikes
X=R
Y=r
MeterStyle=StringStyleNoClip

[MeterCommentsImage]
Meter=Image
ImageName=#@#Images\Comments.png
X=5R
Y=r

[MeterComments]
Meter=String
MeasureName=MeasureComments
X=R
Y=r
MeterStyle=StringStyleNoClip

[MeterTitle]
Meter=String
MeasureName=MeasureTitle
X=10
Y=R
H=40
W=170
MeterStyle=StringStyle
text=%1
LeftMouseUpAction=["[MeasureLinktoBig]"]

[MetereImage]
Meter=IMAGE
MeasureName=MeasureImage
X=10
Y=R
H=190
W=190

;-----------------------------------------------------------------------------------------------
;Graphics - Additionally forces the aero blur borders to correct position.
;-----------------------------------------------------------------------------------------------

[MeterGlossTop]
Meter=Image
X=0
Y=0
W=215
H=40
ImageName=#@#Images\GlossTop.png

[MeterGlossBottom]
Meter=Image
X=0
Y=260
W=210
H=25
ImageName=#@#Images\GlossBottom.png
The Regexp for forty:

Code: Select all

(?siU).*</dc:date>.* <title>(.*)</title>.*<link>(.*)</link>.*<a href="(.*)"><img src="(.*)".*@(.*)</a>.*<img src="(.*)" .*color:red;">(.*)</span>.*COMMENTS:">(.*)</p>.*<author>Webstagram</author>.* <title>(.*)</title>.*<link>(.*)</link>.*<a href="(.*)"><img src="(.*)".*@(.*)</a>.*<img src="(.*)" .*color:red;">(.*)</span>.*COMMENTS:">(.*)</p>.*<author>Webstagram</author>.* <title>(.*)</title>.*<link>(.*)</link>.*<a href="(.*)"><img src="(.*)".*@(.*)</a>.*<img src="(.*)" .*color:red;">(.*)</span>.*COMMENTS:">(.*)</p>.*<author>Webstagram</author>.* <title>(.*)</title>.*<link>(.*)</link>.*<a href="(.*)"><img src="(.*)".*@(.*)</a>.*<img src="(.*)" .*color:red;">(.*)</span>.*COMMENTS:">(.*)</p>.*<author>Webstagram</author>.* <title>(.*)</title>.*<link>(.*)</link>.*<a href="(.*)"><img src="(.*)".*@(.*)</a>.*<img src="(.*)" .*color:red;">(.*)</span>.*COMMENTS:">(.*)</p>.*
Essentially this is the second set of 8 duplicated:
<author>Webstagram</author>.* <title>(.*)</title>.*<link>(.*)</link>.*<a href="(.*)"><img src="(.*)".*@(.*)</a>.*<img src="(.*)" .*color:red;">(.*)</span>.*COMMENTS:">(.*)</p>.*
URL= http://widget.stagram.com/rss/popular/
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Toggling WebParser Contents

Post by jsmorley »

Ok, give me a little while to work up an approach in Lua for this. Check back in a half hour or so.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Toggling WebParser Contents

Post by jsmorley »

To be sure I get this, you want to have a slideshow that toggles between 5 items from the site on some timed basis, and what you are trying to avoid is having to create 40 child measures (in order to get the 8 data elements for each item) and keep the number of meters to a minimum?

You are going to display 1 "item" at a time... Right?
User avatar
Seahorse
Posts: 1175
Joined: June 9th, 2010, 5:56 pm
Location: Locks heath, UK
Contact:

Re: Toggling WebParser Contents

Post by Seahorse »

This is a slideshow for the current 5 popular images, the feed has like 15 or so. Each image has Child 8 measures which I gave descriptive names.

Whilst I can write 40 and do 8 !bangs every minute let's say, it seems a long winded approach that would be hard to maintain/debug.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Toggling WebParser Contents

Post by jsmorley »

Seahorse wrote:This is a slideshow for the current 5 popular images, the feed has like 15 or so. Each image has Child 8 measures which I gave descriptive names.

Whilst I can write 40 and do 8 !bangs every minute let's say, it seems a long winded approach that would be hard to maintain/debug.
I think you are going to be stuck with 41 WebParser measures no matter what. This site can't really be fully parsed in Lua, as it is returning Chinese or Korean or Japanese character sets in the results for "title", and Lua won't support parsing out strings that contain 2-byte unicode characters. So you will need the main WebParser and the 40 child measures. What we can do however is to use Lua to reduce the meters to just 8 or whatever is needed to display one "item", and have a counter to slideshow them using the single set of meters by having Lua read the appropriate child measures and just set !SetOption bangs to the meters.

Does that sound like something you want to tackle?
User avatar
Seahorse
Posts: 1175
Joined: June 9th, 2010, 5:56 pm
Location: Locks heath, UK
Contact:

Re: Toggling WebParser Contents

Post by Seahorse »

Was intending to use a counter to trigger 8 bangs using 8 meters only, as lua still makes my head spin and lua doesn't simplify it, I'll continue with the existing approach, thanks for the assistance... :welcome:
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Toggling WebParser Contents

Post by jsmorley »

Seahorse wrote:Was intending to use a counter to trigger 8 bangs using 8 meters only, as lua still makes my head spin and lua doesn't simplify it, I'll continue with the existing approach, thanks for the assistance... :welcome:
That's fine. It's not a terribly complicated Lua script, just 7 or 8 lines really, but since we need to do all the measures in Rainmeter anyway to avoid the 2-byte character unicode issue, it might be just as easy to do the meters in Rainmeter as well with a counter and some !SetOption bangs.

Good luck.
Post Reply