Skip to content

Instantly share code, notes, and snippets.

@maxaf
Created October 8, 2011 17:06
Show Gist options
  • Save maxaf/1272565 to your computer and use it in GitHub Desktop.
Save maxaf/1272565 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use HTTP::Proxy qw/:log/;
use Time::HiRes qw/time/;
use HTTP::Proxy::BodyFilter::save;
my $DIR = '/home/max/Music/Pandora';
$DIR =~ s/\/+$//;
die "no dir $DIR" unless -d $DIR;
my $proxy = HTTP::Proxy->new(host => '127.0.0.1', port => 3845);
$proxy->logmask(STATUS);
$proxy
->push_filter(mime => 'audio/mp4',
path => qr!/access!,
response => HTTP::Proxy::BodyFilter::save
->new(filename =>
sub {
my $msg = shift;
my $name = "${DIR}/" . time() . '.mp4';
$proxy->log(STATUS, "saved: " . $name);
return $name;
},
),
);
$proxy->start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment