[mythtv] [PATCH] Mythweb Mythvideo patches

bobnvic at everestkc.net bobnvic at everestkc.net
Fri May 21 17:48:02 EDT 2004

This patch adds or changes the following functionality in Mythweb:

1. Adds the ability to edit mythvideo data from mythweb
2. Adds links to the videos from the mythvideo page, building on 
Andrew Ingram's patch to include the option of using file:// links
and also putting links on the cover images.  Most of my videos
are avi's which insist on being downloaded before playing when
using http.
3. Changes the reverse sorting order to list starting with "A"

Patch was created using cvs -z3 diff -ud > mythweb.diff

Patches are for:

mythweb/video_edit.php is new.

This is the first time I looked at any code since college Pascal
18 years ago and I certainly didn't know any PHP before this week,
so it's probably not implemented in the best manner and I'd 
appreciate any comments.  This is also my first patch submit so 
let me know if there are any problems.

Bob C

-------------- next part --------------
? mythweb.diff
? video_edit.php
Index: video.php
RCS file: /var/lib/mythcvs/mythweb/video.php,v
retrieving revision 1.2
diff -u -d -r1.2 video.php
--- video.php	11 May 2004 06:18:22 -0000	1.2
+++ video.php	21 May 2004 21:02:53 -0000
@@ -34,7 +34,7 @@
 // Set sorting
     if (!is_array($_SESSION['video_sortby']))
         $_SESSION['video_sortby'] = array(array('field' => 'title',
-                                                   'reverse' => true));
+                                                   'reverse' => false));
 // Sort the programs
     if (count($All_Shows))
