I think this one is pretty clever... I use PS3MediaServer to stream to my PS3, and have it sort by date, such that new stuff is always on top... however is things are downloaded after PS3MS starts, they end up being appended (to the bottom). This is pretty wonky, so my solution is, whenever a file finishes downloading, restart the PS3MS service, but only if the PS3 isn't connected. I also have this run as an hourly cronjob, so if the PS3 is connected when a download finishes, the "re-ordering" doesn't wait until the next download to happen.
Code: Select all
#!/usr/bin/python
import os
import subprocess
import sys
p1 = subprocess.Popen(["netstat", "-tunv"], stdout=subprocess.PIPE)
p2 = subprocess.Popen(["grep", ":5001"], stdin=p1.stdout, stdout=subprocess.PIPE)
if os.waitpid(p2.pid, 0)[1]:
# print "restarting PS3M"
pstop = subprocess.Popen(["/etc/init.d/PS3MediaServer", "stop"], stdout=subprocess.PIPE)
os.waitpid(pstop.pid,0)
pstart = subprocess.Popen(["/etc/init.d/PS3MediaServer", "start"], stdout=subprocess.PIPE)
os.waitpid(pstart.pid,0)
# print "PS3M restarted"
#else:
# print "connections found"
Code: Select all
#!/bin/bash
curl -k https://prowl.weks.net/publicapi/add -F apikey=X -F application="Deluge" -F event="Torrent Completed" -F description="$2" &
The first one is run on torrent completion, and if a torrent is being downloaded to "/*/*/Files/", it makes a symlink to it in "/media/2TB/New Files"
The second runs on a daily cronjob, and removes any links in "/media/2TB/New Files/" that are over 6 days old.
The net effect, clearly, is that "/media/2TB/New Files/" contains symlinks to all of the new downloads (less than 6 days old)
Code: Select all
#!/usr/bin/python
import sys
import os
if sys.argv[3].split('/')[3] == 'Files':
os.system("ln -s \""+sys.argv[3]+sys.argv[2]+"\" /media/2TB/New\ Files/")
Code: Select all
#!/bin/bash
find /media/2TB/New\ Files/ -mtime +6 -type l -exec rm {} \;
find -L /media/2TB/New\ Files/ -type l -delete