Add scanner step to set review tasks
This commit is contained in:
@@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
docker run --rm -it mariadb:10.11 mariadb --user=videodetect --password=videodetect --host=10.0.1.7 --port=3306 videodetect
|
||||||
+1
-1
@@ -58,7 +58,7 @@ services:
|
|||||||
context: ./api
|
context: ./api
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
container_name: videodetect-api
|
container_name: videodetect-api
|
||||||
restart: no
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "3000:3000"
|
- "3000:3000"
|
||||||
environment:
|
environment:
|
||||||
|
|||||||
+39
-3
@@ -50,6 +50,8 @@ for my $ext (sort { $ignored_extensions{$b} <=> $ignored_extensions{$a} } keys %
|
|||||||
print "Ignored extension $ext: $ignored_extensions{$ext} times\n";
|
print "Ignored extension $ext: $ignored_extensions{$ext} times\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CreateReviewTasks();
|
||||||
|
|
||||||
sub process_file {
|
sub process_file {
|
||||||
my ($file_path) = @_;
|
my ($file_path) = @_;
|
||||||
if (my ($ext)=$file_path =~ /^.+\.(\S+?)$/) {
|
if (my ($ext)=$file_path =~ /^.+\.(\S+?)$/) {
|
||||||
@@ -69,7 +71,12 @@ sub process_file {
|
|||||||
$update_sth->execute($file_size, $row->{id});
|
$update_sth->execute($file_size, $row->{id});
|
||||||
$update_sth->finish();
|
$update_sth->finish();
|
||||||
create_aiscan_task($row->{id});
|
create_aiscan_task($row->{id});
|
||||||
|
} else {
|
||||||
|
my $update_sth = $dbh->prepare("UPDATE videos SET last_scan_time=NOW() WHERE id=?");
|
||||||
|
$update_sth->execute($row->{id});
|
||||||
|
$update_sth->finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
return; # Already exists and size matches
|
return; # Already exists and size matches
|
||||||
}
|
}
|
||||||
print "NEW:$file_path\n";
|
print "NEW:$file_path\n";
|
||||||
@@ -97,9 +104,14 @@ sub process_file {
|
|||||||
|
|
||||||
sub create_aiscan_task {
|
sub create_aiscan_task {
|
||||||
my ($video_id) = @_;
|
my ($video_id) = @_;
|
||||||
$dbh->do("DELETE FROM tasks WHERE video_id=$video_id AND task_type='AISCAN'");
|
create_task($video_id, 'AISCAN');
|
||||||
my $sth = $dbh->prepare("INSERT INTO tasks (video_id, task_type, status) VALUES (?, 'AISCAN', 'PENDING')");
|
}
|
||||||
$sth->execute($video_id);
|
|
||||||
|
sub create_task {
|
||||||
|
my ($video_id, $task_type) = @_;
|
||||||
|
$dbh->do("DELETE FROM tasks WHERE video_id=$video_id AND task_type=?", undef, $task_type);
|
||||||
|
my $sth = $dbh->prepare("INSERT INTO tasks (video_id, task_type, status) VALUES (?, ?, 'PENDING')");
|
||||||
|
$sth->execute($video_id, $task_type);
|
||||||
$sth->finish();
|
$sth->finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,4 +174,28 @@ sub get_video_info {
|
|||||||
codec => $codec // 'unknown',
|
codec => $codec // 'unknown',
|
||||||
duration => $duration,
|
duration => $duration,
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
sub CreateReviewTasks {
|
||||||
|
my $sth = $dbh->prepare("
|
||||||
|
SELECT *
|
||||||
|
FROM tasks
|
||||||
|
WHERE task_type='AISCAN'
|
||||||
|
AND status='COMPLETED'
|
||||||
|
AND JSON_VALUE(results, '$.verdict')=1
|
||||||
|
AND JSON_VALUE(results, '$.reviewed') IS NULL
|
||||||
|
");
|
||||||
|
my $sth_update = $dbh->prepare("
|
||||||
|
UPDATE tasks
|
||||||
|
SET results = JSON_SET(results, '$.reviewed', 1)
|
||||||
|
WHERE id = ?
|
||||||
|
");
|
||||||
|
|
||||||
|
$sth->execute();
|
||||||
|
while (my $row = $sth->fetchrow_hashref) {
|
||||||
|
create_task($row->{video_id}, 'REVIEW');
|
||||||
|
$sth_update->execute($row->{id});
|
||||||
|
}
|
||||||
|
$sth->finish();
|
||||||
|
$sth_update->finish();
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user