Browse Source

expire transmission session

themage
theMage 5 years ago
parent
commit
02d755000f
1 changed files with 3 additions and 1 deletions
  1. 3 1
      lib/CinePantufas/Client/Transmission.pm

+ 3 - 1
lib/CinePantufas/Client/Transmission.pm

@ -10,6 +10,7 @@ use HTTP::Tiny;
10 10
use JSON qw(to_json from_json);
11 11
12 12
my $session;
13
my $sesstime=0;
13 14
14 15
my %ok_res = map {$_ => 1} (
15 16
  'success',
@ -36,11 +37,12 @@ sub add_torrent {
36 37
37 38
  my $ua = HTTP::Tiny->new();
38 39
39
  unless ($session) {
40
  unless ($session and $sesstime>(time-60) ) {
40 41
    my $resp = $ua->get($url);
41 42
42 43
    if ($resp->{headers}->{'x-transmission-session-id'}) {
43 44
      $session = $resp->{headers}->{'x-transmission-session-id'};
45
      $sesstime = time;
44 46
    }
45 47
  }
46 48