Created
October 8, 2011 17:06
-
-
Save maxaf/1272565 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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