It is currently April 13th, 2021, 11:28 am

Help with parsing html

Help with creating, editing & fixing problems with skins
User avatar
Youkai1977
Posts: 138
Joined: October 31st, 2018, 4:11 pm
Location: Germany

Re: Help with parsing html

Post by Youkai1977 »

Oh sorry. :oops:
Yes I had forgotten that I had renamed a measure, but NOT in the OnChangeAction Command-line on the [mRSS]-Measure.
The error is now corrected and nothing shows up in the LOG.

But the time manipulation error is still there. :confused: :???:

Here is the corrected code. It affected ONLY the "newsfeed.ini".
The "newsfeeddata.inc" is not affected by my renamed measure.

1.) newsfeed.ini (Corrected Version)

Code: Select all

[Rainmeter]
Update=20
DefaultUpdateDivider=50
AccurateText=1
DynamicWindowSize=1

[Metadata]
Name=NewsFeed Reader (Marquee)
Author=Youkai1977 
Version=03-21.V1 <> 30.03.2021
Information=This Meter is a Part of M.A.R.S.- 2021 Skin Package
License=Creative Commons Attribution-Non-Commercial-Share Alike 4.0

;==================================================
;=== VARIABLES & STYLES ===========================
;==================================================

[Variables]
@include=newsfeeddata.inc

;==============================================================
;=== VOICE OUTPUT =============================================
;==============================================================
;===                                                         ==
;=== FOR MORE INFO TO SPEECH-PLUGIN                          ==
;=== https://forum.rainmeter.net/viewtopic.php?f=127&t=31161 ==
;===                                                         ==
;==============================================================

[VoiceOutput]
Measure=PLUGIN
Plugin=Speech
Name=#VoiceName#
;Index=#IndexName# 
;Gender=#VoiceGender#
Debug=#DebugModus#
Volume=#VoiceVolume#
Rate=#SpeechRate#
UpdateDivider=-1

;==================================================
;=== MEASURES NEWS FEED & MARQUEE =================
;==================================================

;=== MEASURES NEWS FEED ===========================

[mRSS]
Measure=WEBPARSER
URL=#RSSUrl#
RegExp=(?siU)<lastBuildDate>(.*)</lastBuildDate>.*<description>(.*)</description>#NF1#(?(?=.*<item)#NF2##NF3##NF4##NF5#)
Substitute="&apos;":"'","&quot;":"","&Quot;":"","&amp;":"&","&lt;br&gt;":"","![CDATA[":"","]]":"","...":"","<":"",">":"","/PRE&gt;":"","PRE&gt;":"","&lt;":"","&#39;":"'","&#228;":"ä","&#246;":"ö","&#8211;":"–"
DecodeCharacterReference=3
UpdateRate=1200
StringIndex=1
Debug=1
OnChangeAction=[!EnableMeasureGroup mCHILDS][!UpdateMeasure mNFRUT][!SetOption HEADNAME FontColor "#Color4##Alpha1#"][!UpdateMeter HEADNAME][!ShowMeter HEADNAME][!UpdateMeterGroup FEED][!Redraw]
FinishAction=[!EnableMeasure mLBTSF][!UpdateMeasure mLBTSF][!UpdateMeterGroup FEED][!Redraw][!CommandMeasure VoiceOutput "#NewsUpdSpeech#"][!ShowMeter NewsFeed][!EnableMeasure mXPos][!UpdateMeasure mXPos][!Delay 4000][!SetOption HEADNAME FontColor "#Color3##Alpha1#"][!UpdateMeter HEADNAME][!Redraw]

[mRSSNPN]
Measure=WEBPARSER
URL=[mRSS]
StringIndex=2
Disabled=1
Group=mCHILDS

[mRSSItem1]
Measure=WEBPARSER
URL=[mRSS]
Substitute="&apos;":"'","&quot;":"","&Quot;":"","&amp;":"&","&lt;br&gt;":"","![CDATA[":"","]]":"","...":"","<":"",">":"","/PRE&gt;":"","PRE&gt;":"","&lt;":"","&#39;":"'","&#228;":"ä","&#246;":"ö","&#8211;":"–"
StringIndex=3
Disabled=1
Group=mCHILDS

