Mittwoch, 12. Dezember 2012

[Bash] Play Flash-video with your player

I just improved my code from yesterday (

The player of choice is now nvlc which is a ncurses version of VLC. I took it because it still is command line but also has some console user interface with playlist and such things.

Because now the scripts not just plays "deleted" videos but also videos that are still lying around in cache. This is kind of the old style of how to access flash-movie e.g. for saving it.
The search-path for that is
"~/.mozilla/firefox/*.*/Cache" for firefox and
"~/.cache/chromium/*/*" for chromium.

For the playlist that is created a temporary file in "/tmp/browserFlashFiles.cache.log" is used and after finishing it will be deleted.
The minimum filesize of the videos is set to 1M.

Oh. There is also vim involved. It is used to delete some characters from the playlist. I guess there is an easy way without it. But hey! It works ;-)

YouTube uses some other way to save there videos. Therefor this script won't play those files.
Youtube-dl ( ) is a good place to start. When you start to download a video you should immediately be able to also play the still growing file.

The way would be for example:
youtube-dl -oyt_dl & nvlc yt_dl.part

Another way is to use
For a YouTube-video like e.g.
you add "ss" before the so it looks like this:

You should be getting to a website with some download links on the right site for e.g. MP4 360p and MP4 720p. For different videos there are different versions available. Copy your preferred link location and open it with your player.
For me it looks like this:
mplayer ""

Happy watching!

Btw.: Now here is the new code:
( )
#You should be able to change this variable to the player of your liking

pid=`pgrep -f`

`echo "" > $cacheFile`
rm $cacheFile
for p in $pid
    deles=`ls -l1 /proc/$p/fd/ | grep deleted`
    wcDeles=`echo $deles | wc -w`
    wlDeles=`ls -l1 /proc/$p/fd/ | grep -c deleted`

    wPerLine=`expr $wcDeles / $wlDeles`
    for d in $deles
        for numLine in `seq 1 $wlDeles`
            pos=`expr $wPerLine \* $numLine - $offset`
            if [ $i -eq $pos ]
                echo "/proc/$pid/fd/$dval" >> $cacheFile
        i=`expr $i + 1`

`find $pathFF -size +1M -type f -exec file {} \; | grep -E "(Media|Video)" >> $cacheFile`
`find $pathChrome -size +1M -type f -exec file {} \; | grep -E "( Media|Video)" >> $cacheFile`
vim $cacheFile "+%s/:.*//" "+wq"
cat $cacheFile
$myplayer `cat $cacheFile`
rm $cacheFile