[SUCS Devel] Listen Again

Andrew Price welshbyte at sucs.org
Sun Aug 12 16:59:45 BST 2007


Whups, forgot the 11pm icecast log will be the last one listed at
midnight. This should work now:

import os
import sys
import datetime
import subprocess
day = datetime.datetime.today() + datetime.timedelta(minutes=-30)
path = day.strftime('/home/icecast/logs/%Y/%m/%d/')
logs = os.listdir(path)
if len(logs) < 2:
    sys.exit(0)
logs.sort()
if day.hour == 23:
    iclog = logs[-1]
else:
    iclog = logs[-2]
log = path+iclog
when = day.strftime('%A-'+iclog[:2]+':00')
logfile = file('listenAgain.log-'+when,'w')
returncode = subprocess.call("ffmpeg" + " -y -i "+log+"
/tmp/"+when+".swf" , shell=True, stdout=logfile, stderr=logfile)
returncode = subprocess.call("scp" + " /tmp/"+when+".swf
xtreme at sucs.org:~/public_html/listen_again/" , shell=True,
stdout=logfile, stderr=logfile)
os.unlink("/tmp/"+when+".swf")




More information about the Devel mailing list