News:

HOT TIP! Commands and groups can be copied and pasted directly from your command editor to the forum, and vice versa. This makes sharing command XML on the forum much easier!

Main Menu

Bing Image Downloader

Started by Haddood, November 02, 2014, 07:41:06 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Haddood

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


<?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>
When Voice command gets tough, use hand gestures

nime5ter

#1
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:
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:

<?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)
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

#2
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
When Voice command gets tough, use hand gestures

JonPeyton