Mythfs-perl

 view release on metacpan or  search on metacpan

lib/Net/MythTV/Fuse/Recordings.pm  view on Meta::CPAN

    peH  => '%H{EndTime}',
    pei  => '%M{EndTime}',
    pes  => '%S{EndTime}',
    pea  => '%P{EndTime}',
    peA  => '%p{EndTime}',
    peb  => '%b{EndTime}',
    peB  => '%B{EndTime}',

    oy   => '%y{Airdate}',
    oY   => '%Y{Airdate}',
    on   => '%m{Airdate}', # we don't do the non-leading 0 bit
    om   => '%m{Airdate}',
    oj   => '%e{Airdate}',
    od   => '%d{Airdate}',
    ob   => '%b{Airdate}',
    oB   => '%B{Airdate}',

    '%'  => '%',

    # special format for Plex server
    PLX => <<'END',
    do {
       my $r = '';
       my $ct = $recording->{CatType};
       if ($ct eq 'series' || $ct eq 'tvshow' || $recording->{Season}) {
          $r .= 'TV Shows/';
          $r .= "$recording->{Title}/";
          if ($recording->{Season}) {
             $r .= "Season $recording->{Season}/";
             $r .= sprintf("%s - s%02de%02d - %s",$recording->{Title},$recording->{Season},$recording->{Episode},$recording->{Airdate});
             $r .= " - $recording->{SubTitle}" if defined $recording->{SubTitle};
          } else {
             my ($heuristic_season) = $recording->{SubTitle} =~ /(?:Season|Series)\s+(\d+)/;
             ($heuristic_season)    = $recording->{Airdate} =~ /^(\d+)/ unless $heuristic_season; # year instead of season
             $heuristic_season    ||= '00';
             $r .= "Season $heuristic_season/$recording->{Title} - $recording->{Airdate}";
             $r .= " - $recording->{SubTitle}" if $recording->{SubTitle};
          }
       } else {
          $r .= 'Movies/';
          my ($yr) = $recording->{Airdate} =~ /^(\d+)/;
          $r .= "$recording->{Title}";
          $r .= " ($yr)" if $yr;
          $r .= "/";
          $r .= "$recording->{Title}";
          $r .= ", $recording->{SubTitle}" if $recording->{SubTitle};
          $r .= " ($yr)" if $yr;
       }
       return $r;
    } 
END

    };

use constant REC_CODES => {
    -13  => "Other recording",
    -12  => "Other tuning",
    -11  => "Backend not running",
    -10  => "The showing is being tuned",
    -9   => "The recorder failed to record",
    -8   => "The tuner card was busy",
    -7   => "Low disk space",
    -6   => "Manual cancel",
    -5   => "Missed recording",
    -4   => "Aborted",
    -3   => "Recorded",
    -2   => "Now recording",
    -1   => "Will record",
    0    => "Unknown status code",
    1    => "Don't record",
    2    => "Previously recorded",
    3    => 'Currently recorded',
    4    => "Earlier showing",
    5    => "Max recordings",
    6    => "Not listed",
    7    => 'Conflict',
    8    => 'Later showing',
    9    => 'Repeat',
    10   => 'Rule inactive',
    11   => 'Never record',
    12   => 'Recorder off-line',
    13   => 'Other showing',
};

my $Package = __PACKAGE__;
foreach (qw(debug backend port dummy_data cache cachetime maxgets threaded
            pattern delimiter mtime localmount semaphore)) {
    eval <<END;
sub ${Package}::${_} {
    my \$self = shift;
    \$self->{$_} = shift if \@_;
    return \$self->{$_};
}
END
}

=head2 $r = Net::MythTV::Fuse::Recordings->new(\%options)

Create a new Recordings object. Options are passed as a hashref and
may contain any of the following keys:

 backend       IP address of the backend (localhost)
 port          Control port for the backend (6544)
 pattern       Template for transforming recordings into paths (%T/%S)
 delimiter     Trim this string from the pathname if it is dangling or occurs multiple times (none)
 cachetime     Maximum time to cache recorded list before refreshing from backend (300 sec)
 maxgets       Maximum number of simultaneous file fetches to perform on backend (8)
 threaded      Run the cache fill process as an ithread (true)
 debug         Turn on debugging messages (false)
 dummy_data_path  For debugging, pass path to backend recording XML listing

See the help text for mythfs.pl for more information on these arguments.

=cut

sub new {
    my $class   = shift;
    my $options = shift;
    $options->{backend} or croak "Usage: $class->new({backend=>\$backend_hostname,\@other_options})";
    
    my $self =  bless {



( run in 0.830 second using v1.01-cache-2.11-cpan-98e64b0badf )