Просмотр исходного кода

Add poster support (to the extent YT has posters

Zachary Kotlarek 12 лет назад
Родитель
Сommit
8ab4255db6
1 измененных файлов с 13 добавлено и 4 удалено
  1. 13 4
      yt/ytSubscribe.pl

+ 13 - 4
yt/ytSubscribe.pl

@@ -88,13 +88,21 @@ if (!$DEBUG) {
 # Grab the channel data
 my $channel = getChannel($user);
 
-# Create the channel NFO, if needed
+# Create the channel NFO and poster, if needed
 my $nfo = $dir . '/tvshow.nfo';
 if (!-e $nfo) {
 	if ($DEBUG) {
-		print STDERR 'Creating series NFO: ' . $channel->{'title'} . "\n";
+		print STDERR 'Saving series data for: ' . $channel->{'title'} . "\n";
 	}
-	
+
+	# Save the poster
+	if (exists($channel->{'thumbnail'}) && length($channel->{'thumbnail'}) > 5) {
+		my $poster = $dir . '/poster.jpg';
+		my $jpg    = get($channel->{'thumbnail'});
+		saveString($poster, $jpg);
+	}
+
+	# Save the series NFO
 	my $xml = buildSeriesNFO($channel);
 	if ($DEBUG > 1) {
 		print STDERR 'Saving NFO: ' . $xml . "\n";
@@ -360,9 +368,10 @@ sub getChannel($) {
 	# Extract the data we want
 	my %channel = (
 		'id'          => $data->{'yt$channelId'}->{'$t'},
-		'title'       => $data->{'author'}[0]->{'name'}->{'$t'},
+		'title'       => $data->{'title'}->{'$t'},
 		'date'        => str2time($data->{'published'}->{'$t'}),
 		'description' => $data->{'summary'}->{'$t'},
+		'thumbnail'   => $data->{'media$thumbnail'}->{'url'},
 	);
 	return \%channel;
 }