Opened 14 years ago

Closed 14 years ago

#334 closed patch (fixed)

Update mythlink.pl to work with the new filenames

Reported by: sphery <mtdean@…> Owned by: xris
Priority: minor Milestone: unknown
Component: mythtv Version:
Severity: low Keywords:
Cc: Ticket locked: no

Description

The attached patch updates mythlink.pl to work with the new filename format in use after changeset [7240].

I also moved the block that deletes existing links until after the query was executed and columns were bound. I had heard reports of Samba copies failing on a machine using mythlink.pl in a cron job with the error saying the file does not exist. It seems that when the links were deleted before the query was executed, there was enough of a delay to significantly increase the chance of failure due to bad timing of starts when copying a block of files. I haven't proven that this fixes the problem, but it shouldn't hurt.

I haven't yet started trying to re-incorporate your illegal filename character substitution with positive lookahead. I'll post the improved substitution code in another ticket (probably won't get a chance to work on it until tomorrow).

Attachments (2)

mythtv-mythlink.patch (3.3 KB) - added by sphery <mtdean@…> 14 years ago.
mythtv-mythlink-2.patch (3.3 KB) - added by sphery <mtdean@…> 14 years ago.
Oops. Attached an old version of the patch before. Use this one instead.

Download all attachments as: .zip

Change History (7)

Changed 14 years ago by sphery <mtdean@…>

Attachment: mythtv-mythlink.patch added

Changed 14 years ago by sphery <mtdean@…>

Attachment: mythtv-mythlink-2.patch added

Oops. Attached an old version of the patch before. Use this one instead.

comment:1 Changed 14 years ago by anaerin@…

I've changed my version of mythlink.pl so it works with both (And any future versions) based on the DB changes that have happened. So rather than looking up the details by splitting the filename, it looks up the filename in the DB (As it should).

# Prepare a database query
    $sh = $dbh->prepare('SELECT title, subtitle, description, recgroup, category, originalairdate, date_format(progstart,\'%Y\'), date_format(progstart,\'%m\'), date_format(progstart,\'%d\'), date_format(progstart,\'%H\'), date_format(progstart,\'%i\'), date_format(progstart,\'%S\')), date_format(progend,\'%Y\'), date_format(progend,\'%m\'), date_format(progend,\'%d\'), date_format(progend,\'%H\'), date_format(progend,\'%i\'), date_format(progend,\'%S\'), chanid FROM recorded WHERE basename=?');
# Create symlinks for the files on this machine
    foreach my $file (<$video_dir/*>) {
        next if ($file =~ /^ringbuf/);
    # Pull out the various parts that make up the filename
    #    my ($channel,
    #        $syear, $smonth, $sday, $shour, $sminute, $ssecond,
    #        $eyear, $emonth, $eday, $ehour, $eminute, $esecond) = $file =~/^$video_dir\/([a-z0-9]+)_(....)(..)(..)(..)(..)(..)_(....)(..)(..)(..$
    # Found a bad filename?
    #    unless ($channel) {
    #        print "Unknown filename format:  $file\n";
    #        next;
    #    }
    # Query the desired info about this recording
        $file =~ s/$video_dir\///;
        $sh->execute($file)
            or die "Could not execute ($q):  $!\n\n";
        my ($title, $subtitle, $description, $recgroup, $category, $oad, $syear, $smonth, $sday, $shour, $sminute, $ssecond, $eyear, $emonth, $eday, $ehour, $eminute, $esecond, $channel) = $sh->fetchrow_array;
my $rows = $sh->rows;
        # print "Got $rows, $title, $subtitle, $description, $recgroup, $category, $oad, $syear, $smonth, $sday, $shour, $sminute, $ssecond, $eye$
        if ($rows > 0) {
    # Format some fields we may be parsing below
        # Start time
        my $meridian = ($shour > 12) ? 'AM' : 'PM';
        my $hour = ($shour > 12) ? $shour - 12 : $shour;
        if ($hour < 10) {

And so on...

       }
        symlink "$video_dir/$file", "$dest/$name$suffix"
            or die "Can't create symlink $dest/$name$suffix:  $!\n";
        print "$dest/$name$suffix\n";
        }

This should work a lot better.

The only (other) issue is that it causes some mpg files that were created with the previous version to be labelled as .nuv's, but that's not that major TBH.

comment:2 Changed 14 years ago by tom@…

I like that it deletes existing symlinks, but how about dead links for shows that have been deleted? I manually script it do delete everything first, and then create the new links, but it would be easier to have the original script do it. I could code it up, but it would be ugly...

Tom

comment:3 Changed 14 years ago by anaerin@…

Considering that the script deletes ALL of the symlinks first, *then* re-creates links to the files that *are* there, any files that are deleted are not linked to any longer as their links are deleted along with all the other links.

comment:4 Changed 14 years ago by tom@…

I must have tested it wrong then, I created a file in the directory, then ran the script, and the file I created was still there. I assume (I know, I know) it's smart enough to deal with _real_ dead links then? My apologies.

comment:5 Changed 14 years ago by xris

Resolution: fixed
Status: newclosed

fixed in [7286]

Note: See TracTickets for help on using tickets.