VoxCommando

VoxNastics (User Guides and Mods) => XML Exchange => Topic started by: Haddood on November 02, 2014, 07:41:06 AM

Title: Bing Image Downloader
Post by: Haddood on November 02, 2014, 07:41:06 AM
here is a command that will download Bing Image of the day .... one practical use, I put them in folder then set XBMC amber skin to various background, command can be extended using http://www.sg20.com/wallpaperchanger/ to change the desktop background

trigger it once and it will keep triggering itself at 5:00am everyday ...
You need cURL installed ... make sure to fix the path of the cURL and where you want to save the images

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.0.7-->
<command id="302" name="Bing Image of the day" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Scrape.XML</cmdType>
    <params>
      <param>http://www.bing.com/HPImageArchive.aspx?format=xml&amp;idx=0&amp;n=1&amp;mkt=en-US</param>
      <param>urlBase</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.SetVar</cmdType>
    <params>
      <param>BingURL</param>
      <param>http://www.bing.com{Match.1}_1920x1080.jpg</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <params>
      <param>.*/(.*)</param>
      <param />
      <param>{var.BingURL}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Launch.Capture</cmdType>
    <params>
      <param>C:\Extensions\cURL\curl.exe</param>
      <param>-o "C:\Wallpaper\Bing\{Match.1}" {var.BingURL}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>VC.SetEventTimer</cmdType>
    <params>
      <param>5:00 AM</param>
      <param>Bing.ImageSave</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <event>Bing.ImageSave</event>
</command>
Title: Re: Bing Image Downloader
Post by: nime5ter on November 02, 2014, 07:03:12 PM
Fun. I like curl.

For those who don't have broad use for curl, Python is also an option. The following script can be used to download and save files from the web if you know the url:
Code: [Select]
from System.Net import WebClient

def downloadFile(url,filename):

    #change the following to the path where you want to save your files
    path = "C:\\[yourchosendirectory]\\[filepath]"+filename
    
    WebClient().DownloadFile(url,path)

So, for this purpose, you'd could do the following:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.0.7-->
<command id="302" name="Bing Image of the day--python version" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>PY.ExecFile</cmdType>
    <params>
      <param>PY\downloadFile.py</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Scrape.XML</cmdType>
    <params>
      <param>http://www.bing.com/HPImageArchive.aspx?format=xml&amp;idx=0&amp;n=1&amp;mkt=en-US</param>
      <param>urlBase</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.SetVar</cmdType>
    <params>
      <param>BingURL</param>
      <param>http://www.bing.com{Match.1}_1920x1080.jpg</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <params>
      <param>.*/(.*)</param>
      <param />
      <param>{var.BingURL}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>PY.ExecString</cmdType>
    <params>
      <param>downloadFile("{var.BingURL}","{Match.1}")</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>VC.SetEventTimer</cmdType>
    <params>
      <param>5:00 AM</param>
      <param>Bing.ImageSave</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <event>Bing.ImageSave</event>
</command>

(where downloadFile.py is the above python script)
Title: Re: Bing Image Downloader
Post by: Haddood on November 05, 2014, 02:32:41 PM
nime5ter ... that did not cross my mind ... for sure because I am a PY newbee 
I would just modify the PY function to pass the path as well, and we end up with a universal PY downloader :)
no need for external software ...

VC rocks
Title: Re: Bing Image Downloader
Post by: JonPeyton on September 03, 2018, 04:50:33 PM
love it thanks!