Changeset 37933


Ignore:
Timestamp:
2023-08-13T22:05:53+12:00 (9 months ago)
Author:
davidb
Message:

Now generates JSON file based on thumbnail images

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gs3-installations/thewillow/trunk/sites/thewillow/collect/community-contributions/prepare/04-PREP-VIDEOS.sh

    r37867 r37933  
    33cd the-willow-videos
    44
     5echo ""
     6echo "----"
     7echo "Unzipping"
     8echo "----"
     9
    510for video_zf in *.zip ; do
    6     video_dir=${video_zf%.*}
    7 
     11    video_dir=${video_zf%%-*.*}
     12   
    813    if [ ! -d "$video_dir" ] ; then
    914    echo "Unzipping: $video_zf"
     
    1419done
    1520
     21# Rename MP4 so it doesn't have ' (with subtitles') in it
     22echo ""
     23echo "----"
     24echo "Renaming MP4 videos"
     25echo "----"
     26
     27for video_zf in *.zip ; do
     28    video_dir=${video_zf%%-*.*}
     29
     30    src_mp4_file=$(ls "$video_dir/"*" (with subtitles)".mp4 2> /dev/null)
     31
     32    if [ "x$src_mp4_file"  != "x" ] ; then
     33    dst_mp4_file="${src_mp4_file% (with subtitles).mp4}.mp4"
     34    echo "Renaming $src_mp4_file -> $dst_mp4_file"
     35    /bin/mv "$src_mp4_file" "$dst_mp4_file"
     36    else
     37    echo "Skipping processing MP4 video in $video_dir, as already renamed"
     38    fi   
     39
     40
     41    if [ "$video_dir" = "1 In The Beginning" ] ; then
     42        if [ -d "$video_dir/thumbnails - in the beginning" ] ; then
     43        echo "  Fixing lowercase thumbnail directory for $video_dir"
     44        /bin/mv "1 In The Beginning/thumbnails - in the beginning"  "1 In The Beginning/Thumbnails - In the Beginning"
     45    fi
     46    fi
     47done
     48
     49echo ""
     50echo "----"
     51echo "Processing Thumbnails to generate JSON files"
     52echo "----"
     53
     54for video_zf in *.zip ; do
     55    video_dir=${video_zf%%-*.*}
     56
     57    thumbnail_dir=$(ls -d "$video_dir/Thumbnails - "*)
     58    assocfile_root=${thumbnail_dir##* - }
     59
     60    json_file="$video_dir/$assocfile_root.json"
     61
     62    if [ ! -f "$json_file" ] ; then
     63    echo "Processing Thumbnail directory: $thumbnail_dir"
     64    echo "  ... for '$assocfile_root'"
     65
     66    num_thumbnails=$(ls "$thumbnail_dir/"*".png" | wc -l)
     67    echo "  Number matching PNGs: $num_thumbnails"
     68   
     69    echo "["                                     > "$json_file"
     70
     71    i=0
     72    for full_f in "$thumbnail_dir/"*".png" ; do
     73        echo "  [$i]: $full_f"
     74       
     75        f=${full_f##*/}
     76        timestamp_md=${f%% *}
     77       
     78        label_with_ext=${f#* }
     79        label_md=${label_with_ext%.png}
     80       
     81        label_md=`echo $label_md  | sed "s/we_re/we're/"`
     82       
     83        echo "  {"                                >> "$json_file"
     84        echo "    'timestamp': '$timestamp_md',"  >> "$json_file"
     85        echo "    'label'    : '$label_md'"       >> "$json_file"
     86        echo "  }"                                >> "$json_file"
     87
     88        i=$((i+1))
     89
     90        if [ $i -lt $num_thumbnails ] ; then
     91        echo "  ,"                            >> "$json_file"
     92        fi
     93    done
     94    echo "]"                                      >> "$json_file"
     95    else
     96    echo "JSON file already exits => Skipping Thumbnail directory: $thumbnail_dir"
     97    fi
     98
     99   
     100done
     101
     102
     103echo ""
     104
    16105cd ..
Note: See TracChangeset for help on using the changeset viewer.