Hello there,
This a simple example, and a contribution, to Cache Video project using bash script to get some statistics from youtube_cache.log.
For execute this, use: ./script.sh n
where n = number of day ago to get statistics.
#!/bin/sh # lopan dot eti at gmail dot com (Author: Lopan) # GPL2 #Variables VIDEO_CACHE_DIR=/var/spool/video_cache VIDEO_CACHE_LOG=/var/log/youtube_cache/youtube_cache.log* #Arguments if [ -z $1 ] then DA=0 #if arg $1 = NULL use 0 (0 = today) else DA=$1 #set n days ago fi #Search and sum as total for files are gets from cache TDW=0 for DW in $(cat $VIDEO_CACHE_LOG | grep -w `date --date="$DA days ago" '+%Y-%m-%d'` | grep 303:http | awk '{print $5}'); do VDW=0 VDW=`find $VIDEO_CACHE_DIR -name $DW.flv -exec ls -l {} \; | awk '{print $5}'` TDW=$((TDW+VDW)) #Update the time of file (to date = $DA days ago) if the file are got on day. # #You can use this in future to delete old files. #The old files (if you use this command) represent the files are not accessed on cache. find $VIDEO_CACHE_DIR -iname $DW'*' -exec touch -t `date --date="$DA days ago" '+%m%d%H%M'` {} \; done #Search and sum as total for files are download on day FDDWT=0 for DDW in $(cat $VIDEO_CACHE_LOG | grep -w `date --date="$DA days ago" '+%Y-%m-%d'` | grep "Video was downloaded and cached." | awk '{print $5}'); do FDDW=`find $VIDEO_CACHE_DIR -name $DDW.flv -exec ls -l {} \; | awk '{print $5}'` FDDWT=$((FDDWT+FDDW)) done #Print resume echo "Daily economy (`date --date="$DA days ago" '+%Y-%m-%d'`): `echo $TDW/1024/1024 | bc` MB" echo echo "Total in MB of videos in cache: `du -csh $VIDEO_CACHE_DIR | grep total | awk '{print $1}'`" echo "Total in MB of videos download by day (`date --date="$DA days ago" '+%Y-%m-%d'`): `echo $FDDWT/1024/1024 | bc` MB"
Lopan

