Mythtv - myth-rename / myth-link workaround.
On doing a dist-upgrade of ubuntu this weekend, and after sorting out the million little problems that become apparent, one with myth-tv reared its head. The files weren't being renamed correctly.
If you don't know, myth-tv creates files like "5287_20100704195600.mpg". I like to have them named something "Build_A_New_Life_In_The_Country_-_2010-06-30,_1-56_PM_-_Untitled.mpg" so I can browse the pvr machine's network share and play the files from either laptop, my desktop and my Popcorn Hour plugged into the big telly.
Unfortunately, in the great and good minds of Myth-tv, they cannot seem to grasp that somebody wants to do this. Certainly when I went into the support irc channel asking why it didn't automatically expire database records, resulting in a mysql database for myth containing some 3 million records, the fact that I wanted to use the file system directly instead of their shiny (but slow and clunky, compared to a filesystem) interface surprised them.
Anyway, I digress. On reading the documentation it appears that myth-rename.pl, the script included with Myth to rename files for export (and also to satisfy heathens like myself) had been removed in favour of myth-link.pl - which created a NEW FILE for each recording simply linking to it. Granted, this new file was correctly named, but it didn't remove the original, meaning a duplicate in my explorer window. This is very bizarre and I don't understand this rationale. There was another option - use a myth filesystem, mythfs, but when I tried it it didn't work, and googling told me I'd need to recompile Myth to support it. Given I use Ubuntu on this box so I get nice packages, I didn't want to go down this route. Computers are supposed to make life easier, right?
Anyway, I've worked around it. I've written the attached and very basic script which emulates the original myth-rename.pl script.
Checks the recording directory for any file matching the nnnn.mpg filename.
If found, checks that it's not currently recording by ensuring the "last modified" bit is at least X seconds in the past.
Then queries the myth database with the filename. Gets the details of that record and renames the file and updates the myth database with the new filename, so that continues to work.
It works ok, not seriously tested and ugly in code, but it works for me.
Sorry myth coders. In many ways it's a great system, but seriously, you need to consider that people want to use your software in more than one way...
31 July 2010 - update added to add more escaping to the sql syntax.
| Attachment | Size | Hits | Last download |
|---|---|---|---|
| myth-name.pl.txt | 2.73 KB | 14 | 1 day 1 hour ago |