Net-DAAP-Server-MythTV

 view release on metacpan or  search on metacpan

lib/Net/DAAP/Server/MythTV.pm  view on Meta::CPAN

			['dmap.status' => 200],
			['dmap.updatetype' => 0],
			['dmap.specifiedtotalcount' => 1],
			['dmap.returnedcount' => 1],
			['dmap.listing' => [
				['dmap.listingitem' => [
					['dmap.itemid' => 39],
					['dmap.persistentid' => 13950142391337751524],
					['dmap.itemname' => $self->name],
					['com.apple.itunes.smart-playlist' => 0],
					['dmap.itemcount' => $itemcount]]]]]]]]));
}

sub playlist_items {
	my $self = shift;
	my ($request, $response) = @_;

	my $dbh = $self->connect;
	my $sth = $dbh->prepare(
		'SELECT filename, plot, intid, title, year FROM videometadata');
	$sth->execute;

	my $listing = [];
	while (my ($filename, $plot, $intid, $title, $year) =
			$sth->fetchrow_array) {
		# TODO: It would be faster to cache this data in the database
		my @stat = stat $filename;
		push @$listing, ['dmap.listingitem' => [
			['dmap.itemkind' => 2],
			['daap.songcontentdescription' => $plot],
			['dmap.itemid' => $intid],
			['daap.songdescription' => $plot],
			['dmap.itemname' => $title],
			['daap.songsize' => $stat[7]],
			['daap.songyear' => $year],
			['com.apple.itunes.has-video' => 1]]];
	}

	$response->content($self->_dmap_pack([
		['daap.playlistsongs' => [
			['dmap.status' => 200],
			['dmap.updatetype' => 0],
			['dmap.specifiedtotalcount' => scalar @$listing],
			['dmap.returnedcount' => scalar @$listing],
			['dmap.listing' => $listing]]]]));
}

sub database_item {
	my $self = shift;
	my ($request, $response) = @_;

	my ($intid) = ($request->uri->path =~ /^\/databases\/\d+\/items\/(\d+)/);
	my $dbh = $self->connect;
	my $sth = $dbh->prepare(
		'SELECT filename FROM videometadata WHERE intid = ?');
	$sth->execute($intid);

	my ($filename) = $sth->fetchrow_array;
	open $response->{handle}, '<', $filename;

	$response->streaming(1);
}

__END__

=head1 NAME

Net::DAAP::Server::MythTV - Publish MythTV videos to DAAP clients like Apple's Front Row

=head1 DESCRIPTION

MythTV is a homebrew PVR project.  This module publishes MythTV videos, including metadata, to DAAP clients like Apple's Front Row.

=head1 PREREQUISITES

DBI

POE::Component::Server::HTTP

Net::DAAP::DMAP

=head1 AUTHOR

Jack Bates <ms419@freezone.co.uk>

=head1 COPYRIGHT

Copyright 2007, Jack Bates.  All rights reserved.

This program is free software.  You can redistribute it and/or modify it under the same terms as Perl itself.

=head1 SEE ALSO

Net::DAAP::Server - The module on which this module is based

L<MythTV|http://mythtv.org/>



( run in 0.535 second using v1.01-cache-2.11-cpan-39bf76dae61 )