My Twitter client available for download
Thursday, June 26th, 2008Somebody out there wants it, so here it is: My twitter cli client, written in PHP
“tw h” for help text.
Somebody out there wants it, so here it is: My twitter cli client, written in PHP
“tw h” for help text.
I’ve been using my own PHP-based CLI Twitter client pretty much since signing up (the Twitter API is so simple). You can view your timeline, tweet, view replies and view and send direct messages all via the command line, and I’ve just added the now-famous Fail Whale image to the error output, see this screenshot for an example.
The source isn’t published at the moment, but if you want it I’ll clean it up (take out my hard-coded username and password) and upload it - just leave a comment.
The whale is based on this one which I turned into my own version reversed with added twitter birdies.
Looks like I overestimated the file encryption entirely on the last BBC update. Fortunately some people still had their own “clear” versions of some programs which they could compare directly with the newly encrypted downloads, noticing that what some of us thought was a DRM scheme was actually just a simple XOR of the video stream with two repeating bytes. A quick perl script later and P Lewis, posting on Paul’s blog had a working video file just like the old scripts produced.
P Lewis has since incorporated this update into a really nice full featured script for browsing and downloading video from iPlayer.
I really hope this update wasn’t what the iPlayer team were doing for the last couple of months. Bloody waste of license payer’s cash if it was.
It’s looking like files downloaded from the iPhone iPlayer interface are now unplayable on devices other than the iPhone. Previously this was wide open to allow anyone to download Quicktime (H.264) video over HTTP directly from the site, but it now appears that although the video can still be downloaded it is encrypted (probably with Fairplay DRM).
More technical details on the Wiki as they come in.
(See also Paul Battley’s blog)
Based on Converting FLAC to MP3 in Linux (I tweaked the LAME settings a bit though):
#!/bin/bash
# Converts all AAC (m4a) files in a folder into mp3s, plus the id3 tag
# Requires faad, lame, id3v2
for a in *
do
# Check the file is a flac file
if [[ "$a" =~ (m4a)$ ]]
then
# Name of outfile
OUTF=`echo “$a” | sed s/\.m4a/.mp3/g`
echo “$a => $OUTF”
# Capture all the FLAC metadata
ARTIST=`faad -i “$a” 2>&1 | grep “^artist” | sed “s/.*: //g”`
TITLE=`faad -i “$a” 2>&1 | grep “^title” | sed “s/.*: //g”`
ALBUM=`faad -i “$a” 2>&1 | grep “^album” | sed “s/.*: //g”`
GENRE=`faad -i “$a” 2>&1 | grep “^genre” | sed “s/.*: //g”`
TRACKNUMBER=`faad -i “$a” 2>&1 | grep “^track” | sed “s/.*: //g”`
YEAR=`faad -i “$a” 2>&1 | grep “^date” | sed “s/.*: //g”`
# echo “$ARTIST - $TITLE - $GENRE - $TRACKNUMBER”
# Convert the audio data from AAC to MP3
faad -w “$a” | lame -V 2 -m j -b 192 -B 224 -s 44.1 - “$OUTF”
# Tag the resulting MP3 with the captured metadata
id3v2 -t “$TITLE” -T “$TRACKNUMBER” -a “$ARTIST” -A “$ALBUM” -g “$GENRE” -y “$YEAR” “$OUTF”
fi
done
A quick howto…
If you’re using a desktop debian distro, just use SoundConverter:
sudo apt-get install soundconverter
If you’re shelling into a server (or you just prefer CLI), you’ll need a script and a few audio tools. Here’s the bash script (based on this one):
#!/bin/bash
# Converts all flac files in a folder into mp3s, plus the id3 tag
# Requires flac, metaflac, lame, id3v2
for a in *
do
# Check the file is a flac file
if [[ "$a" =~ flac$ ]]
then
# Name of outfile
OUTF=`echo “$a” | sed s/\.flac/.mp3/g`
echo “$a => $OUTF”
# Capture all the FLAC metadata
ARTIST=`metaflac “$a” –show-tag=ARTIST | sed s/.*=//g`
TITLE=`metaflac “$a” –show-tag=TITLE | sed s/.*=//g`
ALBUM=`metaflac “$a” –show-tag=ALBUM | sed s/.*=//g`
GENRE=`metaflac “$a” –show-tag=GENRE | sed s/.*=//g`
TRACKNUMBER=`metaflac “$a” –show-tag=TRACKNUMBER | sed s/.*=//g`
# Convert the audio data from FLAC to MP3
flac -c -d “$a” | lame -m j -b 256 -s 44.1 - “$OUTF”
# Tag the resulting MP3 with the captured metadata
id3v2 -t “$TITLE” -T “$TRACKNUMBER” -a “$ARTIST” -A “$ALBUM” -g “$GENRE” “$OUTF”
fi
done
Save that off in your path, make it executable:
chmod u+wrx flac2mp3
and run it from an location with mp3s in. It’ll convert all FLAC files to identically named MP3 files with the id3v2 information based on the FLAC metadata.
You’ll need flac, metaflac, id3v2 and lame:
sudo apt-get install flac id3v2 lame
Happy converting ![]()
Thought I’d see if I could get a download script in just one line of console utilities. I could (although it’s actually 8 separate commands split over 12 lines, it’s still executed as one single bash statement). A pretty concise bit of code it is, too:
curl -b cookies.txt -A "Apple iPhone v1.1.3 CoreMedia v1.0.0.4A93" -H "Range: bytes=0-" -o iplayer_download.mov \
$( \
curl -i -c cookies.txt -A "Apple iPhone v1.1.3 CoreMedia v1.0.0.4A93" -H "Range: bytes=0-1" \
$( \
curl -i -A "iPhone, LOL" -c cookies.txt $1 \
| grep "pid :" \
| cut -d\' -f2 \
| sed "s/\([0-9a-z]\)/http:\/\/www.bbc.co.uk\/mediaselector\/3\/auth\/iplayer_streaming_http_mp4\/\1/” \
) \
| grep Location \
| cut -d: -f2,3 \
)
I’ve been doing two fun things this week. The first was playing around with the iPlayer again. Last Friday (7th March) the Beeb made the rather confusing move of releasing an iPhone-optimised version of the iPlayer. Now, the iPhone doesn’t support Flash, so it was all H264 over HTTP. You could get to this resource on a predictable URL just by changing your user agent to that of an iPhone. No DRM, no proprietary streaming format, and for a platform which is minority in the extreme, making a mockery of the “big platforms first” defence that the BBC used for rolling out Windows-only versions of iPlayer.
Anyway, a few days after this was all revealed, they “patched” the service, which actually meant they just checked on the “Range” HTTP header as well as the “User-Agent” one. Pretty weak. By the end of that same day, I’d updated my download script, and so had Paul Battley, followed by johnsto who has written an XBMC version of the exploit.
What will Auntie do next? Let the games commence…
I’ve also put a PC into my car this week, written up on the project page.
Over a year since the last update, yeah I know. I’ve been busy with other stuff
I thought I’d better link this up though. At the end of December 2007 the BBC launched the web-based Flash version of it’s iPlayer server (which allows you to watch TV from within the last week). This was prompted somewhat by the backlash against the Windows XP only version of their iPlayer software which pissed off a lot of Mac, Linux (and even Vista) users. The new service works on any browser with a recent version of the Flash player installed, thus requiring no other specialist software.
This is great because it also means that the shows (that I’ve already paid for with my license fee) are no longer restricted to Windows DRM and it’ll work on my Ubuntu laptop.
Predictably, a thread had already started on the XBox Media Center forums prior to this requesting a script to make iPlayer content play on XBMC although with DRM and closed source software this was unlikely to happen.
After the web player was launched, the thread exploded into activity and it was clear that a few people in the community (notably Phil Wilson) and myself were trying to work out a way of side-stepping the iPlayer flash client to get to the juicy video goodness behind it.
Skip forward a week or so and after I’d trawled through a decompiled version of the flash player, I’ve come up with a script which does just that:
Give this CLI script a programme ID (PID) or the URL of a BBC programmes page or iPlayer page and it will output the media stream. The community is now waiting for some enterprising chap to get RTMP support into mPlayer or curl.
The discussion is currently continuing with lots of frightfully intelligent people on the BBC Backstage mailing list.
Regular visitors may have noticed I’m a bit of a del.icio.us nut. I use it for everything. The problem I’m getting now, after about 18 months of use is that I’ve got so many tags in my tag cloud that it actually takes quite a bit of CPU and RAM to render one of my pages.
Step up delite.strawp.net - a quick one-pager that I just threw together. Basically, stick the path you’d want from del.icio.us on the end of that address and get a stripped-down “lite” version of that page that isn’t going to crash your PDA, phone or Wii, e.g. delite.strawp.net/strawp/videos.
It’s not going to be lightening quick because it still has to request the original page from del.icio.us but it should make accessing your bookmarks on a small device less of a headache.
Apologies for the hopeless uptime of this site - my host appears to have fired everyone that knew what they were doing and replaced them with a pack of drooling gibbons.