7 die("Usage:$0 ID [name]\n") unless(@ARGV);
9 my $gb = find_encoding
("gb2312");
13 open FI
,"-|", "httpget.pl","$url" or return undef;
16 $_ =~ s/^\s*_Callback\s*\(//;
22 $code = $gb->decode($code);
29 open FI
,"-|", "httpget.pl","http://alist.photo.qq.com/fcgi-bin/fcg_list_album?uin=$uin&outstyle=2" or return undef;
30 # open FI,"-|", "httpget.pl","http://xalist.photo.qq.com/fcgi-bin/fcg_list_album?uin=$uin&outstyle=2" or return undef;
33 $_ =~ s/^\s*_Callback\s*\(//;
39 $code = $gb->decode($code);
46 open FI
,"-|","httpget.pl","http://plist.photo.qq.com/fcgi-bin/fcg_list_photo?uin=$uin&albumid=$id&outstyle=2" or return undef;
47 #open FI,"-|","httpget.pl","http://xaplist.photo.qq.com/fcgi-bin/fcg_list_photo?uin=$uin&albumid=$id&outstyle=2" or return undef;
50 $_ =~ s/^\s*_Callback\s*\(//;
51 $_ =~ s/^\s*\);\s*$/;/;
56 $code = $gb->decode($code);
63 $name = $uin unless($name);
66 "http://alist.photo.qq.com/fcgi-bin/fcg_list_album?uin=###UIN###&outstyle=2" =>
67 "http://plist.photo.qq.com/fcgi-bin/fcg_list_photo?uin=###UIN###&albumid=###ALBUMID###&outstyle=2",
68 "http://xalist.photo.qq.com/fcgi-bin/fcg_list_album?uin=###UIN###&outstyle=2" =>
69 "http://xaplist.photo.qq.com/fcgi-bin/fcg_list_photo?uin=###UIN###&albumid=###ALBUMID###&outstyle=2",
73 foreach my $album_exp (keys %url_map) {
74 my $album_url = $album_exp;
75 $album_url =~ s/###UIN###/$uin/;
76 my $list_ref = get_list
($album_url);
77 next unless($list_ref and ref $list_ref);
78 my $albums = $list_ref->{"album"};
79 next unless($albums and ref $albums);
80 print STDERR
"For $name, Get " . scalar(@
{$albums}) . " albums.\n";
82 mkdir $name unless(-d
$name);
83 chdir $name or die("$!\n");
84 foreach my $album (@
{$albums}) {
85 my $album_name = $album->{"name"};
86 $album_name =~ s/^[\s ]+//;
87 $album_name =~ s/[\s ]+$//;
88 $album_name = "_noname" unless($album_name);
89 mkdir $album_name unless(-d
$album_name);
90 chdir $album_name or die("$!\n");
91 print STDERR
"Downloading [$album_name] ...\n";
92 my $photo_url = $url_map{$album_exp};
93 $photo_url =~ s/###UIN###/$uin/;
94 $photo_url =~ s/###ALBUMID###/$album->{id}/;
95 my $photo_list_ref = get_list
($photo_url);
96 next unless($photo_list_ref and ref $photo_list_ref);
97 my $photos = $photo_list_ref->{"pic"};
98 next unless($photos and ref $photos);
99 print STDERR
"Get " . scalar(@
{$photos}) . " photos.\n";
100 foreach my $photo (@
{$photos}) {
101 my $url = $photo->{"origin_url"};
102 my $filename = $photo->{"name"};
103 $filename =~ s/^[ \s]+//;
104 $filename =~ s/[\s ]+$//;
105 system("download","-u",$url,"-s",$filename . "_" . $photo->{"lloc2"} . ".jpg");
113 print "Can't get any photos\n" unless($good_url);