Thursday 9 October 2008

automatically add cd2 to playlist if present

This will , as the name suggests, add movie cd1.avi and movie cd2.avi to a playlist, if its present. This means there's no messing around in the middle of a film if your films are encoded to fit on two 700mb cds for example; it'll just play the 2nd part right after the first.

It'll only work if the first filename contains cd1 or CD1. I put this script in my /usr/bin folder and mark it as executible, then just using nautilus i set my video files to open with it instead of with a normal video player. If the filename doesn't contain cd1 or CD1, it'll just play the file normally. This is set up for gmplayer, but it works fine in xine (the -idx flag can be removed if using xine or a xine-based player)

#! /usr/bin/python

import sys, os

s = sys.argv[1]
cd2 = s.strip().replace('cd1', 'cd2')
cd2 = t.strip().replace('CD1', 'CD2')
if s == cd2:
os.system('''gmplayer "''' + s +'''"''')
else:
os.system('''gmplayer -idx "''' + s + '''" "''' + cd2+'''"''')

No comments:

Post a Comment