Mac-EyeTV

 view release on metacpan or  search on metacpan

lib/Mac/EyeTV.pm  view on Meta::CPAN


    my $start =
      DateTime->from_epoch(epoch => $eyetv_programme->prop("start time")->get);
    my $duration =
      DateTime::Duration->new(
      seconds => $eyetv_programme->prop("duration")->get);
    my $stop = $start + $duration;

    $programme->start($start);
    $programme->stop($stop);

    my %map = (
      'channel_number' => 'channel number',
      'station_name '  => 'station name',
      'input_source'   => 'input source',
      'id'             => 'unique ID',
    );

    foreach my $prop (
      qw(title description channel_number station_name input_source repeats quality enabled id)
      )
    {
      my $eyetv_prop = $map{$prop} || $prop;
      my $value = $eyetv_programme->prop($eyetv_prop)->get;
      $programme->$prop($value);
    }

    push @programmes, $programme;
  }
  return @programmes;
}

sub recordings {
  my $self  = shift;
  my $eyetv = $self->eyetv;
  my @programmes;

  my @eyetv_programmes = $eyetv->obj('recordings')->get;
  foreach my $eyetv_programme (@eyetv_programmes) {
    my $programme = Mac::EyeTV::Recording->new;
    $programme->recording($eyetv_programme);

    my $start =
      DateTime->from_epoch(epoch => $eyetv_programme->prop("start time")->get);
    my $duration =
      DateTime::Duration->new(
      seconds => $eyetv_programme->prop("duration")->get);
    my $stop = $start + $duration;

    $programme->start($start);
    $programme->stop($stop);

    my %map = (
      'channel_number' => 'channel number',
      'station_name '  => 'station name',
      'input_source'   => 'input source',
      'id'             => 'unique ID',
    );

    foreach my $prop (
      qw(title description channel_number station_name input_source repeats quality enabled busy id)
      )
    {
      my $eyetv_prop = $map{$prop} || $prop;
      my $value = $eyetv_programme->prop($eyetv_prop)->get;
      $programme->$prop($value);
    }

    push @programmes, $programme;
  }
  return @programmes;
}

1;

__END__

=head1 NAME

Mac::EyeTV - Interface to the Elgato EyeTV Digital Video Recorder

=head1 SYNOPSIS

  use Mac::EyeTV;
  my $eyetv = Mac::EyeTV->new();

  # See Mac::EyeTV::Channel
  foreach my $channel ($eyetv->channels) {
    my $name   = $channel->name;
    my $number = $channel->number;
    print "$number $name\n";
  }

  # See Mac::EyeTV::Programme
  foreach my $programme ($eyetv->programmes) {
    my $start = $programme->start;
    my $stop  = $programme->stop;
    my $title = $programme->title;
    print "$title $start - $stop\n";
  }

=head1 DESCRIPTION

This module allows you to interface to the Elgato EyeTV Digital Video
Recorder. EyeTV is a piece of software and hardware for Mac OS X which
can record and play back television much like a Tivo. This module
allows you to interface to the EyeTV software, view the channel list
and the recorded programmes and schedule recordings.

See Mac::EyeTV::Programme for information on scheduling a recording.

You should create Mac::Glue bindings to EyeTV before using this
(along the lines of 'sudo gluemac EyeTV').

The EyeTV software itself is available from Elgato Systems at
http://www.elgato.com/index.php?file=support_updates_eyetv

=head1 METHODS

=head2 new



( run in 2.416 seconds using v1.01-cache-2.11-cpan-df04353d9ac )