summaryrefslogtreecommitdiffstats
path: root/abs/extra-testing/myth2ipod
diff options
context:
space:
mode:
authorJames Meyer <james.meyer@operamail.com>2008-11-08 17:08:28 (GMT)
committerJames Meyer <james.meyer@operamail.com>2008-11-08 17:08:28 (GMT)
commitc38715641e214272ad7dc6d495edd29940366e7f (patch)
tree9dcd507543e67458d98fa7462f62026041524047 /abs/extra-testing/myth2ipod
parent3d91b06198a56b6579cb0bd77de65f5908571b87 (diff)
downloadlinhes_pkgbuild-c38715641e214272ad7dc6d495edd29940366e7f.zip
linhes_pkgbuild-c38715641e214272ad7dc6d495edd29940366e7f.tar.gz
linhes_pkgbuild-c38715641e214272ad7dc6d495edd29940366e7f.tar.bz2
packages that will be needed in the future.
This is the initial merge of packages from MythVantage that are not MythVantage specific.
Diffstat (limited to 'abs/extra-testing/myth2ipod')
-rwxr-xr-xabs/extra-testing/myth2ipod/PKGBUILD20
-rwxr-xr-xabs/extra-testing/myth2ipod/iPod.pm184
-rwxr-xr-xabs/extra-testing/myth2ipod/myth2ipod-userjob.sh6
-rwxr-xr-xabs/extra-testing/myth2ipod/myth2ipod.install41
-rwxr-xr-xabs/extra-testing/myth2ipod/myth2ipod.patch35
-rwxr-xr-xabs/extra-testing/myth2ipod/myth2ipod.txt310
-rwxr-xr-xabs/extra-testing/myth2ipod/myth2ipod.txt.modified310
7 files changed, 906 insertions, 0 deletions
diff --git a/abs/extra-testing/myth2ipod/PKGBUILD b/abs/extra-testing/myth2ipod/PKGBUILD
new file mode 100755
index 0000000..ea55613
--- /dev/null
+++ b/abs/extra-testing/myth2ipod/PKGBUILD
@@ -0,0 +1,20 @@
+pkgname=myth2ipod
+pkgver=0.2
+pkgrel=15
+arch=("i686")
+pkgdesc="A multimedia framework based on the MPEG-4 Systems standard"
+url="myth2ipod.com"
+depends=('gpac' 'nuvexport' )
+install="myth2ipod.install"
+source=( http://myth2ipod.com/myth2ipod.txt http://myth2ipod.com/iPod.pm myth2ipod.patch myth2ipod-userjob.sh)
+
+
+build() {
+ cd $startdir/src
+ patch -p0 < myth2ipod.patch
+ install -D -m 755 myth2ipod.txt $startdir/pkg/usr/bin/myth2ipod
+ install -D -m 755 myth2ipod-userjob.sh /$startdir/pkg/usr/bin/myth2ipod-userjob.sh
+ install -D -m755 iPod.pm $startdir/pkg/usr/local/share/nuvexport/export/ffmpeg/iPod.pm
+
+
+}
diff --git a/abs/extra-testing/myth2ipod/iPod.pm b/abs/extra-testing/myth2ipod/iPod.pm
new file mode 100755
index 0000000..24eae99
--- /dev/null
+++ b/abs/extra-testing/myth2ipod/iPod.pm
@@ -0,0 +1,184 @@
+#
+# $Date: 2006-01-18 00:15:31 -0800 (Wed, 18 Jan 2006) $
+# $Revision: 226 $
+# $Author: xris $
+#
+# export::ffmpeg::iPod
+#
+
+package export::ffmpeg::iPod;
+ use base 'export::ffmpeg';
+
+# Load the myth and nuv utilities, and make sure we're connected to the database
+ use nuv_export::shared_utils;
+ use nuv_export::cli;
+ use nuv_export::ui;
+ use mythtv::db;
+ use mythtv::recordings;
+
+# Load the following extra parameters from the commandline
+ add_arg('quantisation|q=i', 'Quantisation');
+ add_arg('a_bitrate|a=i', 'Audio bitrate');
+ add_arg('v_bitrate|v=i', 'Video bitrate');
+ add_arg('multipass!', 'Enably two-pass encoding.');
+
+ sub new {
+ my $class = shift;
+ my $self = {
+ 'cli' => qr/\bipod\b/i,
+ 'name' => 'Export to iPod',
+ 'enabled' => 1,
+ 'errors' => [],
+ 'defaults' => {},
+ };
+ bless($self, $class);
+
+ # Initialize the default parameters
+ $self->load_defaults();
+
+ # Verify any commandline or config file options
+ die "Audio bitrate must be > 0\n" unless (!defined $self->val('a_bitrate') || $self->{'a_bitrate'} > 0);
+ die "Video bitrate must be > 0\n" unless (!defined $self->val('v_bitrate') || $self->{'v_bitrate'} > 0);
+
+ # VBR, multipass, etc.
+ if ($self->val('multipass')) {
+ $self->{'vbr'} = 0;
+ }
+ elsif ($self->val('quantisation')) {
+ die "Quantisation must be a number between 1 and 31 (lower means better quality).\n" if ($self->{'quantisation'} < 1 || $self->{'quantisation'} > 31);
+ $self->{'vbr'} = 1;
+ }
+
+ # Initialize and check for ffmpeg
+ $self->init_ffmpeg();
+
+ # Can we even encode ipod?
+ # if (!$self->can_encode('mov')) {
+ # push @{$self->{'errors'}}, "Your ffmpeg installation doesn't support encoding to mov file formats.";
+ # }
+ if (!$self->can_encode('xvid')) {
+ push @{$self->{'errors'}}, "Your ffmpeg installation doesn't support encoding to xvid video.";
+ }
+ if (!$self->can_encode('aac')) {
+ push @{$self->{'errors'}}, "Your ffmpeg installation doesn't support encoding to aac audio.";
+ }
+ # Any errors? disable this function
+ $self->{'enabled'} = 0 if ($self->{'errors'} && @{$self->{'errors'}} > 0);
+ # Return
+ return $self;
+ }
+
+# Load default settings
+ sub load_defaults {
+ my $self = shift;
+ # Load the parent module's settings
+ $self->SUPER::load_defaults();
+ # Default bitrates
+ $self->{'defaults'}{'v_bitrate'} = 384;
+ $self->{'defaults'}{'a_bitrate'} = 64;
+ }
+
+# Gather settings from the user
+ sub gather_settings {
+ my $self = shift;
+ # Load the parent module's settings
+ $self->SUPER::gather_settings();
+ # Audio Bitrate
+ $self->{'a_bitrate'} = query_text('Audio bitrate?',
+ 'int',
+ $self->val('a_bitrate'));
+ # VBR options
+ if (!$is_cli) {
+ $self->{'vbr'} = query_text('Variable bitrate video?',
+ 'yesno',
+ $self->val('vbr'));
+ if ($self->{'vbr'}) {
+ $self->{'multipass'} = query_text('Multi-pass (slower, but better quality)?',
+ 'yesno',
+ $self->val('multipass'));
+ if (!$self->{'multipass'}) {
+ while (1) {
+ my $quantisation = query_text('VBR quality/quantisation (1-31)?',
+ 'float',
+ $self->val('quantisation'));
+ if ($quantisation < 1) {
+ print "Too low; please choose a number between 1 and 31.\n";
+ }
+ elsif ($quantisation > 31) {
+ print "Too high; please choose a number between 1 and 31\n";
+ }
+ else {
+ $self->{'quantisation'} = $quantisation;
+ last;
+ }
+ }
+ }
+ } else {
+ $self->{'multipass'} = 0;
+ }
+ # Ask the user what video bitrate he/she wants
+ $self->{'v_bitrate'} = query_text('Video bitrate?',
+ 'int',
+ $self->val('v_bitrate'));
+ }
+ }
+
+ sub export {
+ my $self = shift;
+ my $episode = shift;
+ # Force to 4:3 aspect ratio
+ $self->{'out_aspect'} = 1.3333;
+ $self->{'aspect_stretched'} = 1;
+ # PAL or NTSC?
+ my $standard = ($episode->{'finfo'}{'fps'} =~ /^2(?:5|4\.9)/) ? 'PAL' : 'NTSC';
+ $self->{'width'} = 320;
+ $self->{'height'} = ($standard eq 'PAL') ? '288' : '240';
+ $self->{'out_fps'} = ($standard eq 'PAL') ? 25 : 29.97;
+ # Embed the title
+ my $safe_title = shell_escape($episode->{'show_name'}.' - '.$episode->{'title'});
+ # Dual pass?
+ if ($self->{'multipass'}) {
+ # Build the common ffmpeg string
+ my $ffmpeg_xtra = ' -b ' . $self->{'v_bitrate'}
+ .' -bufsize 65535'
+ .' -vcodec xvid -acodec aac '
+ .' -ab ' . $self->{'a_bitrate'}
+ ." -f mp4 -title $safe_title";
+ # Add the temporary file to the list
+ push @tmpfiles, "/tmp/xvid.$$.log";
+ # Back up the path and use /dev/null for the first pass
+ my $path_bak = $self->{'path'};
+ $self->{'path'} = '/dev/null';
+ # Build the ffmpeg string
+ print "First pass...\n";
+ $self->{'ffmpeg_xtra'} = " -pass 1 -passlogfile '/tmp/divx.$$.log'"
+ .$ffmpeg_xtra;
+ $self->SUPER::export($episode, '');
+ # Restore the path
+ $self->{'path'} = $path_bak;
+ # Second Pass
+ print "Final pass...\n";
+ $self->{'ffmpeg_xtra'} = " -pass 2 -passlogfile '/tmp/divx.$$.log'"
+ .$ffmpeg_xtra;
+ }
+ # Single Pass
+ else {
+ $self->{'ffmpeg_xtra'} = ' -b ' . $self->{'v_bitrate'}
+ .(($self->{'vbr'})
+ ? ' -qmin '.$self->{'quantisation'}
+ .' -qmax 31 -minrate 32'
+ .' -maxrate '.(2*$self->{'v_bitrate'})
+ .' -bt 32'
+ : '')
+ .' -vcodec xvid -acodec aac '
+ .' -ab ' . $self->{'a_bitrate'}
+ ." -f mp4 -title $safe_title";
+ }
+ # Execute the (final pass) encode
+ $self->SUPER::export($episode, '.mp4');
+ }
+
+1; #return true
+
+# vim:ts=4:sw=4:ai:et:si:sts=4
+
diff --git a/abs/extra-testing/myth2ipod/myth2ipod-userjob.sh b/abs/extra-testing/myth2ipod/myth2ipod-userjob.sh
new file mode 100755
index 0000000..9ed65b2
--- /dev/null
+++ b/abs/extra-testing/myth2ipod/myth2ipod-userjob.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+. /etc/profile
+#su mythtv -c "TERM=vt100 /usr/bin/myth2ipod "$1" "$2" >/tmp/logfile"
+su mythtv -c "TERM=vt100 /usr/bin/myth2ipod "$1" "$2" "
+#or to also use commercial flagging cutlist
+#su mythtv -c "TERM=vt100 /usr/bin/myth2ipod -cut "$1" "$2" >/tmp/logfile"
diff --git a/abs/extra-testing/myth2ipod/myth2ipod.install b/abs/extra-testing/myth2ipod/myth2ipod.install
new file mode 100755
index 0000000..a1c1ce7
--- /dev/null
+++ b/abs/extra-testing/myth2ipod/myth2ipod.install
@@ -0,0 +1,41 @@
+
+pre_install() {
+ echo ""
+}
+
+pre_upgrade() {
+ pre_install
+}
+
+pre_remove() {
+ pre_install
+}
+
+post_install() {
+ . /etc/systemconfig
+ mkdir /data/media/ipodfeed
+ chown mythtv:users /data/media/ipodfeed
+ ln -s /data/media/ipodfeed /data/srv/httpd/htdocs/ipodfeed
+ cp /usr/bin/myth2ipod /tmp
+ sed -e "s/REPLACEME/$hostname/g" /tmp/myth2ipod > /usr/bin/myth2ipod
+
+
+}
+
+post_upgrade() {
+
+
+ mkdir /data/media/ipodfeed
+ chown mythtv:users /data/media/ipodfeed
+ ln -s /data/media/ipodfeed /data/srv/httpd/htdocs/ipodfeed
+ /usr/bin/myth2ipod -rebuild
+}
+
+post_remove() {
+ post_install
+}
+
+op=$1
+shift
+
+$op $* \ No newline at end of file
diff --git a/abs/extra-testing/myth2ipod/myth2ipod.patch b/abs/extra-testing/myth2ipod/myth2ipod.patch
new file mode 100755
index 0000000..95785ab
--- /dev/null
+++ b/abs/extra-testing/myth2ipod/myth2ipod.patch
@@ -0,0 +1,35 @@
+--- myth2ipod.txt 2007-06-01 10:00:02.000000000 -0500
++++ myth2ipod.txt.modified 2007-06-01 11:24:26.000000000 -0500
+@@ -12,10 +12,10 @@
+
+ # User variables
+ my $portable = "ipod";
+- my $feedfile = "/myth/ipodfeed/feed.php";
+- my $feedpath = "/myth/ipodfeed/";
+- my $wwwloc = "/var/www/";
+- my $feedurl = "http://hostname/ipodfeed/";
++ my $feedfile = "/data/media/ipodfeed/feed.php";
++ my $feedpath = "/data/media/ipodfeed/";
++ my $wwwloc = "/data/srv/httpd/htdocs/";
++ my $feedurl = "http://REPLACEME/ipodfeed/";
+ my $nuvoptions ="--mode=iPod --nice=19 --cutlist --nodenoise --nodeinterlace --nomultipass";
+
+ # Some variables
+@@ -136,7 +136,7 @@
+ # Create cutlist from commercial flagging if -cut was passed to the script
+ if ($cut == 1){
+ printf("Generating cutlist\n");
+- $cmd = "/usr/bin/mythcommflag --chanid $chanid --starttime $start --gencutlist";
++ $cmd = "/usr/local/bin/mythcommflag --chanid $chanid --starttime $start --gencutlist";
+ print $cmd."\n";
+ if(system($cmd)) { print "It looks like I was not able to generate a cutlist.\n"; }
+ }
+@@ -147,7 +147,7 @@
+ if(system($cmd)) { print "Nuvexport encoding seems to have failed\n"; }
+
+ # Now clean up the output so iPods with firmware 1.1 and above can use it
+- $cmd = "/usr/local/bin/MP4Box -add $feedpath$chanid\_$start.temp.mp4 $feedpath$chanid\_$start.$portable.mp4";
++ $cmd = "/usr/bin/MP4Box -add $feedpath$chanid\_$start.temp.mp4 $feedpath$chanid\_$start.$portable.mp4";
+ print $cmd."\n";
+ if(system($cmd)) { print "MP4Box cleanup seems to have failed\n"; }
+ return 0;
diff --git a/abs/extra-testing/myth2ipod/myth2ipod.txt b/abs/extra-testing/myth2ipod/myth2ipod.txt
new file mode 100755
index 0000000..d3d0dab
--- /dev/null
+++ b/abs/extra-testing/myth2ipod/myth2ipod.txt
@@ -0,0 +1,310 @@
+#!/usr/bin/perl -w
+# VERSION: 1.0b2 - myth2ipod
+# Get the latest version, and change log at myth2ipod.com
+# Author: Chris aka Wififun - email: wififun@myth2ipod.com
+# Contributions and testing by Paul Egli
+# modified to use nuvexport by starv at juniks dot org
+
+# Includes
+ use DBI;
+ use Getopt::Long;
+ use File::Path;
+
+# User variables
+ my $portable = "ipod";
+ my $feedfile = "/myth/ipodfeed/feed.php";
+ my $feedpath = "/myth/ipodfeed/";
+ my $wwwloc = "/var/www/";
+ my $feedurl = "http://hostname/ipodfeed/";
+ my $nuvoptions ="--mode=iPod --nice=19 --cutlist --nodenoise --nodeinterlace --nomultipass";
+
+# Some variables
+ our ($dest, $format, $usage);
+ our ($db_host, $db_user, $db_name, $db_pass, $video_dir);
+ our ($hostname, $db_handle, $sql, $statement, $row_ref);
+ our ($chanid, $start, $nuvfile, @nuvarray);
+ my $rebuild = '0';
+ my $encode = '0';
+ my $debug = '0';
+ my $setup = '0';
+ my $cut = '0';
+ my( $rightnow ) = `date`;
+
+GetOptions ("rebuild" => \$rebuild,
+ "encode" => \$encode,
+ "debug" => \$debug,
+ "setup" => \$setup,
+ "cut" => \$cut);
+
+if ($setup == 1){
+ system("clear");
+ print "Setup will do everything needed to run this script.\n";
+ print "This has only been tested on KnoppMyth R5A22.\n";
+ print "make sure you have edited the variables for your conguration.\n";
+ my $cksetup = &promptUser("\nAre you sure you want to procceed?","n");
+ if ($cksetup =~ "y") {
+ DoSetup();
+ exit;
+ }
+ print "Setup exited. Nothing done.\n";
+ exit;
+}
+elsif ($rebuild == 1){
+ GenerateRSSFeed();
+ print "Rebuilding of RSS feed is complete.\n";
+ exit;
+}
+else {
+ Encode4Portable();
+ print "$title is ready for your $portable\n";
+
+ # Check to see if the feed file exists; if not, create it.
+ if (! -e $feedfile) {
+ print "No feed file found. I will make one for you.\n";
+ GenerateRSSFeed();
+ print "All done.\n";
+ }
+}
+
+sub Encode4Portable{
+ if ($#ARGV != 1) {
+ print "Encoding requires options.\nusage: myth2ipod <options> DIRECTORY FILE\n";
+ exit;
+ }
+
+ # Get the show information
+ $directory = $ARGV[0];
+ $file = $ARGV[1];
+ @file = split(/_/, $file);
+ $chanid = $file[0];
+ $start = substr $file[1],0,14;
+ if($debug == 1){ print "$chanid\n$start\n"};
+ if (! -e $directory."/".$file){
+ print "Opps, the file ".$directory.$file." does not exist.\n";
+ exit;
+ }
+
+ # Connect to the database
+ PrepSQLRead();
+ $db_handle = DBI->connect("dbi:mysql:database=$db_name:host=$db_host", $db_user, $db_pass)
+ or die "Cannot connect to database: $!\n\n";
+ $sql = "SELECT title, subtitle, description, category, starttime FROM recorded WHERE chanid = $chanid AND DATE_FORMAT(starttime,'%Y%m%d%H%i%s') = $start";
+
+ $statement = $db_handle->prepare($sql)
+ or die "Couldn't prepare query '$sql': $DBI::errstr\n";
+
+ $statement->execute()
+ or die "Couldn't execute query '$sql': $DBI::errstr\n";
+ $row_ref = $statement->fetchrow_hashref();
+ if($debug == 1){ print "$row_ref->{starttime}\n"};
+ $title = $row_ref->{title};
+ $subtitle = $row_ref->{subtitle};
+ $recorddate = $row_ref->{starttime};
+ $description = $row_ref->{description};
+ $category = $row_ref->{category};
+ $filename = $title."-".$subtitle."-".substr $start, 0, 8;
+ $filename =~ s/ /_/g;
+ $filename =~ s/&/+/g;
+ $filename =~ s/\047//g;
+ $filename =~ s/[^+0-9a-zA-Z_-]+/_/g;
+ $filename =~ s/_$//g;
+
+ printf("Starting nuvexport...\n");
+ EncodeIt();
+ printf("Nuvexport completed, starting xml generation...\n");
+ CreateItemXML();
+ printf("XML file created for \"$filename\" : Yipeee\n");
+ printf("Cleaning up temporary files\n");
+ $cmd = "rm -f $feedpath$chanid\_$start.temp.mp4";
+ print $cmd."\n";
+ if(system($cmd)) { print "Removing nuvexport temp file failed\n"; }
+
+ # remove the cutlist incase we added it.
+ if ($cut == 1){
+ printf("Generating cutlist\n");
+ $cmd = "/usr/bin/mythcommflag --chanid $chanid --starttime $start --clearcutlist";
+ print $cmd."\n";
+ if(system($cmd)) { print "It looks like I was not able to generate a cutlist.\n"; }
+ }
+ return 0;
+}
+
+#
+# Encode for Portable
+#
+sub EncodeIt {
+ # Create cutlist from commercial flagging if -cut was passed to the script
+ if ($cut == 1){
+ printf("Generating cutlist\n");
+ $cmd = "/usr/bin/mythcommflag --chanid $chanid --starttime $start --gencutlist";
+ print $cmd."\n";
+ if(system($cmd)) { print "It looks like I was not able to generate a cutlist.\n"; }
+ }
+
+ # Use nuvexport to do the work
+ $cmd = "/usr/local/bin/nuvexport --chanid=$chanid --start=$start $nuvoptions --filename=$chanid\_$start.temp --path=$feedpath";
+ print $cmd."\n";
+ if(system($cmd)) { print "Nuvexport encoding seems to have failed\n"; }
+
+ # Now clean up the output so iPods with firmware 1.1 and above can use it
+ $cmd = "/usr/local/bin/MP4Box -add $feedpath$chanid\_$start.temp.mp4 $feedpath$chanid\_$start.$portable.mp4";
+ print $cmd."\n";
+ if(system($cmd)) { print "MP4Box cleanup seems to have failed\n"; }
+ return 0;
+}
+
+#
+# Create XML with <ITEM> tag for this video file
+#
+sub CreateItemXML {
+ open(ITEM, ">$feedpath$chanid\_$start.$portable.xml");
+ print ITEM "<item>\n";
+ print ITEM "<title>".&encodeForXML($title." - ".$subtitle)."</title>\n";
+ print ITEM "<itunes:author>MythTV</itunes:author>\n";
+ print ITEM "<author>MythTV</author>\n";
+ print ITEM "<itunes:category text=\"TV Shows\"></itunes:category>\n";
+ print ITEM "<comments>".&encodeForXML($file)."</comments>\n";
+ print ITEM "<description>".&encodeForXML($description)."</description>\n";
+ print ITEM "<pubDate>".$recorddate."</pubDate>\n";
+ print ITEM "<enclosure url=\"".&encodeForXML("$feedurl$chanid\_$start.$portable.mp4")."\" type=\"video/quicktime\" />\n";
+ print ITEM "<itunes:duration></itunes:duration>\n";
+ print ITEM "<itunes:keywords>".&encodeForXML($title." - ".$subtitle." - ".$category)."</itunes:keywords>\n";
+ print ITEM "<category>".&encodeForXML($category)."</category>\n";
+ print ITEM "</item>\n";
+ print "\"$filename\" has been added to the feed.\n";
+ close(ITEM);
+ return 0;
+}
+
+#
+# Generate the RSS feed by combining the ITEM XML Files
+#
+sub GenerateRSSFeed {
+
+ open(RSS, ">$feedfile");
+ print RSS "<?php\n";
+ print RSS "header(\"Content-Type: text/xml\");\n";
+ print RSS "echo \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\"; ?>\n";
+ print RSS "<rss xmlns:itunes=\"http://www.itunes.com/DTDs/Podcast-1.0.dtd\" version=\"2.0\">\n";
+ print RSS "<channel>\n";
+ print RSS "<title>MythTV - <? if (\$_GET['title'] == \"\") { \$title = \"*\"; echo \"Recorded Programs\"; }\n";
+ print RSS "else { \$title = \$_GET['title']; echo str_replace(\"_\",\" \",\$_GET['title']); } ?> </title>\n";
+ print RSS "<itunes:author>MythTV - myth2ipod</itunes:author>\n";
+ print RSS "<link>".&encodeForXML($feedurl)."</link>\n";
+ print RSS "<itunes:subtitle>Transcoded recording for your iPod Video.</itunes:subtitle>\n";
+ print RSS "<itunes:summary>Myth TV Recorded Programs for the iPod v.1</itunes:summary>\n";
+ print RSS "<description>Myth TV Recorded Programs for the iPod v.1</description>\n";
+ print RSS "<itunes:owner>\n";
+ print RSS "<itunes:name>MythTV</itunes:name>\n";
+ print RSS "<itunes:email>mythtv\@localhost</itunes:email>\n";
+ print RSS "</itunes:owner>\n";
+ print RSS "<itunes:explicit>No</itunes:explicit>\n";
+ print RSS "<language>en-us</language>\n";
+ print RSS "<copyright>Copyright 2005.</copyright>\n";
+ print RSS "<webMaster>mythtv\@localhost</webMaster>\n";
+ print RSS "<itunes:image href=\"http://myth2ipod.com/mythipod_200.jpg\" />\n";
+ print RSS "<itunes:category text=\"TV Shows\"></itunes:category>\n";
+ print RSS "<category>TV Shows</category>\n";
+ print RSS "<itunes:image href=\"http://myth2ipod.com/mythipod_200.jpg\"/>";
+ print RSS "<image>";
+ print RSS "<url>http://myth2ipod.com/mythipod_200.jpg</url>\n";
+ print RSS "<title>MythTV 2 iPod</title>\n";
+ print RSS "<link>".&encodeForXML($feedurl)."</link>\n";
+ print RSS "<width>200</width>\n";
+ print RSS "<height>200</height>\n";
+ print RSS "</image>\n";
+ print RSS "<? foreach (glob(\$title\.\"*\.$portable\.xml\") as \$file) {include \$file;} ?>\n";
+ print RSS "</channel>\n";
+ print RSS "</rss>\n";
+ close(RSS);
+ if($debug == 1){ print "I created a feed file, was I supposed to?\n"};
+
+ return 0;
+}
+
+# substitute for XML entities
+sub encodeForXML {
+ local $result;
+ $result = $_[0];
+ $result =~ s/&/&amp;/g;
+ $result =~ s/</&lt;/g;
+ $result =~ s/>/&gt;/g;
+ $result;
+}
+
+
+#
+# This code taken from one of the mythlink.sh scripts to get MySQL information
+#
+sub PrepSQLRead{
+# Get the hostname of this machine
+ $hostname = `hostname`;
+ chomp($hostname);
+
+# Read the mysql.txt file in use by MythTV.
+# could be in a couple places, so try the usual suspects
+ my $found = 0;
+ my @mysql = ('/usr/local/share/mythtv/mysql.txt',
+ '/usr/share/mythtv/mysql.txt',
+ '/etc/mythtv/mysql.txt',
+ '/usr/local/etc/mythtv/mysql.txt',
+ "$ENV{HOME}/.mythtv/mysql.txt",
+ 'mysql.txt'
+ );
+ foreach my $file (@mysql) {
+ next unless (-e $file);
+ $found = 1;
+ open(CONF, $file) or die "Unable to open $file: $!\n\n";
+ while (my $line = <CONF>) {
+ # Cleanup
+ next if ($line =~ /^\s*#/);
+ $line =~ s/^str //;
+ chomp($line);
+ # Split off the var=val pairs
+ my ($var, $val) = split(/\=/, $line, 2);
+ next unless ($var && $var =~ /\w/);
+ if ($var eq 'DBHostName') {
+ $db_host = $val;
+ }
+ elsif ($var eq 'DBUserName') {
+ $db_user = $val;
+ }
+ elsif ($var eq 'DBName') {
+ $db_name = $val;
+ }
+ elsif ($var eq 'DBPassword') {
+ $db_pass = $val;
+ }
+ # Hostname override
+ elsif ($var eq 'LocalHostName') {
+ $hostname = $val;
+ }
+ }
+ close CONF;
+ }
+ die "Unable to locate mysql.txt: $!\n\n" unless ($found && $db_host);
+ return 0;
+}
+
+sub promptUser {
+ local($promptString,$defaultValue) = @_;
+ if ($defaultValue) {
+ print $promptString, "[", $defaultValue, "]: ";
+ } else {
+ print $promptString, ": ";
+ }
+
+ $| = 1; # force a flush after our print
+ $_ = <STDIN>; # get the input from STDIN (presumably the keyboard)
+ chomp;
+ if ("$defaultValue") {
+ return $_ ? $_ : $defaultValue; # return $_ if it has a value
+ } else {
+ return $_;
+ }
+}
+
+sub DoSetup {
+ print "\nNot ready yet. How do you send the cd command from perl?\n";
+ return 0;
+}
diff --git a/abs/extra-testing/myth2ipod/myth2ipod.txt.modified b/abs/extra-testing/myth2ipod/myth2ipod.txt.modified
new file mode 100755
index 0000000..ab41a2f
--- /dev/null
+++ b/abs/extra-testing/myth2ipod/myth2ipod.txt.modified
@@ -0,0 +1,310 @@
+#!/usr/bin/perl -w
+# VERSION: 1.0b2 - myth2ipod
+# Get the latest version, and change log at myth2ipod.com
+# Author: Chris aka Wififun - email: wififun@myth2ipod.com
+# Contributions and testing by Paul Egli
+# modified to use nuvexport by starv at juniks dot org
+
+# Includes
+ use DBI;
+ use Getopt::Long;
+ use File::Path;
+
+# User variables
+ my $portable = "ipod";
+ my $feedfile = "/data/media/feed.php";
+ my $feedpath = "/data/media/";
+ my $wwwloc = "/data/srv/httpd/htdocs/";
+ my $feedurl = "http://REPLACEME/ipodfeed/";
+ my $nuvoptions ="--mode=iPod --nice=19 --cutlist --nodenoise --nodeinterlace --nomultipass";
+
+# Some variables
+ our ($dest, $format, $usage);
+ our ($db_host, $db_user, $db_name, $db_pass, $video_dir);
+ our ($hostname, $db_handle, $sql, $statement, $row_ref);
+ our ($chanid, $start, $nuvfile, @nuvarray);
+ my $rebuild = '0';
+ my $encode = '0';
+ my $debug = '0';
+ my $setup = '0';
+ my $cut = '0';
+ my( $rightnow ) = `date`;
+
+GetOptions ("rebuild" => \$rebuild,
+ "encode" => \$encode,
+ "debug" => \$debug,
+ "setup" => \$setup,
+ "cut" => \$cut);
+
+if ($setup == 1){
+ system("clear");
+ print "Setup will do everything needed to run this script.\n";
+ print "This has only been tested on KnoppMyth R5A22.\n";
+ print "make sure you have edited the variables for your conguration.\n";
+ my $cksetup = &promptUser("\nAre you sure you want to procceed?","n");
+ if ($cksetup =~ "y") {
+ DoSetup();
+ exit;
+ }
+ print "Setup exited. Nothing done.\n";
+ exit;
+}
+elsif ($rebuild == 1){
+ GenerateRSSFeed();
+ print "Rebuilding of RSS feed is complete.\n";
+ exit;
+}
+else {
+ Encode4Portable();
+ print "$title is ready for your $portable\n";
+
+ # Check to see if the feed file exists; if not, create it.
+ if (! -e $feedfile) {
+ print "No feed file found. I will make one for you.\n";
+ GenerateRSSFeed();
+ print "All done.\n";
+ }
+}
+
+sub Encode4Portable{
+ if ($#ARGV != 1) {
+ print "Encoding requires options.\nusage: myth2ipod <options> DIRECTORY FILE\n";
+ exit;
+ }
+
+ # Get the show information
+ $directory = $ARGV[0];
+ $file = $ARGV[1];
+ @file = split(/_/, $file);
+ $chanid = $file[0];
+ $start = substr $file[1],0,14;
+ if($debug == 1){ print "$chanid\n$start\n"};
+ if (! -e $directory."/".$file){
+ print "Opps, the file ".$directory.$file." does not exist.\n";
+ exit;
+ }
+
+ # Connect to the database
+ PrepSQLRead();
+ $db_handle = DBI->connect("dbi:mysql:database=$db_name:host=$db_host", $db_user, $db_pass)
+ or die "Cannot connect to database: $!\n\n";
+ $sql = "SELECT title, subtitle, description, category, starttime FROM recorded WHERE chanid = $chanid AND DATE_FORMAT(starttime,'%Y%m%d%H%i%s') = $start";
+
+ $statement = $db_handle->prepare($sql)
+ or die "Couldn't prepare query '$sql': $DBI::errstr\n";
+
+ $statement->execute()
+ or die "Couldn't execute query '$sql': $DBI::errstr\n";
+ $row_ref = $statement->fetchrow_hashref();
+ if($debug == 1){ print "$row_ref->{starttime}\n"};
+ $title = $row_ref->{title};
+ $subtitle = $row_ref->{subtitle};
+ $recorddate = $row_ref->{starttime};
+ $description = $row_ref->{description};
+ $category = $row_ref->{category};
+ $filename = $title."-".$subtitle."-".substr $start, 0, 8;
+ $filename =~ s/ /_/g;
+ $filename =~ s/&/+/g;
+ $filename =~ s/\047//g;
+ $filename =~ s/[^+0-9a-zA-Z_-]+/_/g;
+ $filename =~ s/_$//g;
+
+ printf("Starting nuvexport...\n");
+ EncodeIt();
+ printf("Nuvexport completed, starting xml generation...\n");
+ CreateItemXML();
+ printf("XML file created for \"$filename\" : Yipeee\n");
+ printf("Cleaning up temporary files\n");
+ $cmd = "rm -f $feedpath$chanid\_$start.temp.mp4";
+ print $cmd."\n";
+ if(system($cmd)) { print "Removing nuvexport temp file failed\n"; }
+
+ # remove the cutlist incase we added it.
+ if ($cut == 1){
+ printf("Generating cutlist\n");
+ $cmd = "/usr/bin/mythcommflag --chanid $chanid --starttime $start --clearcutlist";
+ print $cmd."\n";
+ if(system($cmd)) { print "It looks like I was not able to generate a cutlist.\n"; }
+ }
+ return 0;
+}
+
+#
+# Encode for Portable
+#
+sub EncodeIt {
+ # Create cutlist from commercial flagging if -cut was passed to the script
+ if ($cut == 1){
+ printf("Generating cutlist\n");
+ $cmd = "/usr/local/bin/mythcommflag --chanid $chanid --starttime $start --gencutlist";
+ print $cmd."\n";
+ if(system($cmd)) { print "It looks like I was not able to generate a cutlist.\n"; }
+ }
+
+ # Use nuvexport to do the work
+ $cmd = "/usr/local/bin/nuvexport --chanid=$chanid --start=$start $nuvoptions --filename=$chanid\_$start.temp --path=$feedpath";
+ print $cmd."\n";
+ if(system($cmd)) { print "Nuvexport encoding seems to have failed\n"; }
+
+ # Now clean up the output so iPods with firmware 1.1 and above can use it
+ $cmd = "/usr/bin/MP4Box -add $feedpath$chanid\_$start.temp.mp4 $feedpath$chanid\_$start.$portable.mp4";
+ print $cmd."\n";
+ if(system($cmd)) { print "MP4Box cleanup seems to have failed\n"; }
+ return 0;
+}
+
+#
+# Create XML with <ITEM> tag for this video file
+#
+sub CreateItemXML {
+ open(ITEM, ">$feedpath$chanid\_$start.$portable.xml");
+ print ITEM "<item>\n";
+ print ITEM "<title>".&encodeForXML($title." - ".$subtitle)."</title>\n";
+ print ITEM "<itunes:author>MythTV</itunes:author>\n";
+ print ITEM "<author>MythTV</author>\n";
+ print ITEM "<itunes:category text=\"TV Shows\"></itunes:category>\n";
+ print ITEM "<comments>".&encodeForXML($file)."</comments>\n";
+ print ITEM "<description>".&encodeForXML($description)."</description>\n";
+ print ITEM "<pubDate>".$recorddate."</pubDate>\n";
+ print ITEM "<enclosure url=\"".&encodeForXML("$feedurl$chanid\_$start.$portable.mp4")."\" type=\"video/quicktime\" />\n";
+ print ITEM "<itunes:duration></itunes:duration>\n";
+ print ITEM "<itunes:keywords>".&encodeForXML($title." - ".$subtitle." - ".$category)."</itunes:keywords>\n";
+ print ITEM "<category>".&encodeForXML($category)."</category>\n";
+ print ITEM "</item>\n";
+ print "\"$filename\" has been added to the feed.\n";
+ close(ITEM);
+ return 0;
+}
+
+#
+# Generate the RSS feed by combining the ITEM XML Files
+#
+sub GenerateRSSFeed {
+
+ open(RSS, ">$feedfile");
+ print RSS "<?php\n";
+ print RSS "header(\"Content-Type: text/xml\");\n";
+ print RSS "echo \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\"; ?>\n";
+ print RSS "<rss xmlns:itunes=\"http://www.itunes.com/DTDs/Podcast-1.0.dtd\" version=\"2.0\">\n";
+ print RSS "<channel>\n";
+ print RSS "<title>MythTV - <? if (\$_GET['title'] == \"\") { \$title = \"*\"; echo \"Recorded Programs\"; }\n";
+ print RSS "else { \$title = \$_GET['title']; echo str_replace(\"_\",\" \",\$_GET['title']); } ?> </title>\n";
+ print RSS "<itunes:author>MythTV - myth2ipod</itunes:author>\n";
+ print RSS "<link>".&encodeForXML($feedurl)."</link>\n";
+ print RSS "<itunes:subtitle>Transcoded recording for your iPod Video.</itunes:subtitle>\n";
+ print RSS "<itunes:summary>Myth TV Recorded Programs for the iPod v.1</itunes:summary>\n";
+ print RSS "<description>Myth TV Recorded Programs for the iPod v.1</description>\n";
+ print RSS "<itunes:owner>\n";
+ print RSS "<itunes:name>MythTV</itunes:name>\n";
+ print RSS "<itunes:email>mythtv\@localhost</itunes:email>\n";
+ print RSS "</itunes:owner>\n";
+ print RSS "<itunes:explicit>No</itunes:explicit>\n";
+ print RSS "<language>en-us</language>\n";
+ print RSS "<copyright>Copyright 2005.</copyright>\n";
+ print RSS "<webMaster>mythtv\@localhost</webMaster>\n";
+ print RSS "<itunes:image href=\"http://myth2ipod.com/mythipod_200.jpg\" />\n";
+ print RSS "<itunes:category text=\"TV Shows\"></itunes:category>\n";
+ print RSS "<category>TV Shows</category>\n";
+ print RSS "<itunes:image href=\"http://myth2ipod.com/mythipod_200.jpg\"/>";
+ print RSS "<image>";
+ print RSS "<url>http://myth2ipod.com/mythipod_200.jpg</url>\n";
+ print RSS "<title>MythTV 2 iPod</title>\n";
+ print RSS "<link>".&encodeForXML($feedurl)."</link>\n";
+ print RSS "<width>200</width>\n";
+ print RSS "<height>200</height>\n";
+ print RSS "</image>\n";
+ print RSS "<? foreach (glob(\$title\.\"*\.$portable\.xml\") as \$file) {include \$file;} ?>\n";
+ print RSS "</channel>\n";
+ print RSS "</rss>\n";
+ close(RSS);
+ if($debug == 1){ print "I created a feed file, was I supposed to?\n"};
+
+ return 0;
+}
+
+# substitute for XML entities
+sub encodeForXML {
+ local $result;
+ $result = $_[0];
+ $result =~ s/&/&amp;/g;
+ $result =~ s/</&lt;/g;
+ $result =~ s/>/&gt;/g;
+ $result;
+}
+
+
+#
+# This code taken from one of the mythlink.sh scripts to get MySQL information
+#
+sub PrepSQLRead{
+# Get the hostname of this machine
+ $hostname = `hostname`;
+ chomp($hostname);
+
+# Read the mysql.txt file in use by MythTV.
+# could be in a couple places, so try the usual suspects
+ my $found = 0;
+ my @mysql = ('/usr/local/share/mythtv/mysql.txt',
+ '/usr/share/mythtv/mysql.txt',
+ '/etc/mythtv/mysql.txt',
+ '/usr/local/etc/mythtv/mysql.txt',
+ "$ENV{HOME}/.mythtv/mysql.txt",
+ 'mysql.txt'
+ );
+ foreach my $file (@mysql) {
+ next unless (-e $file);
+ $found = 1;
+ open(CONF, $file) or die "Unable to open $file: $!\n\n";
+ while (my $line = <CONF>) {
+ # Cleanup
+ next if ($line =~ /^\s*#/);
+ $line =~ s/^str //;
+ chomp($line);
+ # Split off the var=val pairs
+ my ($var, $val) = split(/\=/, $line, 2);
+ next unless ($var && $var =~ /\w/);
+ if ($var eq 'DBHostName') {
+ $db_host = $val;
+ }
+ elsif ($var eq 'DBUserName') {
+ $db_user = $val;
+ }
+ elsif ($var eq 'DBName') {
+ $db_name = $val;
+ }
+ elsif ($var eq 'DBPassword') {
+ $db_pass = $val;
+ }
+ # Hostname override
+ elsif ($var eq 'LocalHostName') {
+ $hostname = $val;
+ }
+ }
+ close CONF;
+ }
+ die "Unable to locate mysql.txt: $!\n\n" unless ($found && $db_host);
+ return 0;
+}
+
+sub promptUser {
+ local($promptString,$defaultValue) = @_;
+ if ($defaultValue) {
+ print $promptString, "[", $defaultValue, "]: ";
+ } else {
+ print $promptString, ": ";
+ }
+
+ $| = 1; # force a flush after our print
+ $_ = <STDIN>; # get the input from STDIN (presumably the keyboard)
+ chomp;
+ if ("$defaultValue") {
+ return $_ ? $_ : $defaultValue; # return $_ if it has a value
+ } else {
+ return $_;
+ }
+}
+
+sub DoSetup {
+ print "\nNot ready yet. How do you send the cd command from perl?\n";
+ return 0;
+}