Browse Source

handle 599 specially and add some longer timeouts

themage
theMage 4 years ago
parent
commit
c90f50c5a4
1 changed files with 8 additions and 4 deletions
  1. 8 4
      lib/CinePantufas/Client/Transmission.pm

+ 8 - 4
lib/CinePantufas/Client/Transmission.pm

@ -36,7 +36,7 @@ sub add_torrent {
36 36
  my $config = CinePantufas::Setup->config('transmission');
37 37
  my $url = $config->{api_url};
38 38
39
  my $ua = HTTP::Tiny->new();
39
  my $ua = HTTP::Tiny->new(timeout => 180);
40 40
41 41
  unless ($session and $sesstime>(time-60) ) {
42 42
    my $resp = $ua->get($url);
@ -74,9 +74,13 @@ sub add_torrent {
74 74
  } elsif ( $resp->{status} == 409 and $retry--) {
75 75
    $session = undef;
76 76
    return $class->add_torrent( $link, $retry );
77
  } elsif ( $res->{status} == 599 ) {
78
    if ($ENV{DEBUG}) {
79
      print STDERR "got a 599: $url => $content\n+++++++++\n$resp->{content}\n\n"; 
80
    }
77 81
  } else {
78
    my $more = $ENV{DEBUG} ? $resp->{content} : '';
79
    warn "error on transmission: $resp->{status} $resp->{reason}\n$more\n";
82
    my $more = $ENV{DEBUG} ? ($resp->{content}."\n") : '';
83
    warn "error on transmission: $resp->{status} $resp->{reason}\n$more";
80 84
  }
81 85
82 86
  return 0;
@ -140,7 +144,7 @@ sub remove_torrent {
140 144
  my $config = CinePantufas::Setup->config('transmission');
141 145
  my $url = $config->{api_url};
142 146
143
  my $ua = HTTP::Tiny->new();
147
  my $ua = HTTP::Tiny->new(timeout => 120);
144 148
145 149
  unless ($session) {
146 150
    my $resp = $ua->get($url);