Difference between revisions of "MythPretty"
Line 1: | Line 1: | ||
− | [Category:Tutorials] | + | [[Category:Tutorials]] |
== Making MythTV recordings more Share Friendly == | == Making MythTV recordings more Share Friendly == |
Revision as of 14:00, 3 September 2008
Contents
So, you have your LMCE system happily recording all your favorite shows, and you have a linux/windows/mac box that you wish to use to watch these shows, with XBMC or whatever your poison. Here is the issue. LMCE happily shares out /home for all systems connected to the LMCE internal network. So you browse over to /home/public/data/videos/tv_shows_1 and what do you see?
1108_20080902080022.mpg 1124_20080829205855.mpg 1131_20080831230000.mpg 1131_20080831233000.mpg 1135_20080901010000.mpg 1135_20080903002000.mpg 1136_20080902220000.mpg 1136_20080903070216.mpg 1136_20080903073000.mpg 1136_20080903080000.mpg 1169_20080830160000.mpg 1169_20080830163000.mpg 1169_20080831160000.mpg 1169_20080831163000.mpg 1169_20080902163000.mpg 1169_20080902213038.mpg
But what you want to see is :
Lost Boys- The Tribe - 2008-08-02, 1-00 AM.mpg Not Going Out - 2008-08-12, 11-40 PM.mpg Not Going Out - 2008-08-19, 11-40 PM.mpg Primeval - 2008-08-23, 9-00 PM.mpg Radio - 2008-08-11, 8-14 PM.nuv Skins - 2008-08-24, 10-00 PM - Jal.mpg Skins - 2008-08-24, 9-00 PM - Cassie.mpg Skins - 2008-09-01, 1-00 AM - Chris.mpg South Park - 2008-07-26, 10-00 PM - Simpsons Already Did It.mpg South Park - 2008-07-26, 10-30 PM - Make Love, Not Warcraft.mpg South Park - 2008-07-26, 11-00 PM - Good Times With Weapons.mpg South Park - 2008-07-26, 11-30 PM - Cartoon Wars.mpg South Park - 2008-07-27, 0-30 AM - It Hits the Fan.mpg Stargate Atlantis - 2008-08-01, 10-00 PM - The Daedalus Variations.mpg Stargate Atlantis - 2008-08-15, 10-00 PM - The Ghost in the Machine.mpg Stargate Atlantis - 2008-08-22, 10-00 PM - The Shrine.mpg The Shield - 2008-09-02, 10-00 PM - Coefficient of Drag.mpg Z Rock - 2008-08-31, 11-00 PM.nuv Z Rock - 2008-08-31, 11-30 PM.mpg
So what magic force causes this to happen? mythrename.pl . This script replaces or creates symlinks from the source recording to a "Human Readable" format. WARNING!!!! Do not run this inside your recordings directory, create a new one. See below!!!!!
I first saw this being used in a script called mythpretty.sh from my former KnoppMyth platform, and it is still a part of mythtv, but you have to unearth it. This procedure is how to do that.
Locating and Enabling the mythrename.pl file
By default the file is stored in
/usr/share/doc/mythtv-backend/contrib
The file is called
mythrename.pl.gz
The first thing you do is copy the file over to /usr/local/bin and gunzip it:
cp /usr/share/doc/mythtv-backend/contrib/mythrename.pl.gz /usr/local/bin gunzip /usr/local/bin/mythrename.pl.gz chmod a+x /usr/local/bin/mythrename.pl
Mythrename.pl Usage
The script has the following usage switches:
mythrename.pl --verbose --format "%c_%Y%m%d%H%i%s"
All options: options: --link [destination directory] If you would like mythrename.pl to work like the old mythlink.pl, specify --link and an optional pathname. If no pathname is given, links will be created in the show_names directory inside of the current mythtv data directory on this machine. eg: /var/video/show_names/ WARNING: ALL symlinks within the destination directory and its subdirectories (recursive) will be removed when using the --link option. --live Include live tv recordings, affects both linking and renaming. default: do not link/rename live tv recordings --format default: %T %- %Y-%m-%d, %g-%i %A %- %S %T = title (aka show name) %S = subtitle (aka episode name) %R = description %C = category (as reported by grabber) %c = chanid %U = recording group %y = year, 2 digits %Y = year, 4 digits %n = month %m = month, leading zero %j = day of month %d = day of month, leading zero %g = 12-hour hour %G = 24-hour hour %h = 12-hour hour, with leading zero %H = 24-hour hour, with leading zero %i = minutes %s = seconds %a = am/pm %A = AM/PM %- = separator character / = directory/folder (path separator) * For end time, prepend an "e" to the appropriate time/date format code above; i.e. "%eG" gives the 24-hour hour for the end time. * For original airdate, prepend an "o" to the year, month, or day format codes above; i.e. "%oY" gives the year in which the episode was first aired. * A suffix of .mpg or .nuv will be added where appropriate. * To separate links into subdirectories, include the / format specifier between the appropriate fields. For example, "%T/%S" would create a directory for each title containing links for each recording named by subtitle. You may use any number of subdirectories in your format specifier. If used without the --link option, "/" will be replaced with the "%-" separator character. --separator The string used to separate sections of the link name. Specifying the separator allows trailing separators to be removed from the link name and multiple separators caused by missing data to be consolidated. Indicate the separator character in the format string using either a literal character or the %- specifier. default: '-' --replacement Characters in the link name which are not legal on some filesystems will be replaced with the given character illegal characters: \ : * ? < > | " default: '-' --underscores Replace whitespace in filenames with underscore characters. default: No underscores --verbose Print debug info. default: No info printed to console --help Show this help text.
Creating your own version of the script (the one I use)
This will have to be done on a per tuner/recording directory basis. For my example I will use 2 of my 4 directories. I have 1 tuner on the core, and 1 tuner on the MD moon56. There is also one caveat, you do not want to run the script on the recordings directory, you want a different directory for your "exported" symlinks. For example I create /export/tv1 and /export/tv2
So for the core (/home/public/data/videos/tv_shows_1)
sudo mkdir /export/tv1 sudo mkdir /export/tv2
Add them to samba's smb.conf
sudo vi /etc/samba/smb.conf
Add: (I put this between the [public] and [home] entries
[export] comment = mythtv pretty files browseable = yes writeable = yes path = /export public = no guest ok = no force user = root force group = public create mask = 0774 directory mask = 0775 inherit acls = yes inherit uid = yes inherit owner = yes inherit permissions = yes
Restart samba services:
/etc/init.d/samba restart
And the script: /usr/local/bin/mythpretty1
#!/bin/bash cd /home/public/data/videos/tv_shows_1 mythrename.pl --link /export/tv1
For my case I also added to the core's /etc/exports file
/export 192.168.80.0/255.255.255.0(rw,no_root_squash,no_all_squash,sync,no_subtree_check)
And to the MD's /etc/fstab file
192.168.80.1:/export /export nfs intr,udp,rsize=32768,wsize=32768,retrans=10,timeo=50 1 1
Restart nfs server
/etc/init.d/nfs-kernel-server restart
My MD's script: /usr/local/bin/mythpretty2
#!/bin/bash cd /home/public/data/videos/tv_shows_56 mythrename.pl --link /export/tv2
Schedule the job as cron
On Core: (Runs every day at midnight to keep it sync'd up)
sudo crontab -e
add
0 0 * * * /usr/local/bin/mythpretty1
On MD: (Runs every day at midnight to keep it sync'd up)
sudo crontab -e
add
0 0 * * * /usr/local/bin/mythpretty2
Conclusion
Now when using another non-LMCE system to view your MythTV recordings, when setting up video shares, point them to /export/tvX where X is your paticular setup.
Warnings
If you run this inside your recordings directory i.e not specifying a different directory w/out the --link switch, it will replace all of your 1122_blahblah.mpg files with the renamed file, this will cause LMCE's database to get out of sync, and may hose things up. So, that said, don't do it! :)
If you create a directory under the /home diretory, things will start showing up twice in the LMCE menu. SO the need to create a different directory OUTSIDE of /home, is also very IMPORTANT. So make sure you keep it out of /home. :)
Best of luck, and Happy viewing!