<p dir="ltr"><span style="font-family: arial,helvetica,sans-serif;">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.</span></p>
<p><span style="font-family: arial,helvetica,sans-serif;">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.</span></p>
<p><span style="font-family: arial,helvetica,sans-serif;">The case that jamu doesn't cover:</span></p>
<p><span style="font-family: arial,helvetica,sans-serif;">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:</span></p>
<p><span style="font-family: arial,helvetica,sans-serif;">jamu.py -MF /incoming/series1.S01E01.blahblah.mkv /mythtv-videos/TV-Shows/Series1/Season1</span></p>
<p><span style="font-family: arial,helvetica,sans-serif;">jamu.py -MF /incoming/series2.S03E01.blahblah.mkv /mythtv-videos/TV-Shows/Series2/Season3</span></p>
<p><span style="font-family: arial,helvetica,sans-serif;">... etc for each file that landed in the incoming folder.</span></p>
<p><span style="font-family: arial,helvetica,sans-serif;">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.</span></p>
<p><span style="font-family: arial,helvetica,sans-serif;">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. :)</span></p>
<p><span style="font-family: arial,helvetica,sans-serif;">Hope this is useful to others out there.<br /></span></p>
<p><span style="font-family: arial,helvetica,sans-serif;">cheers,<br /></span></p>
<p><span style="font-family: arial,helvetica,sans-serif;">#!/usr/bin/python<br />#<br /># preSort4jamu.py<br /># This script takes a directory full of loosely formatted video files and<br /># uses jamu.py's "-MF <sourceFile> <destinationDir>" syntax to sort the<br /># files and insert into the MythTV database.<br /><br /># Prerequisites:<br /># Functioning MythTV install with jamu. This was developed on ubuntu 10.04<br /># and may require some tweaks to the paths below on other systems.<br /><br />import re,string,os,subprocess<br /><br /># Set the following dictionary to show the paths for your system<br />SystemPaths = {"Destination":"/mythtv-videos/TV-Shows/",<br /> "Source":"/incoming/",<br /> "JAMU":"/usr/share/mythtv/mythvideo/scripts/jamu.py",<br /> }<br /><br /># You shouldn't need to modify anything below here.<br /><br />for root, dirs, files in os.walk(SystemPaths["Source"]):<br /> for name in files:<br /> sourceFilename = os.path.join(root, name)<br /> directoryPattern = re.compile('^([\w\s\.]*)(\s+-\s+){0,1}(?=([sS]\d{2}[eE]\d{2}))')<br /> filenameMatch = directoryPattern.search(name)<br /> if filenameMatch:<br /> #convert any period delimited names into space separated ones and<br /> #remove leading and trailing spaces<br /> spaceyName = string.strip(filenameMatch.group(1).replace('.',' '))<br /> subprocess.call([SystemPaths["JAMU"],"--user_config=/home/mythtv/.mythtv/jamu.conf","-MF",sourceFilename,SystemPaths["Destination"]+spaceyName.title()])<br /> else:<br /> print "no match on: "+name<br /><br /></span></p>