Author Topic: Bing Image Downloader  (Read 5324 times)

0 Members and 1 Guest are viewing this topic.

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Bing Image Downloader
« 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>
« Last Edit: November 02, 2014, 04:08:35 PM by Haddood »
When Voice command gets tough, use hand gestures

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Bing Image Downloader
« Reply #1 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)
« Last Edit: November 02, 2014, 07:05:53 PM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: Bing Image Downloader
« Reply #2 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
« Last Edit: December 20, 2014, 02:48:07 AM by Haddood »
When Voice command gets tough, use hand gestures

JonPeyton

  • $upporter
  • Jr. Member
  • *****
  • Posts: 36
  • Karma: 3
    • View Profile
Re: Bing Image Downloader
« Reply #3 on: September 03, 2018, 04:50:33 PM »
love it thanks!