[mRSSItem2]
Measure=WEBPARSER
URL=[mRSS]
Substitute="&apos;":"'","&quot;":"","&Quot;":"","&amp;":"&","&lt;br&gt;":"","![CDATA[":"","]]":"","...":"","<":"",">":"","/PRE&gt;":"","PRE&gt;":"","&lt;":"","&#39;":"'","&#228;":"ä","&#246;":"ö","&#8211;":"–"
StringIndex=4
Disabled=1
Group=mCHILDS

[mRSSItem3]
Measure=WEBPARSER
URL=[mRSS]
Substitute="&apos;":"'","&quot;":"","&Quot;":"","&amp;":"&","&lt;br&gt;":"","![CDATA[":"","]]":"","...":"","<":"",">":"","/PRE&gt;":"","PRE&gt;":"","&lt;":"","&#39;":"'","&#228;":"ä","&#246;":"ö","&#8211;":"–"
StringIndex=5
Disabled=1
Group=mCHILDS

[mRSSItem4]
Measure=WEBPARSER
URL=[mRSS]
Substitute="&apos;":"'","&quot;":"","&Quot;":"","&amp;":"&","&lt;br&gt;":"","![CDATA[":"","]]":"","...":"","<":"",">":"","/PRE&gt;":"","PRE&gt;":"","&lt;":"","&#39;":"'","&#228;":"ä","&#246;":"ö","&#8211;":"–"
StringIndex=6
Disabled=1
Group=mCHILDS

[mRSSItem5]
Measure=WEBPARSER
URL=[mRSS]
Substitute="&apos;":"'","&quot;":"","&Quot;":"","&amp;":"&","&lt;br&gt;":"","![CDATA[":"","]]":"","...":"","<":"",">":"","/PRE&gt;":"","PRE&gt;":"","&lt;":"","&#39;":"'","&#228;":"ä","&#246;":"ö","&#8211;":"–"
StringIndex=7
Disabled=1
Group=mCHILDS

;=== MEASURE NFR-SKIN-UPDATE TIME STAMP (mNFRUT) ==
;=== MEASURE NFR-SITE-BUILD  TIME STAMP (mLBTSF) ==

[mNFRUT]
Measure=TIME
Format=%d.%m.%Y [\x00B7] %H:%M:%S
TimeStampLocale=#TSL#
FormatLocale=#FL#
UpdateDivider=-1
Disabled=1
Group=mCHILDS

[mLBTSF]
Measure=TIME
Format=%d.%m.%Y [\x00B7] %H:%M:%S
TimeStamp=[mRSS]
TimeStampFormat=%a, %d %b %Y %H:%M:%S GMT
DynamicVariables=1
Disabled=1

;=== MEASURE MARQUEE FUNCTION =====================

[mXPos]
Measure=LOOP
StartValue=#StartPos#
EndValue=-[NewsFeed:W]
Increment=#Direction#
LoopCount=0
DynamicVariables=1
UpdateDivider=1
Disabled=1

;##################################################
;##################################################
;##################################################
;##################################################
;##################################################
;##################################################

;==================================================
;=== LAYER POS. & LAST NFR-UPD LINE ===============
;==================================================

[LAYERxPosText]
Meter=STRING
MeterStyle=StLAYER
X=0
Y=0

[NFRUpdText]
Meter=STRING
MeterStyle=StNFRUPDATE
X=200
Y=r

;==================================================
;=== HEAD NEWS FEED READER (Side Lines) ===========
;==================================================

[HEADLINES]
Meter=SHAPE
X=0
Y=20
Shape=Rectangle 0,0,8,8 | Extend ModifiersS1
Shape2=Line 8,4,26,4 | Extend ModifiersL1
Shape3=Rectangle 26,0,8,8 | Extend ModifiersS1
;-----
Shape4=Rectangle 0,16,8,8 | Extend ModifiersS2
Shape5=Line 8,20,26,20 | Extend ModifiersL2
Shape6=Rectangle 26,16,8,8 | Extend ModifiersS2
;-----
Shape7=Rectangle ([HEADNAME:W] + 48),0,8,8 | Extend ModifiersS1
Shape8=Rectangle ([HEADNAME:W] + 48),0,8,8 | Extend ModifiersS1
Shape9=Rectangle ([HEADNAME:W] + 48),16,8,8 | Extend ModifiersS2
Shape10=Rectangle ([HEADNAME:W] + 48),16,8,8 | Extend ModifiersS2
;-----
Shape11=Rectangle 872,0,8,8 | Extend ModifiersS1
Shape12=Line 854,4,872,4 | Extend ModifiersL1
Shape13=Rectangle 846,0,8,8 | Extend ModifiersS1
;-----
Shape14=Rectangle 872,16,8,8 | Extend ModifiersS2
Shape15=Line 854,20,872,20 | Extend ModifiersL2
Shape16=Rectangle 846,16,8,8 | Extend ModifiersS2
ModifiersS1=StrokeWidth 0 | Fill Color #Color3##Alpha2#
ModifiersL1=StrokeWidth 2 | StrokeColor #Color3##Alpha2#
ModifiersS2=StrokeWidth 0 | Fill Color #Color3##Alpha1#
ModifiersL2=StrokeWidth 2 | StrokeColor #Color3##Alpha1#
DynamicVariables=1
UpdateDivider=-1
Group=FEED