@@ -57,6 +57,7 @@
 class Video {
+    var $intid;
     var $plot;
     var $rating;    // this should be a reference to the $Channel array value
@@ -72,6 +73,7 @@
     var $childid;
     function Video($program_data) {
+        $this->intid            = $program_data['intid'];
         $this->plot            = $program_data['plot'];
         $this->rating          = $program_data['rating'];
         $this->title           = $program_data['title'];
Index: config/conf.php
RCS file: /var/lib/mythcvs/mythweb/config/conf.php,v
retrieving revision 1.18
diff -u -d -r1.18 conf.php
--- config/conf.php	11 May 2004 06:18:22 -0000	1.18
+++ config/conf.php	21 May 2004 21:02:53 -0000
@@ -39,6 +39,13 @@
 // Type of url for the links to recorded programs. Filename will be added at the end
     define('video_url', video_dir);     //Normal http url
+// Type of url for the links to mythvideo videos. Filename will be added to the end. 
+// For this to work, create a 'videos' symlink in mythweb which points to the path for mythvideo videos
+// Link can set as either html:// or file://.  file:// is useful over lan for avi's to play immediately.
+// Replace 'machine_name/path_to_videos' with relevent info for file:// 
+    define('videos_url', videos);
+    #define('videos_url','file://'machine_name/path_to_videos');
     //Url for windows filters. This need to be changed if you use a different
     //port or the webserver is not running on the backend machine.
     //You may have to adjust the playback app in the filter configuration program.
Index: themes/Default/video.php
RCS file: /var/lib/mythcvs/mythweb/themes/Default/video.php,v
retrieving revision 1.2
diff -u -d -r1.2 video.php
--- themes/Default/video.php	11 May 2004 06:18:23 -0000	1.2
+++ themes/Default/video.php	21 May 2004 21:02:55 -0000
@@ -13,6 +13,17 @@
         global $All_Shows;
+<!--Hide script from old browsers
+function newWindow(newContent)
+ {
+  winContent = window.open(newContent, 'nextWin', 'right=0, top=20,width=350,height=410, toolbar=no,scrollbars=no, resizable=yes')         
+ }
+ //Stop hiding script from old browsers -->
 <table width="100%" border="0" cellpadding="4" cellspacing="2" class="list small">
 <tr class="menu">
 <?php   if (show_recorded_pixmap) { ?>
@@ -26,6 +37,7 @@
     <td><a href="video.php?sortby=length">length</a></td>
     <td><a href="video.php?sortby=userrating">imdb&nbsp;rating</a></td>
     <td><a href="video.php?sortby=year">year</a></td>
+    <td>Edit</a></td>
     $row = 0;
     foreach ($All_Shows as $show) {
@@ -33,12 +45,13 @@
         if (show_recorded_pixmaps) {
             if (file_exists(video_img_path.'/'.basename($show->coverfile)))
-                echo '<img id="'.$show->filename."\" src=\"".video_img_path.'/'.basename($show->coverfile).'" width="'.video_img_width.'" height="'.video_img_height.'">';
+                echo '<a href="'.videos_url.'/'.rawurlencode(basename($show->filename)).'">.<img id="'.$show->filename."\" src=\"".video_img_path.'/'.basename($show->coverfile).'" width="'.video_img_width.'" height="'.video_img_height.'">';
                 echo '&nbsp;';
-    <td><?php echo $show->title?></td>
+    <td><?php echo '<a 
     <td><?php echo $show->director?></td>
     <td><?php echo $show->plot?></td>
     <td><?php echo $show->rating?></td>
@@ -46,6 +59,7 @@
     <td nowrap><?php echo nice_length(($show->length*60))?></td>
     <td nowrap><?php echo $show->userrating?></td>
     <td nowrap><?php echo $show->year?></td>
+    <td><a href="javascript:newWindow ('video_edit.php?intid=<?php echo $show->intid?>')" >Edit</a> 
@@ -64,4 +78,4 @@
\ No newline at end of file
-------------- next part --------------
/***                                                                        ***\
    video_edit.php                               Last Updated: 2004.05.21 (bobcottingham)

    edit video info
\***                                                                        ***/

// Initialize the script, database, etc.
    require_once "includes/init.php";
<script language="JavaScript">
function refreshParent() {
  window.opener.location.href = window.opener.location.href;

  if (window.opener.progressWindow)
//check to see if the form has been submitted
if (isset($_POST['submit'])) {

      //insert data into database
      mysql_query("UPDATE videometadata SET title='{$_POST['title']}',director='{$_POST['director']}',plot='{$_POST['plot']}',rating='{$_POST['rating']}',inetref='{$_POST['inetref']}',year='{$_POST['year']}',userrating='{$_POST['userrating']}',length='{$_POST['length']}' WHERE intid='{$_POST['intid']}'");
      //close window and refresh parent
      ?><body onLoad="refreshParent()"</body><?php

//get data to prefill form if we're editing an existing entry
   $edit_result = mysql_query("SELECT intid,title,director,plot,rating,inetref,year,userrating,length FROM videometadata WHERE intid=' {$_REQUEST['intid']}'")
          or trigger_error('SQL Error: '.mysql_error(), FATAL);
//output html form

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<title text="#DEDEDE">Edit Video Info</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
td,body {
   font-family: Arial, Helvetica, sans-serif;
   font-size: 12px;

<body bgcolor="#003060" text="#DEDEDE" link="#3181B4" alink="#CC0000" vlink="#3181B4" onclick="hide()">

<p align="center">
<font size="+1">Edit Video Info</font>


<form method="post" action="<?=$_SERVER['PHP_SELF']?>">
<table width="302" border="0" cellspacing="0" cellpadding="3">
<td width="99">Title:</td>
<td width="301"><input name="title" type="text" value="<?if (isset($title)) print $title; ?>"></td>
<td><input name="director" type="text" value="<?if (isset($director)) print $director; ?>"></td>
<td><textarea name="plot" rows="5" cols="30" wrap="VIRTUAL"><?if (isset($plot)) print $plot; ?></textarea></td>
<td><input name="rating" type="text" value="<?if (isset($rating)) print $rating; ?>"></td>
<td><input name="inetref" type="text" value="<?if (isset($inetref)) print $inetref; ?>"></td>
<td><input name="year" type="text" size=4 value="<?if (isset($year)) print $year; ?>"></td>
<td><input name="userrating" type="text" size=3 value="<?if (isset($userrating)) print $userrating; ?>"></td>
<td><input name="length" type="text" size=3 value="<?if (isset($length)) print $length; ?>"> in minutes</td>
   <input type="hidden" name="intid" value="<?if (isset($_REQUEST['intid'])) print $_REQUEST['intid']?>">
   <input type="submit" name="submit" value="submit"></td>

More information about the mythtv-dev mailing list