Home > Debian, Fedora, Gentoo, Linux, PCLinuxOS, Tutorial > Saving flv from Firefox cache using bash scripting

Saving flv from Firefox cache using bash scripting

November 11th, 2007 Leave a comment Go to comments

A few months ago I wrote a tutorial about how to save flv files using python scripting.
That wasn’t so much nerdy so I feel something inside me, like a voice telling out loud: “You can do it in a better nerdy way! I know you can!”
It/She/He was right.

Forget it (if you don’t like python) and see below:


Go in your cache directory:

dierre@thinkcool:~$ cd .mozilla/firefox/cq44xz7v.default/Cache/

and run this command:

for x in `file * | grep -i 'flash video' | cut -c 1-11 | xargs`; do mv $x ~/$x-lol.flv ; done

Bye! P

Share and Enjoy:
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists
  • blinkbits
  • Bumpzee
  • Technorati
  • BlinkList
  • Furl
  • Rec6
  • Simpy
  • Slashdot
  • Facebook
  • LinkedIn
  • TwitThis
  1. SL
    December 1st, 2007 at 00:03 | #1

    In my experience once flash videos are completely loaded in Firefox, they get relocated from the cache into /tmp. So when I do
    $ cd /tmp
    and then execute your second command, it works like a charm.

  2. December 1st, 2007 at 00:44 | #2

    Well, basically it’s the same. The difference is if you set an high space for firefox cache, those videos don’t disappear at reboot as in /tmp.
    Thank you )

  3. SL
    December 1st, 2007 at 13:36 | #3

    Oh, cool. I didn’t know that and always wondered where the videos went. Took me quite a while to figure that out last night. Thanks to you now I don’t only know WHERE they go, but also WHY they go there. Cheers, mate, all the best!

  4. Ash
    September 20th, 2008 at 11:23 | #4

    I use this script to print the filename of the last played (downloaded) multimedial file:

    getlastC.sh:

    srcdir=”`echo $HOME/.mozilla/firefox/*.default/Cache`”
    lasts=”`ls -t \”$srcdir\”/* | grep -v _CACHE_`”
    #srcdir=”/tmp”
    #lasts=”`ls -t \”$srcdir\”/Flash*`”
    # mplay1eo1b5: Audio file with ID3 version 22.0 tag, MP3 encoding
    # Apple QuickTime movie (fast start)
    # ISO Media, Apple QuickTime movie

    #echo “To check: $lasts”

    for last in $lasts; do
    #verbose “Checking: $last”
    if file -b “$last” | grep “Macromedia Flash Video” >/dev/null 2>&1; then
    #verbose “Detected: Macromedia Flash Video”
    ext=”flv”
    elif file -b “$last” | grep “Apple QuickTime movie” >/dev/null 2>&1; then
    #verbose “Detected: ISO Media, Apple QuickTime movie”
    ext=”qt”
    else
    #verbose “No multimedial content detected.”
    ext=”"
    fi

    if [[ "$ext" != "" ]]; then
    #lastbasename=${last##*/}
    #verbose “$0:”
    if [[ "$add_ext" != "" ]]; then
    add_ext=”.$ext”
    fi
    echo “$last$add_ext”
    exit
    fi
    done

    And this one to copy (usage: gimmelastC.sh “Great video from youtube”).

    gimmelastC.sh:

    name=”$1″

    last_ext=”$(getlastC.sh ext 2>/dev/null)”

    ext=${last_ext##*.}
    last=${last_ext%.*}
    lastbasename=${last##*/}

    if [[ -z "$name" ]]; then
    name=”$lastbasename”
    fi

    if [[ -f "$last" ]]; then
    echo “mv \”$last\” \”$name.$ext\”"
    mv “$last” “$name.$ext”
    fi

    Returns the last one multimedial file, then the one before the last one etc. Cheers.

  5. September 20th, 2008 at 23:21 | #5

    Hello!
    I’m trying your script but I get this error:

    ls: impossibile accedere a ””/home/dierre/.mozilla/firefox/6vj606d9.default/Cache””/*: Nessun file o directory
    prova.sh: 22: Syntax error: Unterminated quoted string

    this is the line:
    lasts=”`ls -t \”$srcdir\”/* | grep -v _CACHE_`”

    I think this should fix the problem:

    srcdir=`echo $HOME/.mozilla/firefox/*.default/Cache`
    lasts=`ls -t \”$srcdir\”/* | grep -v _CACHE_`

  1. No trackbacks yet.