[HEADNAME]
Meter=STRING
MeterStyle=StHEAD
X=41
Y=r
MouseOverAction=[!SetOption HEADNAME FontColor "#Color4##Alpha1#"][!UpdateMeter HEADNAME][!Redraw]
MouseLeaveAction=[!SetOption HEADNAME FontColor "#Color3##Alpha1#"][!UpdateMeter HEADNAME][!Redraw]
LeftMouseUpAction=[#vURL#]

;==================================================
;=== MARQUEE NEWS FEED READER =====================
;==================================================

;=== CONTAINER NEWS FEED ==========================

[CONTAINER_NFR]
Meter=SHAPE
X=0
Y=r
Shape=Line ([HEADNAME:W] + 63),0,839,0 | StrokeWidth 47 | StrokeColor #Color0##Alpha1#
DynamicVariables=1
UpdateDivider=-1
LeftMouseDoubleClickAction=[#vURL#]
Group=FEED

;=== MARQUEE NEWS FEED ============================

[NewsFeed]
Meter=STRING
MeterStyle=StNEWS
X=[mXPos]r
Y=r
User avatar
balala
Rainmeter Sage
Posts: 12546
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with parsing html

Post by balala »

Youkai1977 wrote: April 3rd, 2021, 10:38 am Oh sorry. :oops:
Yes I had forgotten that I had renamed a measure, but NOT in the OnChangeAction Command-line on the [mRSS]-Measure.
The error is now corrected and nothing shows up in the LOG.
But nor in the skin, which still doesn't work, not even with the new code. Please check once again.
User avatar
Youkai1977
Posts: 138
Joined: October 31st, 2018, 4:11 pm
Location: Germany

Re: Help with parsing html

Post by Youkai1977 »

balala wrote: April 3rd, 2021, 11:19 am But nor in the skin, which still doesn't work, not even with the new code. Please check once again.
Okay, curious. :uhuh:
What exactly does not work with the corrected newsfeed.ini or what error is output in the LOG?
With me the feed runs WITHOUT error in the LOG. Only the time manipulation problem is still there
User avatar
balala
Rainmeter Sage
Posts: 12546
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with parsing html

Post by balala »

Youkai1977 wrote: April 3rd, 2021, 12:51 pm Okay, curious. :uhuh:
What exactly does not work with the corrected newsfeed.ini or what error is output in the LOG?
With me the feed runs WITHOUT error in the LOG. Only the time manipulation problem is still there
Please pack the config and upload it. I think would be easiest way to get the working skin.
User avatar
Youkai1977
Posts: 138
Joined: October 31st, 2018, 4:11 pm
Location: Germany

Re: Help with parsing html

Post by Youkai1977 »

balala wrote: April 3rd, 2021, 2:36 pm Please pack the config and upload it. I think would be easiest way to get the working skin.
Ok, here the NewsFeedReader als rmskin-Package. :thumbup:
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 12546
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with parsing html

Post by balala »

Youkai1977 wrote: April 3rd, 2021, 10:10 pm Ok, here the NewsFeedReader als rmskin-Package. :thumbup:
Alright, now got it working.
There are two dates / times, on this format: LAST NFR-UPD: <First-Date-Time> - LAST NFP-BUILD: <Second-Date-Time>.
  • First-Date-Time is the date and time of last update of parent WebParser measure ([mRSS]). It is returned by the [mNFRUT] measure, which has set an UpdateDivider=-1 option. Accordingly it is updated when the [mRSS] measure updates (due to the [!UpdateMeasure mNFRUT] bang of the FinishAction option of the measure).
  • Second-Date-Time is the date and time returned by the [mLBTSF] measure. This measure is using a TimeStamp option to get the formated form of the time returned by the [mRSS] measure, as has been described previously.
So these dates and times can't be the same. The are representing two different information, it's normal they are different. Not sure why are you waiting them to coincide.
User avatar
Youkai1977
Posts: 138
Joined: October 31st, 2018, 4:11 pm
Location: Germany

Re: Help with parsing html

Post by Youkai1977 »

balala wrote: April 4th, 2021, 3:55 pmSo these dates and times can't be the same. The are representing two different information, it's normal they are different. Not sure why are you waiting them to coincide.
Mhh, I think we're talking past each other here.
I do NOT expect the two date/time values to be identical. How could they be, if they come from 2 different measures, which evaluate/format differently.

BUT, that's exactly what it's all about, although these measures as said, actually CANNOT output identical time, especially the measure [mLBTSF] CANNOT, because it should (actually) ONLY format the read time of the [mRSS], it just does NOT, or only the hour. The minutes and seconds are taken from the realtime. See my screenshots from the day before yesterday.

The one measure should give me the timestamp when this happens when updating the [mRSS]. This works also. And the other measure [mLBTSF], should ONLY format the read <lastBuilddate> (Index1) of the [mRSS] measure from (example): Sun, 04 April 2021 19:20:20 GMT to --> 04.04.2021 19:20:20 <---.
And the latter does NOT work. Because here then the minutes and seconds of the real time, for whatever reason, are taken over.
User avatar
balala
Rainmeter Sage
Posts: 12546
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with parsing html

Post by balala »

Youkai1977 wrote: April 4th, 2021, 5:52 pm And the other measure [mLBTSF], should ONLY format the read <lastBuilddate> (Index1) of the [mRSS] measure from (example): Sun, 04 April 2021 19:20:20 GMT to --> 04.04.2021 19:20:20 <---.
And the latter does NOT work. Because here then the minutes and seconds of the real time, for whatever reason, are taken over.
The website, in the <lastBuildDate>(.*)</lastBuildDate> tag is returning the date and time of the load (when have you accessed the content of the site). You can easily see what am I talking about if you load the content of the site into your browser, then try to refresh manually a few times, one after the other, following the date and time contained in the lastBuildDate tag. You can see you get the results with a difference of just a few seconds. So this tag is returning the date of access of the site. This is approximately the local date and time, there might be differences of a few seconds only.
Each article (maybe not the proper term) on the other hand, has a publication date and time. This time can be accessed with the <pubDate>(.*)</pubDate> tag. But have to get one such date and time for each article out there.
User avatar
Youkai1977
Posts: 138
Joined: October 31st, 2018, 4:11 pm
Location: Germany

Re: Help with parsing html

Post by Youkai1977 »

You can easily see what am I talking about if you load the content of the site into your browser, then try to refresh manually a few times...
ARRRRGGGHHH ...oh man, right, now I see it too. O.O O.O O.O :o :o :o
Man ne, I thought the <lastBuildDate> was the timestamp where Google News was updated altogether. I noticed that when you are on the website, about every 20-30 minutes (haven't checked exactly yet) a message appears at the bottom left of the Screen that there is an updated version and if you want to update.
Therefore, as I said, the assumption that this is the <lastBuildDate>.
But now that you have found out that this is only the timestamp when I or the [mRSS] Measure has accessed the page, this is for me all ad absurdum.
And now for each feed to take the <PupDate> I find exaggerated ... or in other words, this is like shooting with cannons on sparrows.

So the whole snot now flies out of the NewsFeed reader (what has to do with the <lastBuildDate>) and I leave it at the update display, when the NewsFeed skin has updated. I need this among other things, because we are still trying out this update rate for the [mRSS] measure.

Then still something to my COLOR PROBLEM (InlineSettings).
I found out that if special characters occur in the feed, I then have this color play. So a feed is COLORFUL (multicolored), or in WHITE instead of e.g. blue.

If a feed has e.g. the character | in it, the coloring breaks off at that point, and AFTER the | character the feed has a different color.
If the feed contains the characters +++ three times in a row, the feed is COLORFUL.

So your solution from the other day to put a (?iu) in front of my [mRSSItem] seems either NOT to be enough, or not quite the correct way to do it.
User avatar
balala
Rainmeter Sage
Posts: 12546
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with parsing html

Post by balala »

Youkai1977 wrote: April 5th, 2021, 8:35 am ARRRRGGGHHH ...oh man, right, now I see it too. O.O O.O O.O :o :o :o
Man ne, I thought the <lastBuildDate> was the timestamp where Google News was updated altogether. I noticed that when you are on the website, about every 20-30 minutes (haven't checked exactly yet) a message appears at the bottom left of the Screen that there is an updated version and if you want to update.
Therefore, as I said, the assumption that this is the <lastBuildDate>.
But now that you have found out that this is only the timestamp when I or the [mRSS] Measure has accessed the page, this is for me all ad absurdum.
Yeah, indeed makes not too much sense, but that's it.
Youkai1977 wrote: April 5th, 2021, 8:35 am And now for each feed to take the <PupDate> I find exaggerated ... or in other words, this is like shooting with cannons on sparrows.
No, it's not a big deal at all. It can be done extremely easily. Here is an example:
  • Replace the NF1 - NF5 variables into the [Variables] section of the newsfeeddata.inc file with the following ones:

    Code: Select all

    [Variables]
    ...
    NF1=.*<item.*<title.*>(.*)</title>.*<pubDate>(.*)</pubDate>
    NF2=.*<title.*>(.*)</title>.*<pubDate>(.*)</pubDate>
    NF3=.*<title.*>(.*)</title>.*<pubDate>(.*)</pubDate>
    NF4=.*<title.*>(.*)</title>.*<pubDate>(.*)</pubDate>
    NF5=.*<title.*>(.*)</title>.*<pubDate>(.*)</pubDate>
    Just note here that I'd not use five variables, because NF2, NF3, NF4 and NF5 are the same, there is no difference between them.
  • Modify the StringIndex values of the child WebParser measures in the newsfeed.ini file as it follows:

    Code: Select all

    [mRSSItem1]
    ...
    StringIndex=3
    ...
    
    [mRSSItem2]
    ...
    StringIndex=5
    ...
    
    [mRSSItem3]
    ...
    StringIndex=7
    ...
    
    [mRSSItem4]
    ...
    StringIndex=9
    ...
    
    [mRSSItem5]
    ...
    StringIndex=11
    ...
  • Finally add a few other measures to get the dates:

    Code: Select all

    [mRSSDate1]
    Measure=WEBPARSER
    URL=[mRSS]
    StringIndex=4
    Disabled=1
    Group=mCHILDS
    
    [mRSSDate2]
    Measure=WEBPARSER
    URL=[mRSS]
    StringIndex=6
    Disabled=1
    Group=mCHILDS
    
    [mRSSDate3]
    Measure=WEBPARSER
    URL=[mRSS]
    StringIndex=8
    Disabled=1
    Group=mCHILDS
    
    [mRSSDate4]
    Measure=WEBPARSER
    URL=[mRSS]
    StringIndex=10
    Disabled=1
    Group=mCHILDS
    
    [mRSSDate5]
    Measure=WEBPARSER
    URL=[mRSS]
    StringIndex=12
    Disabled=1
    Group=mCHILDS
  • Additional Time measures might be needed, to get the appropriate format for dates / times. Don't post the for now, hope you can add them if you want.
Now you have to use the acquired dates somehow, to add them to string meters or whatever. I leave this for you, add them where you like them.
Youkai1977 wrote: April 5th, 2021, 8:35 am Then still something to my COLOR PROBLEM (InlineSettings).
I found out that if special characters occur in the feed, I then have this color play. So a feed is COLORFUL (multicolored), or in WHITE instead of e.g. blue.

If a feed has e.g. the character | in it, the coloring breaks off at that point, and AFTER the | character the feed has a different color.
If the feed contains the characters +++ three times in a row, the feed is COLORFUL.

So your solution from the other day to put a (?iu) in front of my [mRSSItem] seems either NOT to be enough, or not quite the correct way to do it.
No, I don't get this. The only different colored character is the | itself. See my screenshot (click it to enlarge):
NewsFeed.png
Another comment related to the code: I definitely would move the included newsfeeddata.inc file into the @Resources folder (which doesn't yet exist but can easilly be created). This folder has been added exactly to store such resources, included files and so on.
You do not have the required permissions to view the files attached to this post.