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