The apostophe problem is one of the issue, I agree. But check permissions on the directory. My permissions for this directory is:
drwxr-xr-x 2 mythtv mythtv 4096 Jan 14 22:44 PocketPC
Be sure to:
chgrp mythtv /myth/PocketPC
and
chown mythtv /myth/PocketPC
Here is my script Modified from Wififun's script for Myth2ipod:
---Begn Script
#!/usr/bin/perl -w
# VERSION: Beta .8b - myth2ppc
# Get the latest version, and change log at myth2ipod.com
# Author: Chris aka Wififun - email:
wififun@myth2ipod.com
# Contributions and testing by Paul Egli
# Includes
use DBI;
use Getopt::Long;
use File::Path;
# User variables
my $portable = "ppc";
my $feedfile = "/myth/PocketPC/feed.php";
# my $feedfile = "http://192.168.0.151/PocketPC/feed.php";
my $feedpath = "/myth/PocketPC/";
my $wwwloc = "/var/www/";
my $feedurl = "http://192.168.0.151/ppcfeed/";
# Ecoder settings, may be modified to support other devices
# PocketPC with Video compatable settings. MPEG4/XVID MP3 audio
my $encodeopt = "-y -cropleft 10 -cropright 10 -croptop 8 -cropbottom 8 -deinterlace -vcodec xvid -s 320x240 -r 29.97 -b 384 -qmin 2 -qmax 5 -buf
size 4096 -acodec mp3 -ab 96 -g 300";
# 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( $rightnow ) = `date`;
GetOptions ("rebuild" => \$rebuild,
"encode" => \$encode,
"debug" => \$debug,
"setup" => \$setup);
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};
$ttitle = $title;
$ttitle =~ s/ /_/g;
$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;
printf("Starting pass 1 of 2...\n");
DoPassOne();
printf("Pass 1 competed, starting pass 2 of 2...\n");
DoPassTwo();
printf("Pass 2 competed, building video XML file\n");
CreateItemXML();
printf("XML file created for \"$filename\" : Cleaning up temporary files\n");
$cmd = "mv -f $feedpath'$filename'.pass2 $feedpath'$filename'.$portable.mov";
print $cmd."\n";
if(system($cmd)) { print "Moving pass2 to final .mov failed\n"; }
$cmd = "rm -f /tmp/myth2ppc_log*";
print $cmd."\n";
if(system($cmd)) { print "Removing pass 1 file failed\n"; }
$cmd = "rm -f $feedpath'$filename'.pass1";
print $cmd."\n";
if(system($cmd)) { print "Removing pass 1 file failed\n"; }
return 0;
}
#
# Encode for Portable Pass 1
#
sub DoPassOne {
$cmd = "/usr/local/bin/ffmpeg -i $directory/$file -comment '$file' -title '$title' -author 'MythTV - myth2ppc' -timestamp '$rightnow' $encodeopt
-pass 1 -passlogfile /tmp/myth2ppc_log -f mov $feedpath'$filename'.pass1";
print $cmd."\n";
if(system($cmd)) { print "Pass one failed\n"; }
return 0;
}
#
# Encode for Portable Pass 2
#
sub DoPassTwo {
$cmd = "/usr/local/bin/ffmpeg -i $directory/$file -comment '$file' -title '$title' -author 'MythTV - myth2ppc' -timestamp '$rightnow' $encodeopt
-pass 2 -passlogfile /tmp/myth2ppc_log -f mov $feedpath'$filename'.pass2";
print $cmd."\n";
if(system($cmd)) { print "Pass two failed\n"; }
return 0;
}
#
# Create XML with <ITEM> tag for this video file
#
sub CreateItemXML {
open(ITEM, ">$feedpath$filename.$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$filename.$portable.mov")."\" 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 - myth2ppc</itunes:author>\n";
print RSS "<link>".&encodeForXML($feedurl)."</link>\n";
print RSS "<itunes:subtitle>Transcoded recording for your PocketPC Video.</itunes:subtitle>\n";
print RSS "<itunes:summary>Myth TV Recorded Programs for the PocketPC v.1</itunes:summary>\n";
print RSS "<description>Myth TV Recorded Programs for the PocketPC 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 PocketPC</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/&/&/g;
$result =~ s/</</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;
}
---End Script
I hope posting my modified script helps. It was late when I wrote it and maybe I left something out in my instructions.
Also here is my Symbolic Link in my /var/www/ directory:
lrwxrwxrwx 1 root root 15 Dec 29 17:32 ppcfeed -> /myth/PocketPC/
I hope this helps. If I can copy any other configuration or scripts from my KnoppMyth box, let me know. I'd like to see you get this running.
Again, my thanks to Wififun.
--Brian