Music Sorter
Posted: February 12th, 2010, 2:03 pm
Hi
I made/assembled this scripts using bits and pieces found around this forum. All it does is go through a folder with downloaded music in the format completedmusic/artistname - albumname..../ and moves them to your music folder in the format Music/Artist/Artistname - Album..../ as this is how i like to store my music.
music_sorter.py
oh ye it also updates xbmc afterwards if it's on the same computer that is.
Problem is i that i can't get sabnzbd to run the script, but it works fine when calling it from terminal. i have chmod +x'ed it but still gives error
Exit(-1) Cannot run script /home/brian/scripts/music_sorter.py
anybody can help?
I made/assembled this scripts using bits and pieces found around this forum. All it does is go through a folder with downloaded music in the format completedmusic/artistname - albumname..../ and moves them to your music folder in the format Music/Artist/Artistname - Album..../ as this is how i like to store my music.
music_sorter.py
Code: Select all
#!/usr/bin/python
import os
import sys
import string
import ConfigParser
import shutil
import re
import urllib2
import socket
# store the script's working path
scriptHome = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0])))
# define the desired socket timeout in seconds (used in handling of url's)
timeout = 20
socket.setdefaulttimeout(timeout)
musicSource="/home/brian/downloads/music"
musicDir="/home/brian/Music"
downloadList = os.listdir(musicSource)
downloadList.sort()
for download in downloadList:
newArtist = 1
artistsList = os.listdir(musicDir)
artistsList.sort()
for artist in artistsList:
if artist==download.split(" - ")[0]:
newArtist=0
os.mvdir(musicSource+"/"+download, musicDir+"/"+artist)
break
if newArtist == 1:
os.mkdir(musicDir+"/"+download.split(" - ")[0])
shutil.move(musicSource+"/"+download, musicDir+"/"+download.split(" - ")[0])
xbmcurl = urllib2.Request("http://localhost:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn¶meter=XBMC.updatelibrary(music)")
try: handle = urllib2.urlopen(xbmcurl)
except IOError, e:
print "XBMC library update skipped"
else:
print "XBMC library update completed"
Problem is i that i can't get sabnzbd to run the script, but it works fine when calling it from terminal. i have chmod +x'ed it but still gives error
Exit(-1) Cannot run script /home/brian/scripts/music_sorter.py
anybody can help?