<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.&nbsp; But there is one missing feature that was driving me nuts.&nbsp; 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.&nbsp; 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.&nbsp; Sadly the different series and seasons are all mixed together in that folder.&nbsp; 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.&nbsp; 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.&nbsp; = happy MythTV/jamu family.&nbsp; :)</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 &lt;sourceFile&gt; &lt;destinationDir&gt;" syntax to sort the<br /># files and insert into the MythTV database.<br /><br /># Prerequisites:<br />#&nbsp;&nbsp; Functioning MythTV install with jamu.&nbsp; This was developed on ubuntu 10.04<br />#&nbsp;&nbsp; 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 />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "Source":"/incoming/",<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "JAMU":"/usr/share/mythtv/mythvideo/scripts/jamu.py",<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br /><br /># You shouldn't need to modify anything below here.<br /><br />for root, dirs, files in os.walk(SystemPaths["Source"]):<br />&nbsp; for name in files:<br />&nbsp;&nbsp;&nbsp; sourceFilename = os.path.join(root, name)<br />&nbsp;&nbsp;&nbsp; directoryPattern = re.compile('^([\w\s\.]*)(\s+-\s+){0,1}(?=([sS]\d{2}[eE]\d{2}))')<br />&nbsp;&nbsp;&nbsp; filenameMatch = directoryPattern.search(name)<br />&nbsp;&nbsp;&nbsp; if filenameMatch:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #convert any period delimited names into space separated ones and<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #remove leading and trailing spaces<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; spaceyName = string.strip(filenameMatch.group(1).replace('.',' '))<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; subprocess.call([SystemPaths["JAMU"],"--user_config=/home/mythtv/.mythtv/jamu.conf","-MF",sourceFilename,SystemPaths["Destination"]+spaceyName.title()])<br />&nbsp;&nbsp;&nbsp; else:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "no match on: "+name<br /><br /></span></p>