From: Alan J. Pippin Date: Sat, 19 Nov 2011 04:28:53 +0000 (-0700) Subject: Added protection about only running the organizing/merging if video files haven't... X-Git-Url: http://git.pippins.net/embedvideo/.git/%27%20.%20%24this-%3Ephpgw_js_url%20.%20%27/jscalendar/%24link?a=commitdiff_plain;h=32f5e50c17ae4efc216a50ef2cecae7e2dcf6508;p=videoscripts%2F.git Added protection about only running the organizing/merging if video files haven't changed in the last X minutes. --- diff --git a/merge_videos_by_day b/merge_videos_by_day index b285f1a..a6b509b 100755 --- a/merge_videos_by_day +++ b/merge_videos_by_day @@ -17,13 +17,12 @@ my $srcpathname = $opt_s; my $compute_host = "pippin.pippins.net"; # I need this since this script is run from a virtual machine my $use_compute_host = 1; # Set to 1 to use a remote compute host to run the mkvmerge command. Set to 0 to use the local host to run it. my $make_mkv = "/naspool/videos/bin/make_mkv"; # Update this to be the path to the make_mkv script -my $minage = "+10"; # Files must be older than X minutes to move my $owner = "ajp"; # The owner of the files after they are moved my $group = "pip"; # The group of the files after they are moved my $mode = "664"; # The mode to set on each file after they are moved my $video_suffix = "000"; # What number to start with when adding an incrementing suffix to the end of the video clip to avoid name collisons my $video_title_prefix = "HomeVideos:"; # What text to put on the front of the title for the merged video being created -my $find_cmd = "find \"$srcpathname/\" -cmin $minage -iregex \".*\.mov\" -o -iregex \".*\.3gp\" -o -iregex \".*\.mp4\" -o -iregex \".*\.mts\""; +my $find_cmd = "find \"$srcpathname/\" -iregex \".*\.mov\" -o -iregex \".*\.3gp\" -o -iregex \".*\.mp4\" -o -iregex \".*\.mts\""; #################################################################################################### sub usage { diff --git a/organize_videos b/organize_videos index 539c2c1..86047a1 100755 --- a/organize_videos +++ b/organize_videos @@ -14,13 +14,15 @@ use File::Pid; my $srcpathname = "/naspool/pictures/New Photos"; # Path to look for videos to move from my $dstpathname = "/naspool/videos/HomeVideos"; # Path to move the videos to my $merge_videos_by_day = "/naspool/videos/bin/merge_videos_by_day"; -my $minage = "+10"; # File creation dates must be older than X minutes to move +my $minage = "+30"; # Video file creation dates must not have changed in the last X minutes to process any of the video files my $owner = "ajp"; # The owner of the files after they are moved my $group = "pip"; # The group of the files after they are moved my $mode = "664"; # The mode to set on each file after they are moved my $playlist_extension = "pls"; # The extension to use when creating playlist files my $video_suffix = "000"; # What number to start with when adding an incrementing suffix to the end of the final video clip to avoid name collisions -my $find_cmd = "find \"$srcpathname/\" -cmin $minage -a \\( -iregex \".*\.mov\" -o -iregex \".*\.3gp\" -o -iregex \".*\.mp4\" -o -iregex \".*\.mts\" -o -iregex \".*\.mkv\" \\)"; +my $movie_file_ext = "-iregex \".*\.mov\" -o -iregex \".*\.3gp\" -o -iregex \".*\.mp4\" -o -iregex \".*\.mts\" -o -iregex \".*\.mkv\""; +my $find_changed_cmd = "find \"$srcpathname/\" -not -cmin $minage -a \\( $movie_file_ext \\)"; +my $find_cmd = "find \"$srcpathname/\" $movie_file_ext"; #################################################################################################### # Sanity check @@ -123,6 +125,10 @@ if(defined $opt_p) { $video_files_found=`$find_cmd`; if(!$video_files_found) { exit 0; } +# Only proceed if no files have changed in the past $cmin minutes +$changed_files_found=`$find_changed_cmd`; +if($changed_files_found) { exit 0; } + # Only one instance of this script running at a time my $pidfile = File::Pid->new({file => "/tmp/organize_videos.pid"}); exit if $pidfile->running();