Remote network usage

This commit is contained in:
Ryan
2026-09-13 18:40:02 -04:00
parent dbbbaa2ea2
commit ad3deb3226
6 changed files with 36 additions and 19 deletions
+6 -4
View File
@@ -16,7 +16,7 @@ $SIG{INT} = sub { die "Interrupted\n"; };
my $dbh = DBI->connect("DBI:mysql:database=$db_name;host=$db_host", $db_user, $db_pass);
my @video_extensions = qw(mp4 mkv avi mov flv wmv mpg mpeg webm);
my @video_extensions = qw(mp4 mkv avi mov flv wmv mpg mpeg webm m4v);
my %ignored_extensions;
my @dir_queue = ('/data');
@@ -46,18 +46,19 @@ while(my $dir = shift @dir_queue) {
# Any entry where last_scan_time < $now is considered deleted or moved, so we can mark them as such
my $sth_delete = $dbh->prepare("DELETE FROM videos WHERE last_scan_time < ? OR last_scan_time IS NULL");
$sth_delete->execute($now);
print "Ignored extensions: " . join(", ", keys %ignored_extensions) . "\n";
for my $ext (sort { $ignored_extensions{$b} <=> $ignored_extensions{$a} } keys %ignored_extensions) {
print "Ignored extension $ext: $ignored_extensions{$ext} times\n";
}
sub process_file {
my ($file_path) = @_;
if (my ($ext)=$file_path =~ /^.+\.(\S+?)$/) {
unless (grep { lc($ext) eq $_ } @video_extensions) {
$ignored_extensions{lc($ext)} = 1;
$ignored_extensions{lc($ext)}++;
return; # Not a video file
}
}
print "$file_path\n";
my $sth = $dbh->prepare("SELECT id,file_size FROM videos WHERE file_path=?");
$sth->execute($file_path);
if(my $row = $sth->fetchrow_hashref()) {
@@ -71,6 +72,7 @@ sub process_file {
}
return; # Already exists and size matches
}
print "NEW:$file_path\n";
my $info = get_video_info($file_path);
unless ($info) {