summaryrefslogtreecommitdiffstats
path: root/abs/extra/myt2xvid3
diff options
context:
space:
mode:
Diffstat (limited to 'abs/extra/myt2xvid3')
-rwxr-xr-xabs/extra/myt2xvid3/PKGBUILD18
-rw-r--r--abs/extra/myt2xvid3/archive.php159
-rwxr-xr-xabs/extra/myt2xvid3/myt2xvid3310
-rwxr-xr-xabs/extra/myt2xvid3/myt2xvid3-userjob.sh6
-rwxr-xr-xabs/extra/myt2xvid3/myt2xvid3.install38
5 files changed, 531 insertions, 0 deletions
diff --git a/abs/extra/myt2xvid3/PKGBUILD b/abs/extra/myt2xvid3/PKGBUILD
new file mode 100755
index 0000000..9d88ce9
--- /dev/null
+++ b/abs/extra/myt2xvid3/PKGBUILD
@@ -0,0 +1,18 @@
+pkgname=myt2xvid3
+pkgver=0.1
+pkgrel=7
+arch=("i686")
+pkgdesc="A multimedia framework based on the MPEG-4 Systems standard"
+url="http://www.knoppmythwiki.org/index.php?page=XvidEncoding"
+depends=('nuvexport')
+install="myt2xvid3.install"
+source=( myt2xvid3 myt2xvid3-userjob.sh archive.php)
+
+
+build() {
+ cd $startdir/src
+ install -D -m 755 myt2xvid3 $startdir/pkg/usr/bin/myt2xvid3
+ install -D -m 755 myt2xvid3-userjob.sh $startdir/pkg/usr/bin/myt2xvid3-userjob.sh
+ mkdir -m777 -p $startdir/pkg/myth/video/archive/
+ install -D -m 755 archive.php $startdir/pkg/myth/video/archive/
+}
diff --git a/abs/extra/myt2xvid3/archive.php b/abs/extra/myt2xvid3/archive.php
new file mode 100644
index 0000000..f970868
--- /dev/null
+++ b/abs/extra/myt2xvid3/archive.php
@@ -0,0 +1,159 @@
+<?
+//archive.php
+// based on m2iweb.php by http://anthony.lusby.us/m2iweb/
+//release 0.1
+//10/05/07
+?>
+
+<html>
+<head>
+ <title>MythWeb - Archive Recordings</title>
+
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+
+ <script type="text/javascript" src="/mythweb/js/init.js"></script>
+ <script type="text/javascript" src="/mythweb/js/browser.js"></script>
+ <script type="text/javascript" src="/mythweb/js/utils.js"></script>
+
+ <script type="text/javascript" src="/mythweb/js/mouseovers.js"></script>
+ <script type="text/javascript" src="/mythweb/js/visibility.js"></script>
+ <script type="text/javascript" src="/mythweb/js/ajax.js"></script>
+
+ <link rel="stylesheet" type="text/css" href="/mythweb/skins/default/style.css" />
+ <link rel="stylesheet" type="text/css" href="/mythweb/skins/default/header.css" />
+ <link rel="stylesheet" type="text/css" href="/mythweb/skins/default/menus.css" />
+ <link rel="stylesheet" type="text/css" href="/mythweb/skins/default/programming.css" />
+
+ <link rel="stylesheet" type="text/css" href="/mythweb/skins/default/status.css" />
+
+</head>
+
+<body>
+
+<div id="page_header" class="clearfix">
+ <div id="logo_box">
+ <a id="mythtv_logo" href="/mythweb/">
+ <img src="/mythweb/skins/default/img/mythtv-logo.png"
+width="174" height="48" border="0" alt="MythTV" class="alpha_png">
+ </a>
+
+ </div>
+ <div id="sections">
+ <a id="tv_link" href="/mythweb/tv" onmouseover="return help_text('TV functions, including recorded programs.')" onmouseout="return help_text()">
+ <img src="/mythweb/skins/default/img/tv.png" width="48" height="48" class="alpha_png" alt="MythTV"/>
+ </a>
+ <a id="video_link" href="/mythweb/video" onmouseover="return help_text('MythVideo on the web.')" onmouseout="return help_text()">
+ <img src="/mythweb/skins/default/img/video.png" width="48" height="48" class="alpha_png" alt="MythVideo" />
+ </a>
+ <a id="weather_link" href="/mythweb/weather" onmouseover="return help_text('MythWeb Weather.')" onmouseout="return help_text()">
+ <img src="/mythweb/skins/default/img/weather.png" width="48" height="48" class="alpha_png" alt="MythWeather" />
+ </a>
+ <a id="settings_link" href="/mythweb/settings" onmouseover="return help_text('Edit MythWeb and some MythTV settings.')" onmouseout="return help_text()">
+ <img src="/mythweb/skins/default/img/settings.png" width="48" height="48" class="alpha_png" alt="Settings" />
+ </a>
+ </div>
+ <div id="extra_header">
+ <div id="help_wrapper">
+ <div id="help_box">
+
+ <div id="help_text_default">
+ MythWeb: Mon May 16, 2006, 09:09 PM </div>
+ <div id="help_text">
+ </div>
+ </div>
+ </div>
+ <div id="search" >
+ <form action="/mythweb/tv/search" method="post">
+
+ <div id="simple_search">
+ <input id="search_text" type="text" name="searchstr" size="15" value="">
+ <input id="search_submit" type="submit" class="submit" value="Search"> (<a href="/mythweb/tv/search">Advanced</a>)
+ </div>
+ <div id="search_options">
+ </div>
+ </form>
+
+ </div>
+ </div>
+</div>
+
+
+<table width="100%" border="0" cellspacing="2" cellpadding="0">
+<tr>
+
+ <td colspan="2" class="menu menu_border_t menu_border_b"><table class="body" width="100%" border="0"
+
+cellspacing="2" cellpadding="2">
+ <tr>
+ <td><div id="command_choices">
+ <a href="/mythweb/" id="category_legend" onmouseover="popup('category_legend'); return true;">MythTV:</a> &nbsp; &nbsp;
+
+ <a href="/mythweb/tv/list">Listings</a>
+ &nbsp; | &nbsp;
+ <a href="/mythweb/tv/searches">Searches</a>
+ &nbsp; | &nbsp;
+ <a href="/mythweb/tv/schedules">Recording Schedules</a>
+ (<a href="/mythweb/tv/schedules/manual">Manual</a>,
+ <a href="/mythweb/tv/schedules/custom">Custom</a>)
+ &nbsp; | &nbsp;
+ <a href="/mythweb/tv/upcoming">Upcoming Recordings</a>
+ &nbsp; | &nbsp;
+ <a href="/mythweb/tv/recorded">Recorded Programs</a>
+ &nbsp; | &nbsp;
+ <a href="/ipodfeed/m2iweb.php">Myth2iPod</a>
+ &nbsp; | &nbsp;
+ <a href="/archive/archive.php">Myt2XviD3</a>
+ &nbsp; | &nbsp;
+ <a href="/mythweb/status">Backend Status</a>
+ </div></td>
+ </tr>
+ </table></td>
+
+</tr>
+</table>
+
+<table width="100%" border="0" cellpadding="4" cellspacing="2" class="list small">
+<tr><td colspan="10" class="list_separator">View and delete recordings transcoded to XviD via Myt2XviD3.</td></tr>
+<?php
+if (isset($_REQUEST['delete'])){
+ $delete = $_REQUEST['delete'];
+ if ($delete AND substr($delete, -9) == ".XviD.xml") {
+ echo '<tr><td colspan="10" class="list_separator">
+ <font color="red">';
+ echo $delete;
+ unlink($delete) or print(" failed to be ");
+ echo ' has been deleted, ';
+ $deletetoo = substr($delete, 0, -3)."avi";
+ echo $deletetoo;
+ unlink($deletetoo) or print(" failed to be ");
+ echo ' has been deleted.';
+ echo'</td></tr>';
+ }
+}
+ $i=1;
+ foreach (glob("*.XviD.xml") as $file) {
+ $lines = file($file);
+ echo '<tr class="recorded"><td class="list">&nbsp;</td><td>';
+ echo '<font color="';
+ if (!file_exists(substr($file, 0, -3)."avi")) {
+ echo "red";
+ }
+ echo '">'.$i.'</font>';
+ echo "</td></td><td><a href=".'"'.substr($file, 0, -3)."avi".'"'."style='color:white'>".strip_tags($lines[1])."</a></td><td>".strip_tags($lines[7])."</td><td>".strip_tags($lines[6])."</td><td nowrap>".filesizeparse(filesize(substr($file, 0, -3)."avi"))."</td><td>".'<a href="?delete='.$file.'" onclick="return confirm('."'Are you sure you want to delete?'".')">Delete</a>'."</td>".'<td class="list">&nbsp;</td>'."</tr>";
+ $i++;
+ }
+//}
+
+function filesizeparse($size){
+ $i=0;
+ $iec = array(" B", " KB", " MB", " GB", " TB");
+ while (($size/1024)>1) {
+ $size=$size/1024;
+ $i++;
+ }
+ return substr($size,0,strpos($size,'.')+3).$iec[$i];
+}
+?>
+</table>
+</body>
+</html>
diff --git a/abs/extra/myt2xvid3/myt2xvid3 b/abs/extra/myt2xvid3/myt2xvid3
new file mode 100755
index 0000000..af65188
--- /dev/null
+++ b/abs/extra/myt2xvid3/myt2xvid3
@@ -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 = "XviD";
+my $feedfile = "/myth/video/archive/feed.php";
+my $feedpath = "/myth/video/archive/";
+my $wwwloc = "/data/srv/httpd/htdocs";
+my $feedurl = "http://REPLACEME/archive/";
+my $nuvoptions ="--mode=XviD --nice=19 --cutlist --nodenoise --nodeinterlace --crop --multipass";
+
+# 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 "Oops, 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/bin/nuvexport --chanid=$chanid --start=$start $nuvoptions --filename=$chanid\_$start.$portable --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.avi")."\" 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/myt2xvid3/myt2xvid3-userjob.sh b/abs/extra/myt2xvid3/myt2xvid3-userjob.sh
new file mode 100755
index 0000000..6bd46ea
--- /dev/null
+++ b/abs/extra/myt2xvid3/myt2xvid3-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/myt2xvid3 "$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/myt2xvid3/myt2xvid3.install b/abs/extra/myt2xvid3/myt2xvid3.install
new file mode 100755
index 0000000..b3767f3
--- /dev/null
+++ b/abs/extra/myt2xvid3/myt2xvid3.install
@@ -0,0 +1,38 @@
+
+pre_install() {
+ mkdir -p /myth/video/archive
+ chown mythtv:http /myth/video/archive
+}
+
+pre_upgrade() {
+ pre_install
+}
+
+pre_remove() {
+ pre_install
+}
+
+post_install() {
+ . /etc/systemconfig
+ ln -s /myth/video/archive /data/srv/httpd/htdocs/archive
+ ln -s /myth/video/archive/archive.php /myth/video/archive/index.php
+ sed -i -e "s/REPLACEME/$HOSTNAME/g" /usr/bin/myt2xvid3
+ chown -R mythtv:http /myth/video/archive
+ /usr/bin/myt2xvid3 -rebuild
+}
+
+post_upgrade() {
+ /usr/bin/myt2xvid3 -rebuild
+}
+
+post_remove() {
+ rm -fr /data/srv/http/htdocs/archive
+ rm -rf /myth/video/archive/index.php
+ rm -rf /myth/video/archive/archive.php
+ # don't delete content that the user may still want, so leave /myth/video/archive
+}
+
+op=$1
+shift
+
+$op $*