This one goes through an m3u playlist and seperates out the songs that have been moved or deleted.
By Collin Anderson
import sys
import os.path
oldname = sys.argv[-1]
dirname = os.path.dirname(oldname)
goodname = oldname.replace(".m3u","_good.m3u")
badname = oldname.replace(".m3u","_bad.m3u")
old=file(oldname)
good=file(goodname,"w")
badlst=[]
for line in old:
if not line.startswith("#"):
if os.path.exists(os.path.join(dirname, line.strip())):
good.write(line)
else:
#bad.write(line)
badlst.append(line)
old.close()
good.close()
if badlst:
badlst.sort()
bad=file(badname,"w")
for x in badlst:
bad.write(x)
bad.close()
Tags: m3u, playlist, python
This entry was posted on February 13, 2007 at 9:18 am and is filed under Uncategorized. You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.