summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetter Reinholdtsen <pere@hungry.com>2009-10-22 09:07:22 +0000
committerPetter Reinholdtsen <pere@hungry.com>2009-10-22 09:07:22 +0000
commit3fa0d772acde0c1ae48be52cd6b5bf9c0ae75ce1 (patch)
treede00478c74e4e5bc9da4772a5c3d314ed982cae2
parent3e73e2e259dfb304a0853af0c4188ae0e492e474 (diff)
Simplify code and always retry fetching thumbs if the files are
missing.
-rwxr-xr-xfrikanalen/bin/update_video_diff.pl22
1 files changed, 8 insertions, 14 deletions
diff --git a/frikanalen/bin/update_video_diff.pl b/frikanalen/bin/update_video_diff.pl
index 6a7333f..3d24efa 100755
--- a/frikanalen/bin/update_video_diff.pl
+++ b/frikanalen/bin/update_video_diff.pl
@@ -12,15 +12,12 @@
use Data::Dumper;
use XML::Simple;
my $localvideo_dir = '/data/video/frikanalen';
+my $localthumbs_dir = '/data/video/frikanalen/thumbs';
my $meta = XMLin("$localvideo_dir/meta.xml");
# Make sure convert is in the path
$ENV{PATH} = $ENV{PATH} . ":/usr/local/bin";
-opendir LOCALVIDEO_DIR, $localvideo_dir or die "Can't open directory $localvideo_dir: $!\n";
-@localvideos = grep /^.+\.ogv/, readdir(LOCALVIDEO_DIR);
-closedir HOST_DIR;
-
&get_new_vids;
###### Functions #######
@@ -33,19 +30,16 @@ sub get_new_vids {
# Uncomment this line if you want to refresh _all_ thumbs.
#&get_thumb($meta->{$metaid}->{'ImageUri'},$file_id);
$exists = 'false';
- foreach my $local_file (@localvideos) {
- $local_file =~ s/.ogv//;
- if ($file_id eq $local_file) {
- $exists = 'true';
- print "$file_id is here\n" if $ARGV[0] eq "debug";
- }
- }
- if ($exists ne 'true') {
+ unless ( -f "$localvideo_dir/$file_id.ogv") {
print "Fetching video $file_id \n" if $ARGV[0] eq "debug";
if ($meta->{$metaid}->{'VideoOgvUri'} =~ /^http:/) {
&get_http_vid($meta->{$metaid}->{'VideoOgvUri'},$file_id);
- &get_thumb($meta->{$metaid}->{'ImageUri'},$file_id);
}
+ } else {
+ print "$file_id is here\n" if $ARGV[0] eq "debug";
+ }
+ unless ( -f "$localthumbs_dir/$file_id.jpg") {
+ get_thumb($meta->{$metaid}->{'ImageUri'},$file_id);
}
}
}
@@ -55,7 +49,7 @@ sub get_thumb {
my ($url, $file_id) = @_;
# foreach my $metaid (keys %$meta) {
print "Fetching thumbnail for video $file_id\n";
- `/usr/local/bin/wget --quiet -O - $url |convert - -scale 25% $localvideo_dir/thumbs/$file_id.jpg`;
+ `/usr/local/bin/wget --quiet -O - $url |convert - -scale 25% $localthumbs_dir/$file_id.jpg`;
# }
}