[mythtv-users] An companion script for jamu.py

Epinephrine Junky epinephrine_junky at beadon.ca
Wed Aug 10 19:58:06 UTC 2011



I'm a big fan of jamu, especially since I found the -MF command to fiX
sTupId caSE issuES and make the naming consistent. But there is one missing
feature that was driving me nuts. So I decided to brush off my python and
take a stab at it. 

I think this code really belongs somewhere in the body
of jamu.py but I don't presume to know what the author thinks about it. I'm
hoping that devs will read this and comment. 

The case that jamu doesn't
cover: 

I have an incoming folder where new episodes of shows are put on
my drive. Sadly the different series and seasons are all mixed together in
that folder. That required me to run: 

jamu.py -MF
/incoming/series1.S01E01.blahblah.mkv
/mythtv-videos/TV-Shows/Series1/Season1 

jamu.py -MF
/incoming/series2.S03E01.blahblah.mkv
/mythtv-videos/TV-Shows/Series2/Season3 

... etc for each file that landed
in the incoming folder. 

Rather than typing all of that I wrote the
following python script to parse out the name of the series and deduce the
output path. I may tweak this to automatically put the season number in the
destination directory path but at the moment I like this because I don't
keep more than one season at a time. 

Now that I have this script running
in a cron job hourly my new shows are automagically showing up in mythtv. =
happy MythTV/jamu family. :) 

Hope this is useful to others out
there.

cheers,

#!/usr/bin/python
#
# preSort4jamu.py
# This script takes
a directory full of loosely formatted video files and
# uses jamu.py's "-MF
" syntax to sort the
# files and insert into the MythTV database.

#
Prerequisites:
# Functioning MythTV install with jamu. This was developed
on ubuntu 10.04
# and may require some tweaks to the paths below on other
systems.

import re,string,os,subprocess

# Set the following dictionary to
show the paths for your system
SystemPaths =
{"Destination":"/mythtv-videos/TV-Shows/",
 "Source":"/incoming/",

"JAMU":"/usr/share/mythtv/mythvideo/scripts/jamu.py",
 }

# You shouldn't
need to modify anything below here.

for root, dirs, files in
os.walk(SystemPaths["Source"]):
 for name in files:
 sourceFilename =
os.path.join(root, name)
 directoryPattern =
re.compile('^([ws.]*)(s+-s+){0,1}(?=([sS]d{2}[eE]d{2}))')
 filenameMatch =
directoryPattern.search(name)
 if filenameMatch:
 #convert any period
delimited names into space separated ones and
 #remove leading and trailing
spaces
 spaceyName = string.strip(filenameMatch.group(1).replace('.',' '))

subprocess.call([SystemPaths["JAMU"],"--user_config=/home/mythtv/.mythtv/jamu.conf","-MF",sourceFilename,SystemPaths["Destination"]+spaceyName.title()])

else:
 print "no match on: "+name

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.mythtv.org/pipermail/mythtv-users/attachments/20110810/406baa51/attachment.html 


More information about the mythtv-users mailing list