Splash randomizer
#1
what i would love to see made (once again, can't program much at all) is a tiny script that randomizes the next splashscreen for the next bootup. basically, it'd be a randomizer that simply renames files, ie, splash.000 > splash.png, etc.

each time xbmc is booted up, it renames a new splash file to be displayed on next bootup.

any takers?

thanks!

psc
Reply
#2
bump.

or even point me in the right direction for basic basic py scripting. (random number generation, renaming of files.. etc)

thanks,

psc
Reply
#3
this might work. i didnt debug it or test or anything though.

Quote:import os, random, shutil

files = filter(lambda x: x.startswith('splash.'), os.listdir('q://media//'))
os.remove('q://media//splash.png')
random.seed()
shutil.copy('q://media//'+files[random.randint(0,len(files)-1)],'q://media//splash.png')

edit ohh call that autoexec.py and put it in the scripts folder.



Reply
#4
ok, so if i have, say, 7 files: splash.000 - splash.005 (+splash.png) in the media folder it will pick one of those? sorry, i just don't get what that script does.

i see that it removes the current splash, then randomizes.. and copies a new file into splash.png, but i don't see how it picks the file, and what it does with the old splash.png once it puts the new one in place.

thanks a lot

psc

edit: alright, i see that file is the variable and it picks anything that begins with 'splash'. so there's no limit to how many i can put in there, as long as it begins with splash?

i guess my only question now is what happens to the old one once it gets removed.



Reply
#5
i probably abridged too much stuff... when you make stuff short it is not obvious what it does so i will rewrite with more clarity.
this does the same thing as before.

note there is likely a bug from before if you try replacing the splash.png with any other file that begins with 'splash' since it could try replacing with itself. here i changed the other files to begin with 'logo'. the original splash.png is removed each time but the logo files are unchanged so you can copy your current splash as logo1.png or something.

Quote:import os, random, shutil

# get a list of all the files in the media dir
files = os.listdir('q://media//'))

# this will be a list of those files which are splash files
splash_files = []

for f in files:
if f.startswith('logo'):
splash_files.append(f)

#this makes random different each time you run it
random.seed()

# pick a the new splash screen at random with an index
# from 0 to len(files) - 1
newsplash = files[random.randint(0,len(files)-1)]
# need full path with the filename
new_splash_path = 'q://media//'+newsplash
old_splash_path = 'q://media//splash.png'

os.remove(old_splash_path)
shutil.copy(new_splash_path,old_splash_path)
Reply

Logout Mark Read Team Forum Stats Members Help
Splash randomizer0