Ticket #1322: transcode.diff

File transcode.diff, 12.8 KB (added by penguin@…, 18 years ago)
  • mythweb/themes/default/tv/transcode.php

     
     1<?php
     2// Add transcode job to jobqueue.
     3
     4
     5//Get stage
     6$stage = $_POST["stage"];
     7
     8//This keeps us from altering the database
     9    $Live=true;
     10//This show how much info to show
     11//0 - Off
     12//1 - Debug
     13    $verbose=0;
     14
     15// Set the desired page title
     16    $page_title = 'MythWeb - Transcode';
     17    $headers[0] = "<link rel=\"stylesheet\" href=\"" . skin_url . "/transcode.css\">";
     18    if ($stage==3 && $verbose==0) {
     19        $headers[1] = "<meta http-equiv=\"refresh\" content=\"1;/mythweb/\">";
     20    }
     21   
     22
     23// Print the page header
     24    require_once theme_dir.'/header.php';
     25
     26
     27?>
     28<br>
     29<?php
     30if (!isset($_POST["stage"]))
     31{
     32    echo ("
     33    <form action=\"transcode\" method=\"POST\">
     34    <input type=hidden name=\"stage\" value=\"2\">
     35    <table align=center border=1>
     36    <!-- <tr><td><select name=\"select_video\"> -->
     37    ");
     38    $query = "SELECT title,subtitle,chanid,starttime,description,filesize FROM recorded ORDER BY title,starttime DESC";
     39    $result = mysql_query($query);
     40
     41    $rows = mysql_numrows($result);
     42    $i = 0;
     43    $j = 0;
     44    while ($i<$rows)
     45    {
     46        $title = mysql_result($result,$i,"title");
     47        $subtitle = mysql_result($result,$i,"subtitle");
     48        $chanid = mysql_result($result,$i,"chanid");
     49        $starttime = mysql_result($result,$i,"starttime");
     50        $description = mysql_result($result,$i,"description");
     51        $vid_info = transcode_encode_vidlink($chanid,$starttime);
     52        $filesize = mysql_result($result,$i,"filesize");
     53        $filesize = (int)($filesize/(1024*1024));
     54        if (transcode_has_cutpoints($vid_info) && !transcode_is_queued($vid_info))
     55        {
     56            echo ("<tr>");
     57            echo ("<td><input type=checkbox name=\"$i\" value=\"$vid_info\"></td>");
     58            echo ("<td>$title");
     59            if ($subtitle != "")
     60              echo (": $subtitle");
     61            echo ("</td>");
     62            echo ("<td width=400>$description</td>");
     63            echo ("<td>$starttime</td>");
     64            echo ("<td>$filesize MB</td>");
     65            echo ("</tr>");
     66        }
     67
     68        $i++;
     69    }
     70    echo ("
     71    </table>
     72    <br><center><input type=submit value=\"Review Selections\"></center>
     73    </form>
     74    ");
     75}
     76?>
     77<div id="vidinfo">
     78</div>
     79<?php
     80if ( $stage == 2 )
     81{
     82    echo ("
     83    <div id=\"vidinfo\">
     84    <form action=\"transcode\" method=\"POST\">
     85    <input type=hidden name=\"stage\" value=\"3\">
     86    <br>Will transcode the following videos:
     87    ");
     88    foreach ($_POST as $post_key => $post_value)
     89    {
     90        if ($post_key !== "stage")
     91        {
     92            echo ("<input type=hidden name=\"$post_key\" value=\"$post_value\">\n");
     93            $video_info = transcode_get_vidinfo($post_value);
     94            echo ("<br> ");
     95            echo ("<a id=\"program_" . $post_key . "\" href=\"#\" onmouseover =\"popup('program_" . $post_key . "', '');return true\">");
     96            echo ($video_info["title"]);
     97            if ($video_info["subtitle"] != "")
     98              echo (": " . $video_info["subtitle"]);
     99            echo ("</a>\n");
     100        }
     101    }
     102    echo ("
     103    <br>
     104    <br><input type=submit value=\"Queue\">
     105    </form>
     106    </div>
     107    ");
     108    foreach ($_POST as $post_key => $post_value)
     109    {
     110        if ($post_key !== "stage")
     111        {
     112            $video_info = transcode_get_vidinfo($post_value);
     113            echo ("<div id=\"program_" . $post_key . "_popup\" class=\"popup\"><dl class=\"details_list\">\n");
     114            echo ("<dt>Title:</dt><dd>" . $video_info["title"]);
     115            if ($video_info["subtitle"] != "")
     116              echo (": " . $video_info["subtitle"]);
     117            echo ("</dd>\n");
     118            echo ("<dt>Start time:</dt><dd>" . $video_info["starttime"] . "</dd>\n");
     119            echo ("<dt>End time:</dt><dd>" . $video_info["endtime"] . "</dd>\n");
     120            echo ("<dt>Chanid:</dt><dd>" . $video_info["chanid"] . "</dd>\n");
     121            echo ("<dt>Host:</dt><dd>" . $video_info["hostname"] . "</dd>\n");
     122            echo ("<dt>Filesize:</dt><dd>" . $video_info["filesize"] . "MB</dd>\n");
     123            echo ("<dt>Description:</dt><dd>" . $video_info["description"] . "</dd>\n");
     124            echo ("</div>\n");
     125        }
     126    }
     127}
     128else if ( $stage == 3 )
     129{
     130    if ($verbose>0)
     131        echo ("<div id=\"vidinfo\">");
     132    if (!$Live && $verbose>0)
     133      echo ("<font color=\"red\"><b>Notice</b>: Database Safe-mode Activated</font>");
     134    foreach ($_POST as $post_key  => $post_value)
     135    {
     136        if ($post_key !== "stage")
     137        {
     138            if ($verbose>0)
     139                echo ("<br><br>Got $post_key : $post_value");
     140            $video_parms = transcode_decode_vidlink($post_value);
     141            $insert_time = date("Y-m-d H:i:s");
     142            $query = "SELECT mark,type FROM recordedmarkup WHERE chanid=\"$video_parms[0]\" AND starttime=\"$video_parms[1]\" AND type BETWEEN 4 AND 5";
     143            if ($verbose>0)
     144                echo ("<br>Query: $query");
     145            $result = mysql_query($query);
     146            $i = 0;
     147            $cutpoint = 0;
     148            $rows = mysql_numrows($result);
     149            if ($verbose>0)
     150                echo ("<br>Rows: $rows");
     151            $cutlist = array();
     152            $query = "UPDATE recorded SET cutlist=\"";
     153            while ($i<$rows)
     154            {
     155                $type = mysql_result($result,$i,"type");
     156                $mark = mysql_result($result,$i,"mark");
     157                if ($type == 4)
     158                    $cutlist[$cutpoint] = $mark;
     159                if ($type == 5) {
     160                    $cutlist[$cutpoint] = $cutlist[$cutpoint]." - $mark";
     161                    $query = $query."$cutlist[$cutpoint]\n";
     162                    if ($verbose>0)
     163                        echo ("<br>Cutpoint created: $cutlist[$cutpoint]");
     164                    $cutpoint++;
     165                }
     166                $i++;
     167            }
     168            if ($verbose>0)
     169                echo ("<br>Cutpoints created: $cutpoint");
     170            $query = $query."\" WHERE chanid=\"$video_parms[0]\" AND starttime=\"$video_parms[1]\"";
     171            if ($Live)
     172              mysql_query($query);
     173            if ($verbose>0)
     174                echo ("<br>Query: $query");
     175            $query = "INSERT INTO jobqueue VALUES ('','$video_parms[0]','$video_parms[1]','$insert_time',1,0,1,1,'','','','')";
     176            if ($Live)
     177              mysql_query($query);
     178            if ($verbose>0)
     179                echo ("<br>Query: $query");
     180        }
     181    }
     182    if ($verbose>0)
     183    {
     184        echo ("<br><br><a href=\"transcode\">Transcode</a>");
     185        echo ("</div");
     186    }
     187}
     188
     189
     190
     191
     192// Print the page footer
     193    require_once theme_dir.'/footer.php';
     194
     195
  • mythweb/themes/default/header.php

     
    175175<?php if ($Modules['backend_log']) { ?>
    176176                    &nbsp; | &nbsp;
    177177                    <a href="<?php echo root ?>backend_log"><?php echo t('Backend Logs') ?></a>
     178                    &nbsp; | &nbsp;
     179                    <a href="<?php echo root ?>tv/transcode"><?php echo t('Transcode') ?></a>
    178180<?php } ?>
    179181                </div></td>
    180182        </tr>
  • mythweb/skins/default/transcode.css

     
     1#vidinfo {
     2    position: relative;
     3    left: 120pt;
     4    width: 600px;
     5}
     6
     7#vid_warn {
     8    font-size: 12px;
     9    color: #FF0000;
     10}
     11 No newline at end of file
  • mythweb/languages/English.php

    Property changes on: mythweb/skins/default/transcode.css
    ___________________________________________________________________
    Name: svn:executable
       + *
    
     
    9696    'The requested recording schedule has been deleted.' => '',
    9797    'Thursday'                                           => '',
    9898    'Title'                                              => '',
     99    'Transcode'                                          => '',
    99100    'Transcoder'                                         => '',
    100101    'Tuesday'                                            => '',
    101102    'Type'                                               => '',
  • mythweb/modules/tv/transcode.php

     
     1<?php
     2// Add jobqueue entries
     3
     4/*
     5
     6Mythjobqueue Types, Commands, Flags, And Status
     7
     8Types
     90 - None
     101 - Transcode
     112 - Commflag
     12
     13Commands
     140 - Run
     151 - Pause
     162 - Resume
     174 - Stop
     188 - Restart
     19
     20Flags
     210 - Reg Flags
     221 - Use cutlist
     232 - Live Recording
     24
     25Status
     260 - Unknown
     271 - Queued
     282 - Pending
     293 - Starting
     304 - Running
     315 - Stopping
     326 - Paused
     337 - Retry
     348 - Erroring
     359 - Aborting
     36100 - Done
     37110 - Finished
     38120 - Aborted
     39130 - Erroreds
     40140 - Cancelled
     41
     42*/
     43function transcode_encode_vidlink($chanid,$starttime)
     44{
     45    return implode("~",array($chanid,$starttime));
     46}
     47
     48function transcode_decode_vidlink($vidlink)
     49{
     50    return explode("~",$vidlink);
     51}
     52
     53function transcode_get_vidinfo($vidlink)
     54{
     55    $video_search_info=transcode_decode_vidlink($vidlink);
     56    $query="SELECT title,subtitle,description,hostname,filesize,endtime FROM recorded WHERE chanid=\"$video_search_info[0]\" AND starttime=\"$video_search_info[1]\"";
     57    $result=mysql_query($query);
     58    $rows=mysql_numrows($result);
     59    $i=0;
     60    $video_info=array();
     61    while ($i<$rows)
     62    {
     63        $video_info["title"]=mysql_result($result,$i,"title");
     64        $video_info["subtitle"]=mysql_result($result,$i,"subtitle");
     65        $video_info["description"]=mysql_result($result,$i,"description");
     66        $video_info["hostname"]=mysql_result($result,$i,"hostname");
     67        $video_info["filesize"]=mysql_result($result,$i,"filesize");
     68        $video_info["filesize"]=(int)($video_info["filesize"]/(1024*1024));
     69        $video_info["endtime"]=mysql_result($result,$i,"endtime");
     70        $video_info["chanid"]=$video_search_info[0];
     71        $video_info["starttime"]=$video_search_info[1];
     72        $i++;
     73    }
     74    return $video_info;
     75}
     76
     77function transcode_has_cutpoints($vidlink)
     78{
     79    $video_cutpoint_info=transcode_decode_vidlink($vidlink);
     80    $query="SELECT mark FROM recordedmarkup WHERE chanid=\"$video_cutpoint_info[0]\" AND starttime=\"$video_cutpoint_info[1]\" AND type BETWEEN 4 AND 5";
     81    $result=mysql_query($query);
     82    $rows=mysql_numrows($result);
     83    if ($rows>0)
     84        return true;
     85    return false;
     86}
     87
     88function transcode_is_queued($vidlink)
     89{
     90    $video_queue_info=transcode_decode_vidlink($vidlink);
     91    $query="SELECT id FROM jobqueue WHERE chanid=\"$video_queue_info[0]\" AND starttime=\"$video_queue_info[1]\" AND type=1";
     92    $result=mysql_query($query);
     93    $rows=mysql_numrows($result);
     94    if ($rows>0)
     95        return true;
     96    return false;
     97}
     98
     99// Load the class for this page
     100    require_once theme_dir.'tv/transcode.php';
     101
     102// Exit
     103    exit;
     104
  • mythweb/modules/tv/init.php

    Property changes on: mythweb/modules/tv/transcode.php
    ___________________________________________________________________
    Name: svn:executable
       + *
    
     
    2323                                                  'schedules/manual' => t('Schedule Manually'),
    2424                                                  'schedules/custom' => t('Custom Schedule'),
    2525                                                  'recorded'         => t('Recorded Programs'),
     26                                                  'transcode'        => t('Transcode'),
    2627                                                 ),
    2728                          );
    2829
  • mythweb/.htaccess

     
    108108# or if this is a /css/, /js/ or /cache/ directory request.
    109109    RewriteRule    ^(css|data|images|js|themes|skins|[a-z_]+\.php)(/|$)     -     [L]
    110110
    111 # Redirect most of the remaining URL requests to the main mythweb script.
     111# Redirect most of the remaining URL requests to the main cooktools script.
    112112# It will then handle any requests given to it.
    113113    RewriteRule     ^(.+)$                  mythweb.php/$1              [QSA,L]
    114114