X-Git-Url: https://git.camperquake.de/gitweb.cgi?p=videosite.git;a=blobdiff_plain;f=videosite-dl.pl;h=b761e182436e085e18e26f9c30967bb4afe37acc;hp=3a711f1d1de6032001fd80b74dc557b37db4dd42;hb=cbfc87367cce587d41ce8848edd7c4e9350e0943;hpb=28e365c0f06c832e5c1e3f3a852a18ab03045c5f diff --git a/videosite-dl.pl b/videosite-dl.pl index 3a711f1..b761e18 100755 --- a/videosite-dl.pl +++ b/videosite-dl.pl @@ -6,6 +6,9 @@ use File::Spec; use File::Basename; use Module::Load; use Cwd qw(realpath); +use Carp; + +$SIG{ __DIE__ } = sub { Carp::confess( @_ ) }; my $info = 0; my $debug = 0; @@ -13,8 +16,10 @@ my %config = ( mode => 'download', getter => 'filegetter', 'plugin.youtube.QUALITY' => 'hd', + 'plugin.youtube.ADAPTIVE' => 1, 'plugin.filegetter.FILEPATTERN' => './%3$s.flv', ); +my @options; sub link_callback { my $m = shift; @@ -23,27 +28,23 @@ sub link_callback { foreach (keys(%{$m})) { printf("%s: %s\n", $_, defined($m->{$_})?$m->{$_}:'(undef)'); } - return 0; + return 1; } else { print("Downloading $m->{'TITLE'}\n"); - return 1; + return 0; } } -GetOptions("i" => \$info, "d" => \$debug); +GetOptions("i" => \$info, "d" => \$debug, "o=s" => \@options); +%config = (%config, map { split(/=/, $_, 2) } @options); push(@INC, dirname(realpath($0))); load 'libvideosite'; unless(libvideosite::register_api({ - config_init => sub {}, - config_save => sub {}, - config_get => sub { return $config{join(".", @{$_[0]})} }, - config_set => sub { $config{join(".", @{$_[0]})} = $_[1] }, - config_has => sub { exists($config{join(".", @{$_[0]})}) }, - config_del => sub { delete($config{join(".", @{$_[0]})}) }, link_callback => \&link_callback, + _config_default => sub { return \%config }, _debug => sub { return $debug }, })) { die("Error registering API: $libvideosite::error"); @@ -57,6 +58,7 @@ foreach (@ARGV) { printf("Handling %s...\n", $_); libvideosite::check_for_link({ message => $_, - ewpf => sub { print @_, "\n" }, + io => sub { print @_, "\n" }, + window => "", }); }