I wrote this little script the other day. This is a small program that basically finds flash movies running in a browser and loads them. the code looks something like this.
the code:
path=$(stat -c %N /proc/*/fd/* 2>&1|awk -F[\`\'] '/lash/{print$2}') pid=$(echo $path | cut -d / -f3) name=$( ps --no-header -o comm -p $pid) mid=$(wmctrl -l | grep -i $name) filename=`echo $mid | cut -c 21-$(($(echo $mid | wc -c)-16))` cp $path /home/Downloads/"$filename.avi"
This is just a PART of the code. The first line of code gets the path to the remote temp file. The second line gets pid. Thirdly, the name of the process. Close the window ID and window title. The fifth line manipulates the wmctrl output to retrieve the name of the video being played (most of the time the video name is included in the window title ... for example, youtube)
Now, when this script is run after buffering the entire video, it works flawlessly (the above script works for google chrome) .. and copies the file from the / proc // fd folder to the download folder and changes its name to the extracted file name.
Now here is the trick part.I want to automate this code, for example, for me to run this code, now I have to wait for the video to finish buffering (say youtube).
I want this script to detect when a video has finished buffering, and then continue copying without having to manually run it at the end of the video.
So, is there a way you can find out when a video has finished buffering?
I start. All suggestions for improving the code are welcome.
source share