Mac::EyeTV::Programme - An EyeTV programme


Mac-EyeTV documentation Contained in the Mac-EyeTV distribution.

Index


Code Index:

NAME

Top

Mac::EyeTV::Programme - An EyeTV programme

SYNOPSIS

Top

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

  # Examine existing programmes
  foreach my $programme ($eyetv->programmes) {
    my $start       = $programme->start;
    my $stop        = $programme->stop;
    my $title       = $programme->title;
    my $description = $programme->description;

    print "$title $start - $stop ($description)\n";
  }

  # Record a new programme
  my $programme = Mac::EyeTV::Programme->new;
  $programme->start($start_dt);
  $programme->stop($stop_dt);
  $programme->title($title);
  $programme->description($description);
  $programme->channel_number($channel_number);
  $programme->record;

  # Delete an existing programme
  $programme->delete;

DESCRIPTION

Top

This module represents an EyeTV program. The programmes() method in Mac::EyeTV returns a list of Mac::EyeTV::Programme objects which represent the existing and future programs.

METHODS

Top

new

This is the constructor, which takes no arguments:

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

delete

The delete() method deletes the programme:

  $programme->delete;

description

The description() method returns the description of the programme:

  my $description = $programme->description;

duration

The duration() method returns the duration of the programme (as a DateTime::Duration object):

  my $duration = $programme->duration;

record

The record method schedules a new recording:

  # Record a new program
  my $programme = Mac::EyeTV::Programme->new;
  $programme->start($start_dt);
  $programme->stop($stop_dt);
  $programme->title($title);
  $programme->description($description);
  $programme->channel_number($channel_number);
  $programme->record;

start

The start method returns when the programme starts (as a DateTime object):

  my $start = $programme->start;

stop

The stop method returns when the programme stops (as a DateTime object):

  my $stop = $programme->stop;

title

The title() method returns the title of the programme:

  my $title = $programme->title;

AUTHOR

Top

Leon Brocard <acme@astray.com>.

COPYRIGHT

Top


Mac-EyeTV documentation Contained in the Mac-EyeTV distribution.

package Mac::EyeTV::Programme;
use strict;
use warnings;
use DateTime;
use DateTime::Format::Strptime;
use base qw(Class::Accessor::Fast);

__PACKAGE__->mk_accessors(
  qw(programme start stop title
    description channel_number station_name input_source repeats quality
    enabled id)
);

sub delete {
  my $self = shift;
  $self->programme->delete;
}

sub duration {
  my $self = shift;
  return $self->stop - $self->start;
}

sub record {
  my $self = shift;

  my $start          = $self->start;
  my $stop           = $self->stop;
  my $title          = $self->title;
  my $description    = $self->description || "";
  my $channel_number = $self->channel_number;
  my $duration       = ($stop->epoch - $start->epoch);

  my $eyetv = Mac::Glue->new('EyeTV');
  $eyetv->make(
    new             => 'program',
    with_properties => {
      'start time'     => $start->epoch,
      duration         => $duration,
      title            => $title,
      description      => $description,
      'channel number' => $channel_number,
    },
  );
}

1;

__END__