| 1 | 1 | ▶ | use strict; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 2 | 1 | ▶ | use File::Temp qw/:seekable/; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 3 | 1 | ▶ | use Webqq::Client::Util qw(console); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 4 | 0 | ▶ | sub Webqq::Client::_get_offpic { | ||||||||||||||||||||
|
Subroutine
_get_offpic: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||
| 5 | 0 | my $self = shift; | |||||||||||||||||||||
| 6 | 0 | ▶ | return if $self->{type} ne 'smartqq'; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 7 | 0 | my $file_path = shift; | |||||||||||||||||||||
| 8 | 0 | my $from_uin = shift; | |||||||||||||||||||||
| 9 | 0 | my $cb = shift; | |||||||||||||||||||||
| 10 | 0 | my $api = 'http://w.qq.com/d/channel/get_offpic2'; | |||||||||||||||||||||
| 11 | 0 | ▶ | if(ref $cb eq 'CODE'){ | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 12 | my @query_string = ( | ||||||||||||||||||||||
| 13 | file_path => $file_path, | ||||||||||||||||||||||
| 14 | f_uin => $from_uin, | ||||||||||||||||||||||
| 15 | clientid => $self->{qq_param}{clientid}, | ||||||||||||||||||||||
| 16 | psessionid => $self->{qq_param}{psessionid}, | ||||||||||||||||||||||
| 17 | 0 | ); | |||||||||||||||||||||
| 18 | 0 | ▶ | my $callback = sub{ | ||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||
| 19 | 0 | my $response = shift; | |||||||||||||||||||||
| 20 | 0 | ▶ | if($response->is_success){ | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 21 | 0 | ▶ | return unless $response->header("content-type") =~/^image\/(.*)/; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 22 | 0 | ▶ | my $type = $1=~/jpe?g/i ? ".jpg" | ||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||
| 23 | : $1=~/png/i ? ".png" | ||||||||||||||||||||||
| 24 | : $1=~/bmp/i ? ".bmp" | ||||||||||||||||||||||
| 25 | : $1=~/gif/i ? ".gif" | ||||||||||||||||||||||
| 26 | : undef | ||||||||||||||||||||||
| 27 | ; | ||||||||||||||||||||||
| 28 | 0 | ▶ | return unless defined $type; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 29 | 0 | my $tmp = File::Temp->new( | |||||||||||||||||||||
| 30 | TEMPLATE => "webqq_offpic_XXXX", | ||||||||||||||||||||||
| 31 | SUFFIX => $type, | ||||||||||||||||||||||
| 32 | TMPDIR => 1, | ||||||||||||||||||||||
| 33 | UNLINK => 1, | ||||||||||||||||||||||
| 34 | ); | ||||||||||||||||||||||
| 35 | 0 | binmode $tmp; | |||||||||||||||||||||
| 36 | 0 | print $tmp $response->content(); | |||||||||||||||||||||
| 37 | 0 | close $tmp; | |||||||||||||||||||||
| 38 | 0 | eval{ | |||||||||||||||||||||
| 39 | 0 | ▶ | open(my $fh,"<:raw",$tmp->filename) or die $!; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 40 | 0 | $cb->($fh,$tmp->filename); | |||||||||||||||||||||
| 41 | 0 | close $fh; | |||||||||||||||||||||
| 42 | }; | ||||||||||||||||||||||
| 43 | 0 | ▶ | console "[Webqq::Client::_get_offpic] $@" if $@; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||
| 45 | 0 | }; | |||||||||||||||||||||
| 46 | 0 | require URI; | |||||||||||||||||||||
| 47 | 0 | my $uri = URI->new('http:'); | |||||||||||||||||||||
| 48 | 0 | $uri->query_form(\@query_string); | |||||||||||||||||||||
| 49 | 0 | ▶ | print "GET $api?" . $uri->query() . "\n" if $self->{debug}; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 50 | 0 | $self->{asyn_ua}->get($api ."?". $uri->query(),$callback); | |||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||
| 52 | }; | ||||||||||||||||||||||
| 53 | 1 | 1; | |||||||||||||||||||||