This script starts a randomly selected streaming radio station at startup (some examples are provided below.) It also sets the slideshow screensaver to use a large number of images, which I got from a wallpaper torrent, also listed below. It starts a random slideshow of the images a few seconds after XBMC starts and the music starts playing. It's a neat little audiovisual setup for your XBMC, and if you have XBMC as your primary dash, you can boot into this mode with one button! I recommend Confluence Light for use with this setup at 720p; regular Confluence will work but less smoothly at startup.
Here's a video of the script in action, from xbox startup to music/slideshow: https://www.youtube.com/watch?v=EGL7zwus-tI
Details
I wanted to play some streaming music when XBMC started, so I got together a few video game/demoscene/chiptune music streaming radio stations (see links below) and had my autoexec.py pick a random file from the folder when XBMC started. (it wasn't working for me from the startup playlist option)
I also thought it would be cool to download a lot wallpapers and use them as a screensaver. I downloaded a huge wallpaper set (see link below), and converted them to 720p jpgs, which came up to about 7GB. In the process of transferring them to my xbox, I ran up against the 4096 file limit. So, I split the files into 10 directories and tried again. Running a recursive slideshow or starting the screensaver pointed to the image diretories didn't work, the screensaver would take control away and I would have to press a button to return to normal browsing, but nothing would appear on screen. So, apparently ~40,000 images is a little too much for a recursive slideshow.
To work around this I had the autoexec.py script change the setting by editing the slideshowpath line in guisettings.xml to a random folder out of 10 folders containing 4096 images each. So now I have a built-in screensaver that doesn't rely on an external API to get content. I have my screensaver set to start at 1 minute, and I also put a line in the script to start a random slideshow of the current screensaver directory at startup.
By the way, I had tried putting the images in 0 compression RARs to save on file count and transfer time, but the slideshow would always start from the first image of each RAR.
Wallpaper set from: https://www.reddit.com/r/pcmasterrace/c ... allpapers/ (note that all wallpapers are available on imgur)
I used FastStone Image Viewer to batch convert the image files to 720p 16:9 resolution (using "smart cropping") rather than scaling at 90% quality.
You should run a duplicate checker on the images; maybe 1/4 of them are duplicates. The program I used was DupDetector, but it's a little awkward to use and I don't recommend it. I was able to get the full 720p set down to 5.6 gigs and ~31,000 files by removing duplicates.
As a side note, UnleashX can also have its screensaver set to a 4096-image directory and handles it fine loading-wise, although it will chug a little with rendering 720p images. 480p images are much smaller, and I ended up sending over a single folder of 4096 images for UnleashX to use. Note that you need to resize them to 853x480 for them to fill the screen on UnleashX, not 720x480 like I tried the first time...
Streaming radio stations:
Scenesat Radio (Demoscene): http://www.scenesat.com/listenmenu
mine - High bandwidth, max quality - http://www.scenesat.com/listen/normal/max.m3u
Nectarine Demoscene Radio - https://www.scenemusic.net/demovibes/streams/
mine - http://necta.jansenit.com:8000/necta192.mp3.m3u
AI Radio (Video game music) - http://ai-radio.org/streams/
mine - http://ai-radio.org/320.ogg
CGM UK Demoscene Radio - http://www.lmp.d2g.com/
mine - 128kbps mp3 - http://www.lmp.d2g.com:8003/listen.pls
Gyusyubu Radio (music from old Japanese PC games) - http://gyusyabu.ddo.jp:8000/listen.pls
Kohina ("old school game and demo music") - http://www.kohina.com/ (note that there are 2 streams)
mine - http://www.deliancourt.org:8000/fresh.ogg.m3u ("Fresh" stream, DE)
mine - http://stream.nute.net:8000/kohina/stream.ogg.m3u ("Full Playlist" stream, FR)
Let me know if you haven any suggestions for improvement to streaming format for any of these sites, or any streams that you think would go well with this, and I'll update the links in the OP
I have to say that these stations go great with the above image download, try it out! I recommend adding all your stations to your favorites, so that you can quickly switch between them.
I really had a blast with this little project and seeing the end result.
SCRIPT:
(Thanks to Rocky5 with his help cleaning this up!)
Code: Select all
import xbmc
import time
import random
import os
import fileinput
#########################################################################################################
# Paths (change me; no trailing slashes please)
#########################################################################################################
Music_Path = "F:/Music/BGRadio"
Pictures_Path = "F:/Pictures/Wallpaper/720p"
#########################################################################################################
# Wait a little while for both since the script seems to fail otherwise
#########################################################################################################
time.sleep(1.5)
#########################################################################################################
# Get a random subdirectory of Pictures_Path and set this directory to the slideshow screensaver path
#########################################################################################################
Pictures_Dir_List = os.listdir(Pictures_Path)
Directory_Name = random.choice(Pictures_Dir_List)
New_Screensaver_Path = Pictures_Path + '/' + Directory_Name
Slideshow_XML_Line = '<slideshowpath pathversion="1">' + New_Screensaver_Path + '/</slideshowpath>\n'
GUISettings_Path = fileinput.input( xbmc.translatePath( 'special://profile/guisettings.xml' ), inplace=1)
for line in GUISettings_Path:
if "slideshowpath" in line:
line = Slideshow_XML_Line
sys.stdout.write(line)
#########################################################################################################
# Get a random playback item from the music directory (does not check for file type)
#########################################################################################################
list = os.listdir( Music_Path )
xbmc.executebuiltin( 'PlayMedia(' + Music_Path + '/' + random.choice(list) + ')' )
#########################################################################################################
# Start a slideshow with the new screensaver directory
#
# NOTE: This runs into memory issues with starting the screensaver and radio at the same time for regular Confluence at 720p.
# Confluence Light seems to work fine. If you're only using this for the screensaver, you can remove the time.sleep call.
# Users with 128GB of RAM on regular Confluence might be also ok with removing the time.sleep call.
# 7 seconds was about the lowest I could set it on Confluence where it usually wouldn't be interefered with by radio startup.
#########################################################################################################
#time.sleep(7.5) #uncomment this line if you're not on a low memory skin!
xbmc.executebuiltin('SlideShow('+ New_Screensaver_Path + ', random)')
DON'T USE THIS VERSION, USE THE ABOVE VERSION WHICH IS BASED ON THE NEXT POST
THIS IS HERE AS AN EXAMPLE OF WHAT NOT TO DO
(it has been fixed to work though)
Code: Select all
import xbmc
import time
import random
import os
# Wait a little while for both since the script seems to fail otherwise
time.sleep(1.5)
# Get a random item from the directory (does not check for file type)
# Use this directory or change it to your directory of choice on both lines
list = os.listdir("E:\\Apps\\XBMC\\BGMusic")
xbmc.executebuiltin( "PlayMedia(\"E:\\Apps\\XBMC\\BGMusic\\" + random.choice(list) + "\")" )
# Get a random subdirectory of dirpath, be sure to add the trailing slashes to your dirpath.
# This dir should only contain folders (sloppy, I know)
dirpath = "F:\\Pictures\\Wallpaper\\720p"
walldirlist = os.listdir(dirpath)
dirname = random.choice(walldirlist)
pathstring = "<slideshowpath pathversion=\"1\">dirpath + dirname + "\\</slideshowpath>\n"
filePath = "E:\\Apps\\XBMC\\UserData\\guisettings.xml"
text = open(filePath).read()
#xbmc.log(text)
new_text = '\n'.join(pathstring if line.find("slideshowpath") != -1 else line for line in text.splitlines())
open(filePath, 'w').write(new_text)