It is currently May 4th, 2024, 9:24 am

Looking for a RegEx script to get the latest Mega Millions Result

Get help with creating, editing & fixing problems with skins
User avatar
CoffeeJoe
Posts: 48
Joined: November 6th, 2019, 4:19 am

Looking for a RegEx script to get the latest Mega Millions Result

Post by CoffeeJoe »

Anyone who can speak RegEx: I'd like a measure that can get the latest Mega Millions result and the draw date from the reputable source of your choice. - Please

I have tried to do RegEx captures and I'm crap at it.

I'd like it if I could optionally get some historical results as well but that's not really a big deal overall.

Thanks in advance
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: Looking for a RegEx script to get the latest Mega Millions Result

Post by death.crafter »

Yincognito, knock! knock!

P.S. at first I thought he was asking to store a million matches parsed using regex. :rolmfao:
from the Realm of Death
User avatar
CoffeeJoe
Posts: 48
Joined: November 6th, 2019, 4:19 am

Re: Looking for a RegEx script to get the latest Mega Millions Result

Post by CoffeeJoe »

Only if it shows which one is the winner (before the drawing) :thumbup:
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: Looking for a RegEx script to get the latest Mega Millions Result

Post by death.crafter »

CoffeeJoe wrote: August 18th, 2021, 4:57 pm Only if it shows which one is the winner (before the drawing) :thumbup:
API Documentation(get an api key to not get temporarily blocked):
https://dev.socrata.com/foundry/data.ny.gov/5xaw-6ayf

API format:
https://data.ny.gov/resource/5xaw-6ayf.json?draw_date=2005-07-12T00:00:00.000

Code: Select all

[Date]
Measure=Time
Format=%Y-%m-%d

[Regex]
Measure=WebParser
URL=https://data.ny.gov/resource/5xaw-6ayf.json?draw_date=[Date]T00:00:00.000
RegExp=.*"winning_numbers":"(.*)".*,.*"mega_ball":"(.*)".*
UpdateRate=(3600*12)

[WinningNumbers]
Measure=WebParser
URL=[Regex]
StringIndex=1

[MegaBall]
Measure=WebParser
URL=[Regex]
StringIndex=2
from the Realm of Death
User avatar
CoffeeJoe
Posts: 48
Joined: November 6th, 2019, 4:19 am

Re: Looking for a RegEx script to get the latest Mega Millions Result

Post by CoffeeJoe »

I can't get this to work - I did mention that I'm crap at regex
I haven't seen any variation of this expression actually return any data

This is what I have after much testing / tweaking / and mucking about... (date measure works, url works)

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1

[Variables]

[MegaMill]
Meter=String
X=200
Y=22
W=400
H=40
;MeasureName=Date
MeasureName=DrawDate
;MeasureName=WinningNumbers
;MeasureName=MegaBall
;MeasureName=Multiplier
SolidColor=202020DF
FontSize=18
StringAlign=CenterCenter
FontColor=DFDFDFFF
AntiAlias=1
DynamicVariables=1
Text=%1

[Date]
Measure=Time
Format=%Y-%m-%d
DynamicVariables=1

[Regex]
Measure=WebParser
URL=https://data.ny.gov/resource/5xaw-6ayf.json?draw_date=2021-08-17T00:00:00.000
RegExp=.*draw_date:"(.*)",.*"winning_numbers":"(.*)".*,.*"mega_ball":"(.*)".*,.*multiplier:"(.*)".*
UpdateRate=(3600*12)

[DrawDate]
Measure=WebParser
URL=[Regex]
StringIndex=1
DynamicVariables=1

[WinningNumbers]
Measure=WebParser
URL=[Regex]
StringIndex=2
DynamicVariables=1

[MegaBall]
Measure=WebParser
URL=[Regex]
StringIndex=3
DynamicVariables=1

[Multiplier]
Measure=WebParser
URL=[Regex]
StringIndex=4
DynamicVariables=1

User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: Looking for a RegEx script to get the latest Mega Millions Result

Post by death.crafter »

CoffeeJoe wrote: August 19th, 2021, 5:02 am

Code: Select all

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

[Metadata]
Name=
Author=
Information=
Version=
License=Creative Commons Attribution - Non - Commercial - Share Alike 3.0

[Variables]
DrawDate=2021-08-17

[Regex]
Measure=WebParser
URL=https://data.ny.gov/resource/5xaw-6ayf.json?draw_date=#DrawDate#T00:00:00.000
RegExp=.*"draw_date":"(.*)".*"winning_numbers":"(.*)".*,.*"mega_ball":"(.*)".*"multiplier":"(.*)"
UpdateRate=3600

[DrawDate]
Measure=WebParser
URL=[Regex]
StringIndex=1

[WinningNumbers]
Measure=WebParser
URL=[Regex]
StringIndex=2

[MegaBall]
Measure=WebParser
URL=[Regex]
StringIndex=3

[Multiplier]
Measure=WebParser
URL=[Regex]
StringIndex=4

[MegaMill]
Meter=String
MeasureName=DrawDate
MeasureName2=WinningNumbers
MeasureName3=MegaBall
MeasureName4=Multiplier
SolidColor=202020DF
FontSize=18
StringAlign=
FontColor=DFDFDFFF
AntiAlias=1
DynamicVariables=1
Text=Draw Date: "%1"#CRLF#Winning Numbers: "%2"#CRLF#MegaBall: "%3"#CRLF#Multiplier: "%4"
Works fine for me.

Edit:
Ohh I see it now. You forgot to put double quotes("") around draw_date.
from the Realm of Death
User avatar
Yincognito
Rainmeter Sage
Posts: 7198
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Looking for a RegEx script to get the latest Mega Millions Result

Post by Yincognito »

death.crafter wrote: August 18th, 2021, 4:48 pm Yincognito, knock! knock!

P.S. at first I thought he was asking to store a million matches parsed using regex. :rolmfao:
Ouch, missed this one, sorry 'bout that... :oops: Took a little break from checking things here. I suppose the issue is solved by now, isn't it? :sly:
If so, thanks, death.crafter, for managing the regexes like a boss while I was hiding myself from the outside world, LMAO.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: Looking for a RegEx script to get the latest Mega Millions Result

Post by death.crafter »

Yincognito wrote: August 19th, 2021, 5:59 pm Ouch, missed this one, sorry 'bout that... :oops: Took a little break from checking things here. I suppose the issue is solved by now, isn't it? :sly:
If so, thanks, death.crafter, for managing the regexes like a boss while I was hiding myself from the outside world, LMAO.
Lol, except .s and *s I am a pro noob in regex. Tho I take credit for "Googling" out the website. :rolmfao:
from the Realm of Death
User avatar
Yincognito
Rainmeter Sage
Posts: 7198
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Looking for a RegEx script to get the latest Mega Millions Result

Post by Yincognito »

death.crafter wrote: August 19th, 2021, 6:01 pm Lol, except .s and *s I am a pro noob in regex. Tho I take credit for "Googling" out the website. :rolmfao:
I use RegExr.com to build or verify stuff - I like that it looks simpler than regex101.com, and it was invaluable in my regex experiences. It's a lot like Rainmeter's docs, with the left sidebar for strict to the point, no nonsense, help (i.e. RegEx Reference) and the large and comfortable "Expression" and "Text" area in the middle, plus the "Replace" and "List" buttons at bottom right. Can't apply multiple substitutions like in Rainmeter, but I copy paste results as "texts" to other similarly pinned tabs to replicate that. 8-)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
CoffeeJoe
Posts: 48
Joined: November 6th, 2019, 4:19 am

Re: Looking for a RegEx script to get the latest Mega Millions Result

Post by CoffeeJoe »

Yes - it turned out pretty well, thanks for the Regex assist.
Thx also for the RegExr.com reference. I might actually get the hang of PCRE

Code: Select all

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

[Variables]
DrawDate=2021-08-17

[Regex]
Measure=WebParser
URL=https://data.ny.gov/resource/5xaw-6ayf.json?draw_date=2021-08-17
RegExp=.*"draw_date":"(.*)".*"winning_numbers":"(.*)".*"mega_ball":"(.*)".*"multiplier":"(.*)".*
UpdateRate=(3600*12)

[DrawDate]
Measure=WebParser
URL=[Regex]
StringIndex=1
RegExpSubstitute=1
Substitute="T00:00:00.000":""

[WinningNumbers]
Measure=WebParser
URL=[Regex]
StringIndex=2

[MegaBall]
Measure=WebParser
URL=[Regex]
StringIndex=3

[Multiplier]
Measure=WebParser
URL=[Regex]
StringIndex=4

[MegaMill]
Meter=String
MeasureName=DrawDate
MeasureName2=WinningNumbers
MeasureName3=MegaBall
MeasureName4=Multiplier
SolidColor=202020DF
FontSize=18
Padding=15,8,15,8
FontColor=DFDFDFFF
AntiAlias=1
DynamicVariables=1
InlineSetting=Color | DFDF00FF
InlineSetting2=Weight | 600
InlineSetting3=Size | 24
InlinePattern=" \d\d\n"
InlinePattern2=" \d\d\n"
InlinePattern3="\d\d \d\d \d\d \d\d \d\d \d\d\n"
Text=%1#CRLF#%2 %3#CRLF#Megaplier x%4