PDA

View Full Version : A script to Copy currently playing song to a favorites folder


jcrueger
2008-07-06, 03:33
First i'd like to explain in a little detail what i'm attempting to do. I'm trying to create a script that will copy not move the currently playing song to a folder called F:\ipod\ so i can then add the songs to my ipod. The reason i need a script to do this so when i hear a song i like i wont have to go thru the filemanger and find the song and then copy it everytime i find a song i like. And i would also like to add a keymap to keymaps.xml to execute the script from the visualization window so i can execute the script with a push of a single button when i'm listening to music with the tv off.
Now i've spent quite a bit of time trying to find out if this is even possible with not much luck. i've found script functions to get certain song info like artist and albumname ect but none for filepath/name and i've had limited success finding and info on how to copy files. So i've come here hoping for someone to maybee help write this or just point me in the right direction.

jmarshall
2008-07-06, 04:15
Why not tag it as a favourite by rating it highly? This is doable from the visualisation window already.

Then you have a smartplaylist that fetches said favourites, and you can very likely copy said files directly to another folder if you want.

Nuka1195
2008-07-06, 04:15
untested, check the pydocs in my signature. the info is in them

import xbmc
import shutil
import os

song = xbmc.Player().getPlayingFile()
ipod_song = "f:\\ipod\\" + os.path.basename( song )

shutil.copyfile( song, ipod_song )

jcrueger
2008-07-06, 12:28
lemme first say thanks for the quick response Jm/nuka.
Jmarshall: as far a setting a song as a favorite i was'nt aware of the options you could do with that. So that maybee something i can do with the songs i put into the ipod folder for more an even more refined selection from the songs i find.
sounds like its definately worth exploring.
that script that nuka wrote does exactly what i was looking for
i've got the whole thing mapped and working correctly as for me not being able to find the copy function i guess i should have done more looking in the python docs.. Thanks a bunch for the help.