Skip to content

Instantly share code, notes, and snippets.

@jberger
Last active December 5, 2017 16:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jberger/b5e35ffd5231ad44ef6178d4a94fba27 to your computer and use it in GitHub Desktop.
Save jberger/b5e35ffd5231ad44ef6178d4a94fba27 to your computer and use it in GitHub Desktop.
use Mojo::Base -strict;
use Mojo::UserAgent;
my $ua = Mojo::UserAgent->new->max_redirects(10);
my $success = 0;
$ua->on(start => sub {
my ($ua, $tx) = @_;
$tx->res->content->unsubscribe('read')->on(read => sub {
my (undef, $chunk) = @_;
$success = 1 if length $chunk;
$tx->res->error({message => 'interrupting stream'});
});
});
my $url = 'http://rrr.sz.xlcdn.com/?account=rtv_oost&file=RadioOost_mp3&type=live&service=icecast&output=m3u';
$ua->get($url);
say $success ? 'Success' : 'Failure';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment