You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
912 B

10 years ago
#!/usr/bin/perl
use strict;
use warnings;
use lib 'lib';
use POSIX qw(tmpnam);
10 years ago
use Test::More tests => 4;
10 years ago
10 years ago
require_ok('Text::Playlist::M3U');
10 years ago
10 years ago
my $pls = new_ok('Text::Playlist::M3U' => []);
10 years ago
10 years ago
my $text = <<M3U;
10 years ago
#EXTM3U aspect-ratio=4:3
10 years ago
#EXTINF:-1,First channel
10 years ago
http://127.0.0.1:1027/udp/224.3.22.7:1234
#EXTINF:-1 cn-id=34727751,Second channel +8
http://127.0.0.1:1027/udp/224.3.23.9:1234
10 years ago
M3U
my $path = tmpnam();
open my $FH, ">", $path;
print $FH $text;
10 years ago
close $FH;
my $out = [{
10 years ago
attrs => {},
10 years ago
file => 'http://127.0.0.1:1027/udp/224.3.22.7:1234',
title => 'First channel',
duration => '-1',
}, {
attrs => { 'cn-id' => '34727751' },
file => 'http://127.0.0.1:1027/udp/224.3.23.9:1234',
title => 'Second channel +8',
duration => '-1',
}];
my @items = $pls->load($path);
is_deeply(\@items, $out, "Loading test playlist");
10 years ago
unlink $path;
is($text, $pls->dump(@items));
10 years ago
10 years ago
exit 0;