It is currently April 24th, 2024, 6:12 am

Why WebParser Download Stops Working?

Get help with creating, editing & fixing problems with skins
User avatar
GTI.H
Posts: 75
Joined: December 15th, 2018, 3:35 am

Why WebParser Download Stops Working?

Post by GTI.H »

Hi,

This my WebParser worked for years and then suddenly stopped. I noticed difference in the URL from http:// to https://, I have corrected and not resolved. The image is not downloaded.

It works for other URLs but not for this.

[MSMoonPic]
Measure=Plugin
Plugin=WebParser
UpdateRate=#UpdateMoon#
; Url="https://static.die.net/moon/512.jpg"
Url="https://static.die.net/moon/800.jpg"
; 512 -> Image size
Download=1
DownloadFile="Moon.jpg"

Anyone know what happened and how to solve it?
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Why WebParser Download Stops Working?

Post by jsmorley »

Not sure. They may have built-in a browser check to prevent this kind of automatic downloading from the site.
User avatar
GTI.H
Posts: 75
Joined: December 15th, 2018, 3:35 am

Re: Why WebParser Download Stops Working?

Post by GTI.H »

Is there any chance of getting our beautiful picture?
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Why WebParser Download Stops Working?

Post by jsmorley »

I think you are going to have to use Powershell, with a script something like this:

Code: Select all

$url = "https://static.die.net/moon/800.jpg"

$wc = New-Object System.Net.WebClient
$wc.DownloadFile($url, "C:\temp\test.jpg")
Lemmie chew on how best to implement that.

I think the issue is that the site has implemented CloudFlare, which is doing a "browser check" and then re-directing you to the image. WebParser can't deal with re-directs.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Why WebParser Download Stops Working?

Post by jsmorley »

So like this:

Skin:

Code: Select all

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

[Variables]
URL=https://static.die.net/moon/800.jpg

[MeasureScheduleDownload]
Measure=Calc
UpdateDivider=600
OnUpdateAction=[!CommandMeasure MeasureRun "Run"]

[MeasureRun]
Measure=Plugin
Plugin=RunCommand
OutputType=ANSI
Program=PowerShell.exe
Parameter=-NoProfile -ExecutionPolicy Bypass -Command "& '.\GetMoon.ps1' '#URL#' '.\Moon.jpg'"
FinishAction=[!SetOption MeterShowMoon ImageName "Moon.jpg"][!UpdateMeter MeterShowMoon][!Redraw]

[MeterShowMoon]
Meter=Image
Path=#CURRENTPATH#
W=200
PreserveAspectRatio=1
GetMoon.ps1:

Code: Select all

$url = $args[0]
$file = $args[1]

Remove-Item $file

$wc = New-Object System.Net.WebClient
$wc.DownloadFile($url, $file)

1.png

GetImage_2.0.rmskin


That will fire it when the skin is loaded or refreshed, and every subsequent 10 minutes... 600 X 1000 milliseconds.

Geeky note: The reason for the [!SetOption MeterShowMoon ImageName "Moon.jpg"] on the FinishAction option is to address a timing issue. The Powershell script is executed when the skin is first loaded, and appears to have time to create an empty "moon.jpg" file in the folder before it is done downloading the actual image. If you have ImageName set on the Image meter to start with, it will find and load that empty image, and "cache" it in memory. It will never load the completed one then. Setting ImageName only after the Powershell is entirely completed solves this issue, as the image meter isn't looking for the image until it it done.
You do not have the required permissions to view the files attached to this post.
User avatar
GTI.H
Posts: 75
Joined: December 15th, 2018, 3:35 am

Re: Why WebParser Download Stops Working?

Post by GTI.H »

Ok!

Now I have work ahead, I will test at the earliest opportunity and then return the results!

Many thanks for now. :thumbup:
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Why WebParser Download Stops Working?

Post by jsmorley »

GTI.H wrote: December 15th, 2018, 5:17 pm Ok!

Now I have work ahead, I will test at the earliest opportunity and then return the results!

Many thanks for now. :thumbup:
Sure. Let me know if you have questions.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Why WebParser Download Stops Working?

Post by jsmorley »

And if you use the latest 4.3 beta of Rainmeter, you can use Container to remove the black background on the image. Cause, why not...

https://docs.rainmeter.net/manual-beta/meters/general-options/container/

Code: Select all

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

[Variables]
URL=https://static.die.net/moon/800.jpg

[MeasureScheduleDownload]
Measure=Calc
UpdateDivider=600
OnUpdateAction=[!CommandMeasure MeasureRun "Run"]

[MeasureRun]
Measure=Plugin
Plugin=RunCommand
OutputType=ANSI
Program=PowerShell.exe
Parameter=-NoProfile -ExecutionPolicy Bypass -Command "& '.\GetMoon.ps1' '#URL#' '.\Moon.jpg'"
FinishAction=[!SetOption MeterShowMoon ImageName "Moon.jpg"][!UpdateMeter MeterShowMoon][!Redraw]

[MeterContainer]
Meter=Shape
Shape=Ellipse 100,100,96 | StrokeWidth 0

[MeterShowMoon]
Meter=Image
Path=#CURRENTPATH#
W=200
PreserveAspectRatio=1
Container=MeterContainer
1.png
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 16164
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Why WebParser Download Stops Working?

Post by balala »

jsmorley wrote: December 15th, 2018, 3:28 pm Not sure. They may have built-in a browser check to prevent this kind of automatic downloading from the site.
Probably you're right. But if you do, how does work the later posted PowerShell code? Is it "deceives" somehow the URL?
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Why WebParser Download Stops Working?

Post by jsmorley »

balala wrote: December 15th, 2018, 6:46 pm Probably you're right. But if you do, how does work the later posted PowerShell code? Is it "deceives" somehow the URL?
I think in any case the browser-check is passed, but there is then a re-direct to the actual image. WebParser, or I think more to the point, the Download function of WebParser, just can't deal with a re-direct like that, where the Powershell function seems to be able to. I think the key to that is the C#-based System.Net.WebClient, which is likely a slightly more robust animal than the C++ WinINet API calls used in WebParser.