Ticket #3799: mythtv-mythrename_previews.patch

File mythtv-mythrename_previews.patch, 1.4 KB (added by sphery <mtdean@…>, 17 years ago)
  • contrib/mythrename.pl

     
    330331                    $rows = $sh->execute($show->{'basename'}, $show->{'chanid'}, $show->{'recstartts'});
    331332                    die "Couldn't restore original basename in database for ".$show->{'basename'}.":  ($q)\n" unless ($rows == 1);
    332333                }
     334            # Rename previews
     335                my ($dimensions, $current_preview);
     336                my $old_name = $show->{'local_path'};
     337                while (defined($current_preview = <$old_name*.png>)) {
     338                    $current_preview =~ /$show->{'local_path'}(\..*)?\.png/;
     339                    $dimensions = $1 || '';
     340                    $ret = rename $current_preview, "$video_dir/$name$dimensions.png";
     341                    # If the rename fails, try to delete the preview from the
     342                    # cache (it will automatically be re-created with the
     343                    # proper name, when necessary)
     344                    if (!$ret) {
     345                        unlink $current_preview or
     346                        vprint("Unable to rename preview image: $current_preview.");
     347                    }
     348                }
    333349                vprint($show->{'basename'}."\t-> $name");
    334350            }
    335351        }