8/12/09

Randrandrandom

Once something awesome happened to me, I was downloading an album by torrent and I started listening to it at 50% of the total download. It was just l0L, because torrents download in "random" parts I listened to random parts of random length of random files non-stopping, and I loved it.


So I came up with this:


let R=$RANDOM%12000+1; let T=$RANDOM%2000+100; find "$1" -name "*mp3" -type f -print0 | xargs -0 mpg123 -C -Z -k $R -n $T


This one liner generates a random number between 1 and 12001 to use as the frame from which to start playing the other random number (between 100 and 2100) of frames from a random file in the directory specified by $1 (I use it in a script, to one-line it put the directory name directly there).


I love this shit, mainly because I listen to all kinds of shit: dnb, trance, brakcore, house, techno, minimal, alt-rock, psychedelic, goa, chillout, ambient, 8bit and noise; and randomixing between this stuff creates a fucking awesome effect.

6/12/09

Youtuber

I always hated flash, from the beginning, when it was just in some random adds.


But lately my computer has been kinda slow cause of a lot of programs that are now always open (nicotine+, transmisison, jdownloader) since I bought myself a Seagate 1TB hard disk, and when watching youtube form firefox it got reeeaaaallyyyyy slow, so I started to use ffplay from bash to play the flvs firefox downloads from youtube and places in /tmp/Flash*, but firefox alone used a lot of CPU and RAM.


So today I invented this:


wget -O - "$(youtube-dl -g $@)" | ffplay -


This simple looking commands uses youtube-dl script from Ubuntu repos to get the real URL of the youtube video, pass it to wget who downloads it and streams the flv to ffplay, who plays the video taking almost no CPU or RAM and even not writing the hard disk.


I putted it in a bash script (I know a function would have worked too) and now just typing a single command I get a youtube video in a small window with mplayer-alike control bindings.