Fixed : Repair Duration

Fixed : Reindex
This commit is contained in:
Arslan Hassan 2012-08-01 13:06:49 +00:00
parent 48953ddacc
commit 043e48307c
5 changed files with 113 additions and 81 deletions

View file

@ -1,66 +1,59 @@
<?php
/*
/*
* By Arslan Hassan for reparing video durations
* it will check which videos are already processed
* and their video duration is still not fixed
* it will read files 1 by 1 and fix them all
*/
*/
require'../includes/admin_config.php';
$userquery->admin_login_check();
$userquery->login_check('web_config_access');
$params = array('duration'=>'1','duration_op'=>'<=','status'=>'Successful');
$params = array('duration' => '1', 'duration_op' => '<=', 'status' => 'Successful');
$videos = get_videos($params);
$fixed_array = array();
if($_POST['fix_duration']
|| $_POST['mark_failed']
|| $_POST['mark_delete'])
{
foreach($videos as $video)
{
$log = get_file_details($video['file_name']);
if($log && $_POST['fix_duration'])
{
//$duration = $log['output_duration'];
//if(!$duration)
// $duration = $log['duration'];
$duration = parse_duration(LOGS_DIR.'/'.$video['file_name'].'.log');
if(!$duration)
e("Can't do anything about \"".$video['title']."\"");
else
{
$db->update(tbl('video'),array('duration'),array($duration),"videoid='".$video['videoid']."'");
$fixed_array[$video['file_name']] = 'yes';
e("Succesfully updated duration of \"".$video['title']."\" to ".SetTime($duration),'m');
}
}
if(!$log && $_POST['mark_failed'])
{
$db->update(tbl("video"),array("status","failed_reason"),
array('Failed',"Unable to get video duration")," file_name='".$video['file_name']."'");
e("\"".$video['title']."\" status has been changed to Failed","m");
}
if(!$log && $_POST['mark_delete'])
{
$db->update(tbl("video"),array("status","failed_reason"),
array('Failed',"Unable to get video duration")," file_name='".$video['file_name']."'");
$cbvideo->delete_video($video['videoid']);
}
}
$videos = get_videos($params);
$action = $_POST['action'];
if ($action) {
foreach ($videos as $video) {
$log = get_file_details($video['file_name']);
if ($log && $action == 'fix') {
//$duration = $log['output_duration'];
//if(!$duration)
// $duration = $log['duration'];
$duration = parse_duration(LOGS_DIR . '/' . $video['file_name'] . '.log');
if (!$duration)
e("Can't do anything about \"" . $video['title'] . "\"");
else {
$db->update(tbl('video'), array('duration'), array($duration), "videoid='" . $video['videoid'] . "'");
$fixed_array[$video['file_name']] = 'yes';
e("Succesfully updated duration of \"" . $video['title'] . "\" to " . SetTime($duration), 'm');
}
}
if (!$log && $action == 'fail') {
$db->update(tbl("video"), array("status", "failed_reason"), array('Failed', "Unable to get video duration"), " file_name='" . $video['file_name'] . "'");
e("\"" . $video['title'] . "\" status has been changed to Failed", "m");
}
if (!$log && $action == 'delete') {
$db->update(tbl("video"), array("status", "failed_reason"), array('Failed', "Unable to get video duration"), " file_name='" . $video['file_name'] . "'");
$cbvideo->delete_video($video['videoid']);
}
}
$videos = get_videos($params);
}
subtitle("Repair videos duration");
assign('videos',$videos);
assign('fixed_array',$fixed_array);
assign('videos', $videos);
assign('fixed_array', $fixed_array);
template_files('repair_vid_duration.html');
display_it();
?>

View file

@ -1,4 +1,5 @@
<span class="page_title">Re-index Clipbucket <img src="{$imageurl}/help.png" border="0" class="tipsy_tip" title="Re-index simples means to recount everything and update it." /></span>
<h2>Re-index Clipbucket <img src="{$imageurl}/help.png" border="0" class="tipsy_tip" title="Re-index simples means to recount everything and update it." /></h2>
<div style="height:3px;"></div>
Here you can re-index your videos, users or groups statistics. From below select which thing you want to re-index.

View file

@ -3,7 +3,7 @@
{
$('.popover-class').popover();
$('a[rel=tooltip], span[rel=tooltip]').tooltip();
$('img[rel=tooltip], a[rel=tooltip], span[rel=tooltip]').tooltip();
//Setting Up the Left Column and Menu List

View file

@ -1,4 +1,4 @@
<span class="page_title">Re-index Clipbucket <img src="{$imageurl}/help.png" border="0" class="tipsy_tip" title="Re-index simples means to recount everything and update it." /></span>
<h2>Re-index Clipbucket <img src="{$imageurl}/help.png" border="0" rel="tooltip" class="valignTop" title="Re-index simples means to recount everything and update it." /></h2>
<div style="height:3px;"></div>
Here you can re-index your videos, users or groups statistics. From below select which thing you want to re-index.
@ -17,7 +17,7 @@ Here you can re-index your videos, users or groups statistics. From below select
<td align="right">
<form name="reindex_videos" method="get" action="">
<input type="hidden" name="loop_size" value="" id="loop_start" />
<input type="submit" name="index_vids" id="index_vids" value="Reindex Videos" class="button"
<input type="submit" name="index_vids" id="index_vids" value="Reindex Videos" class="btn btn-primary"
onclick="$('#loop_start').val($('#the_loop_size').val())"/>
</form></td>
</tr>
@ -28,7 +28,7 @@ Here you can re-index your videos, users or groups statistics. From below select
<td align="right">
<form name="reindex_users" method="get" action="">
<input type="hidden" name="loop_size" value="" id="loop_start_user" />
<input type="submit" name="index_usrs" id="index_usrs" value="Reindex Users" class="button"
<input type="submit" name="index_usrs" id="index_usrs" value="Reindex Users" class="btn btn-primary"
onclick="$('#loop_start_user').val($('#the_loop_size').val())"/>
</form></td>
</tr>
@ -40,7 +40,7 @@ Here you can re-index your videos, users or groups statistics. From below select
<td align="right">
<form name="reindex_groups" method="get" action="">
<input type="hidden" name="loop_size" value="" id="loop_start_gp" />
<input type="submit" name="index_gps" id="index_gps" value="Reindex Groups" class="button"
<input type="submit" name="index_gps" id="index_gps" value="Reindex Groups" class="btn btn-primary"
onclick="$('#loop_start_gp').val($('#the_loop_size').val())"/>
</form></td>
</tr>
@ -52,7 +52,7 @@ Here you can re-index your videos, users or groups statistics. From below select
<td align="right">
<form name="reindex_collections" method="get" action="">
<input type="hidden" name="loop_size" value="" id="loop_start_cl" />
<input type="submit" name="index_collections" id="index_collections" value="Reindex Collections" class="button"
<input type="submit" name="index_collections" id="index_collections" value="Reindex Collections" class="btn btn-primary"
onclick="$('#loop_start_gp').val($('#the_loop_size').val())"/>
</form></td>
</tr>
@ -64,7 +64,7 @@ Here you can re-index your videos, users or groups statistics. From below select
<td align="right">
<form name="reindex_photos" method="get" action="">
<input type="hidden" name="loop_size" value="" id="loop_start_ph" />
<input type="submit" name="index_photos" id="index_photos" value="Reindex Photos" class="button"
<input type="submit" name="index_photos" id="index_photos" value="Reindex Photos" class="btn btn-primary"
onclick="$('#loop_start_gp').val($('#the_loop_size').val())"/>
</form></td>
</tr>
@ -82,7 +82,12 @@ Here you can re-index your videos, users or groups statistics. From below select
var start_index = '{$next_index}';
var loop_size = '{$smarty.get.loop_size}';
var mode = '{$mode}';
{literal}$(document).oneTime(2000,function(){$(window.location).attr('href', '?loop_size='+loop_size+'&'+mode+'=yes&start_index='+start_index)});{/literal}
setInterval(function() {
$(window.location).attr('href', '?loop_size='+loop_size+'&'+mode+'=yes&start_index='+start_index)
}, 2000);
</script>
redirecting....do not close this window
{else}

View file

@ -1,29 +1,62 @@
<h2>ClipBucket video duration fix</h2>
<div style="margin:10px 0px">
<div class="height10"></div>
<div>
Clipbucket repair video duration using file conversion logs of each file, if there is no log, duration fix is likely not possible.<br />
* with log => those videos that have file conversion log<br />
* with no log => those don't have any conversion log</div>
<div class="height10"></div>
Clipbucket repair video duration using file conversion logs of each file, if there is no log, duration fix is likely not possible.<br />
* with log => those videos that have file conversion log<br />
* with no log => those don't have any conversion log</div>
<div class="cb_div">{if $videos}
<form name="fix duration" method="post">
<input type="submit" name="fix_duration" value="Fix duration (only with log)" class="button"/>
<input type="submit" name="mark_failed" value="Mark failed (with no log)" class="button"/>
<input type="submit" name="mark_delete" value="Delete (with no log)" class="button"/>
</form>
<div style="height:10px"></div>
{foreach from=$videos item=video}
{assign var=filename value=$video.file_name}
{assign var=log value=func->get_file_details($filename)}
<div style="margin-bottom:5px">
<div style="display:inline-block; float:left"><img src="{getThumb vdetails=$video}" height="20" width="20"/></div>
<div style="padding-left:25px">{if $fixed_array.$filename}<strong>[FIXED]</strong> {/if}<a href='edit_video.php?video={$video.videoid}' style="color:#06c; font-weight:bold; text-decoration:{if $fixed_array.$filename}line-through {else}none{/if}
">{$video.title}</a> (duration : <strong>{$vdo.duration|setTime}</strong> | Has Log :<strong>{if $log} <span style="color:#060">yes</span>{else}<span style="color:#ed0000">no</span>{/if} </strong> )</div>
<div style="clear:both"></div>
</div>
{/foreach}
{else}
<em><strong>No videos found with duration less than or equal to 1</strong></em>
<div class="manager-list">
<div class="controller scrolltoFixed white-grad">
<div class="buttons">
<div class="btn-toolbar">
<div class="btn-group">
<a class="btn btn-primary" onclick="$('#action').val('fix');$('#videos-form').submit();" rel="tooltip" title="Only those who have log">Fix Duration</a>
<a class="btn btn-primary" onclick="$('#action').val('fail');$('#videos-form').submit();" rel="tooltip" title="Those who have no log">Mark failed</a>
<a class="btn btn-danger" onclick="$('#action').val('delete');$('#videos-form').submit();" rel="tooltip" title="Those who have no log">Delete</a>
</div>
</div>
<div class="right-button">
</div>
</div>
</div>
<form name="videos-form" method="post" id="videos-form">
<input type="hidden" name="action" id="action" />
<table id="videos-list" class="table table-striped list-block {if !$videos}display-none{/if}">
<thead>
<tr>
<th width="70">#</th>
<th>Title</th>
<th width="70">Duration</th>
<th width="200">Has Log</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{foreach $videos as $video}
<tr>
<td>{$video.videoid}</td>
<td><a href="edit_video.php?video={$video.videoid}">{$video.title}</a> {if $fixed_array.$filename}<span class="label label-success">Fixed</span>{/if}</td>
<td>{$video.duration|setTime}</td>
<td>{if $log}<span class="label label-success">Yes</span>{else}<span class="label label-warning">No</span>{/if}</td>
<td>{$video.status}</td>
</tr>
{/foreach}
</tbody>
</table>
</form>
{if !$videos}
<div class="alert">No videos found with duration less than or equal to 1</div>
{/if}
</div>
</div>