[mythtv] Re: [mythtv-commits] Ticket #857: Patch to mythrename.pl to work correctly with slave backends

Michael T. Dean mtdean at thirdcontact.com
Thu Dec 22 22:03:15 EST 2005

Tom Lichti wrote:

> Michael T. Dean wrote:
>> Tom Lichti wrote:
>>> Michael T. Dean wrote:
>>>> MythTV wrote:
>>>>> #857: Patch to mythrename.pl to work correctly with slave backends
>>>>> -------------------------------------+-------------------------------------- 
>>>>> Reporter:  tom at redpepperracing.com  |       Owner:  ijr     Type:  
>>>>> patch                    |      Status:  new Priority:  
>>>>> minor                    |   Milestone:      Component:  
>>>>> mythtv                   |     Version:  head
>>>>> Severity:  low                      |  
>>>>> -------------------------------------+-------------------------------------- 
>>>>> This small patch updates mythrename.pl to use the hostname when 
>>>>> deciding
>>>>> what records to process. I only use the --link option, so further 
>>>>> testing
>>>>> may be required. 
>>>> If you check for hostname with the query, we won't get links to 
>>>> recordings recorded on other backends, even if the file exists on 
>>>> the filesystem (i.e. multiple backends share a recordings directory 
>>>> using NFS).  Since mythrename.pl checks for the existence of the 
>>>> file before creating the link, we shouldn't need to do this check.  
>>>> As is, we (should) only get links to recordings that are available 
>>>> through the filesystem and recordings whose filies are not 
>>>> available are (should be) ignored.
>>>> If there's a specific problem/error you're trying to fix, more info 
>>>> would be nice...  :) 
>>> Hrm. Well, in my case, using the --link option on both my master and 
>>> slave backends creates the same links on both, so something isn't 
>>> working. I'll see if I can narrow it down some more. At a quick 
>>> glance, I don't see where the check for the file existence is being 
>>> done, but I'm no perl expert. 
>> Hrmmm.  It seems that mythlink.sh had it, but mythlink.pl (which 
>> eventually became mythrename.pl) never got it...
>> So, how's this?  It should also make for many less "restores" after 
>> rename fails on inaccessible files...  Good catch.
>> If it works, you can post it on your ticket as a replacement for your 
>> patch (since this should meet both our expectations :).
> That seems to do it! I'll update the ticket.

Thanks.  BTW, it's easier for the devs if you attach the file instead of 
putting it in the text (which can lead to copy/paste errors of varying 
severity from annoying to won't-apply to applies-but-won't-compile to 
applies-and-compiles-but-doesn't-function-properly).  Normally, you post 
your, "This patch ..." message and /after/ submitting it, view the 
ticket and use the "Attach File" button to attach the file.

> There are a couple of other things that mythlink did that mythrename 
> doesn't... :)
> 1) It doesn't delete old links for shows that have been deleted (I 
> just add an rm * but it's pretty brutal)

Are you sure?  It should remove any links (even ones it didn't create ;) 
in the destination directory before starting to create links and should 
die if it fails to remove any of them (so you should get all or 
nothing).  Lines 226-229 - 

BTW, it works for me.

> 2) I like to organize the links by making a folder for each show, and 
> then just have the shows listed by title and date (again, I hacked 
> mine, but not nicely)

I'm doing a slightly easier thing that may work for you.  Instead of 
grouping shows by folder, I create several folders with different 
"views" of the files--each sorted differently.  I have a script 
(mythlink.sh) which creates the views (so I can run a single cron job to 
create them all).

When changing from the old mythlink.sh to mythlink.pl, I created the 
script as a "functional replacement" of the "upgraded" mythlink.sh (not 
the 0.18.1 and below version) in case packagers/etc. wanted it.  Chris 
decided that the script didn't really warrant inclusion in the contrib 
directory and I agreed, but I'm including a copy here for your viewing.  
(You'll need to edit the values at the top as described in the comments.)

The 5 format strings I include provide sorting by:
    1) start time/end time/title
    2) title/start time
    3) group/title/start time
    4) category/title/start time
    5) title/original airdate/subtitle

Using wildcards, you can easily view the shows by title.  Perhaps 
something like this would work for you?

-------------- next part --------------
# mythlink.sh
# Creates readable symlinks referring to MythTV recordings using the
# mythrename.pl script

### Modify these values for your installation ###

# The path in which the views ("pretty" links) will be created

# The location of the mythrename.pl script
# The default value assumes mythrename.pl is in the user's PATH

### The following directory names and formats may be customized ###

# Formats may be constructed using the format specifiers listed in the
# output of "mythrename.pl --help"

# Files will be sorted "alphabetically" so the appropriate fields on which you
# would like to sort should be placed at the beginning of the format

# To add a custom format, simply include a directory name and format in the
# environment variables below using the syntax shown below.

# The names of the directories containing the views
# The formats used for the respective directories specified above

# The string used to separate sections of the link name

# The string used to replace illegal characters in the filename

# Make the links by calling mythlink.pl with the appropriate arguments
last_index=$(( ${#DIRECTORIES[@]} - 1 ))
for directory in `seq 0 $last_index`; do
  ${COMMAND} --link ${VIEWS_PATH}/${DIRECTORIES[$directory]} \
             --separator $SEPARATOR \
             --replacement $REPLACEMENT \
             --underscores \
             --format ${FORMATS[$directory]}

More information about the mythtv-dev mailing list