aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/gtk-straw-viewer43
-rwxr-xr-xbin/straw-viewer21
2 files changed, 37 insertions, 27 deletions
diff --git a/bin/gtk-straw-viewer b/bin/gtk-straw-viewer
index 870b654..821f202 100755
--- a/bin/gtk-straw-viewer
+++ b/bin/gtk-straw-viewer
@@ -2523,6 +2523,10 @@ sub display_results {
use Data::Dump qw(pp);
pp $items;
+ if (ref($items) eq 'HASH' and $items->{type} eq 'playlist') {
+ $items = $items->{videos};
+ }
+
hide_feeds_window();
#~ if (not $from_history) {
@@ -2596,7 +2600,7 @@ sub display_results {
if ($yv_utils->is_playlist($item)) {
- my $playlist_id = $yv_utils->get_playlist_id($item) || next;
+ #~ my $playlist_id = $yv_utils->get_playlist_id($item) || next;
#~ if (exists($info->{__extra_info__}{$playlist_id})) {
#~ @{$item}{qw(contentDetails)} =
@@ -2613,7 +2617,7 @@ sub display_results {
}
elsif ($yv_utils->is_video($item)) {
- my $video_id = $yv_utils->get_video_id($item) || next;
+ #~ my $video_id = $yv_utils->get_video_id($item) || next;
#~ if (exists($info->{__extra_info__}{$video_id})) {
#~ @{$item}{qw(id contentDetails statistics snippet)} =
@@ -2773,7 +2777,7 @@ sub add_channel_entry {
my ($channel) = @_;
my $iter = $liststore->append;
- my $title = $yv_utils->get_title($channel);
+ my $title = $yv_utils->get_channel_title($channel);
my $channel_id = $yv_utils->get_channel_id($channel);
my $description = $yv_utils->get_description($channel);
my $row_description = make_row_description($description);
@@ -2840,8 +2844,8 @@ sub add_playlist_entry {
my $num_items_template = "<b>$symbols{numero}</b> %d items\n";
my $num_items_text = "";
- if (defined($playlist->{contentDetails}{itemCount})) {
- $num_items_text = sprintf($num_items_template, $playlist->{contentDetails}->{itemCount});
+ if (defined($playlist->{videoCount})) {
+ $num_items_text = sprintf($num_items_template, $playlist->{videoCount});
}
my $type_label = reflow_text("<b>$symbols{diamond}</b> " . 'Playlist' . "\n" . $num_items_text);
@@ -2865,6 +2869,7 @@ sub list_playlist {
my ($playlist_id) = @_;
my $results = $yv_obj->videos_from_playlist_id($playlist_id);
+
if ($yv_utils->has_entries($results)) {
$liststore->clear if $CONFIG{clear_search_list};
display_results($results);
@@ -3575,37 +3580,39 @@ sub set_entry_details {
my $info = $yv_obj->parse_json_string($liststore->get($iter, 8));
+ my %thumbs = (
+ start => 1,
+ middle => 2,
+ end => 3,
+ );
+
# Getting thumbs
- foreach my $nr (qw(1 2 3)) {
+ foreach my $type (keys %thumbs) {
- $gui->get_object("image$nr")->set_from_pixbuf($default_thumb);
+ $gui->get_object("image$thumbs{$type}")->set_from_pixbuf($default_thumb);
Glib::Idle->add(
sub {
- my ($nr) = @{$_[0]};
+ my ($type) = @{$_[0]};
- if ($code =~ /$valid_video_id_re/) {
+ my $url = $yv_utils->get_thumbnail_url($info, $type);
- my $thumbnail = $info->{snippet}{thumbnails}{medium};
- my $url = $thumbnail->{url};
+ #~ my $thumbnail = $info->{snippet}{thumbnails}{medium};
+ #~ my $url = $thumbnail->{url};
if ($url =~ /_live\.\w+\z/) {
## no extra thumbnails available while video is LIVE
}
else {
- $url =~ s{/\w+\.(\w+)\z}{/mq$nr.$1};
+ $url =~ s{/\w+\.(\w+)\z}{/mq$thumbs{$type}.$1};
}
my $pixbuf = get_pixbuf_thumbnail_from_url($url, 160, 90);
- $gui->get_object("image$nr")->set_from_pixbuf($pixbuf);
- }
- else {
- $gui->get_object("image$nr")->set_from_pixbuf($default_thumb);
- }
+ $gui->get_object("image$thumbs{$type}")->set_from_pixbuf($pixbuf);
return 0;
},
- [$nr],
+ [$type],
Glib::G_PRIORITY_DEFAULT_IDLE
);
}
diff --git a/bin/straw-viewer b/bin/straw-viewer
index ef3b6f2..fbd0829 100755
--- a/bin/straw-viewer
+++ b/bin/straw-viewer
@@ -2570,8 +2570,7 @@ sub print_channels {
}
my $url = $results->{url};
- my $info = $results->{results} // {};
- my $channels = $info->{items} // [];
+ my $channels = $results->{results} // [];
foreach my $i (0 .. $#{$channels}) {
my $channel = $channels->[$i];
@@ -2579,7 +2578,7 @@ sub print_channels {
if ($opt{results_with_details}) {
printf(
"\n%s. %s\n %s: %-23s %s: %-12s\n%s\n",
- colored(sprintf('%2d', $i + 1), 'bold') => colored($yv_utils->get_title($channel), 'bold blue'),
+ colored(sprintf('%2d', $i + 1), 'bold') => colored($yv_utils->get_channel_title($channel), 'bold blue'),
colored('Updated' => 'bold') => $yv_utils->get_publication_date($channel),
colored('Author' => 'bold') => $yv_utils->get_channel_title($channel),
wrap_text(
@@ -2593,7 +2592,7 @@ sub print_channels {
print "\n" if $i == 0;
printf("%s. %s (%s)\n",
colored(sprintf('%2d', $i + 1), 'bold'),
- colored($yv_utils->get_title($channel), 'blue'),
+ colored($yv_utils->get_channel_title($channel), 'blue'),
colored($yv_utils->get_publication_date($channel), 'magenta'),
);
}
@@ -2612,7 +2611,7 @@ sub print_channels {
foreach my $i (0 .. $#{$channels}) {
my $channel = $channels->[$i];
- my $title = clear_title($yv_utils->get_title($channel));
+ my $title = clear_title($yv_utils->get_channel_title($channel));
printf "%s. %s %s [%*s]\n", colored(sprintf('%2d', $i + 1), 'bold'),
adjust_width($title, $title_length),
@@ -2642,7 +2641,7 @@ sub print_channels {
sub => __SUB__,
url => $url,
res => $channels,
- info => $info,
+ info => $results,
)
) {
## ok
@@ -2872,8 +2871,7 @@ sub print_playlists {
}
my $url = $results->{url};
- my $info = $results->{results} // {};
- my $playlists = $info->{items} // [];
+ my $playlists = $results->{results} // [];
state $info_format = <<"FORMAT";
@@ -2965,7 +2963,7 @@ FORMAT
sub => __SUB__,
url => $url,
res => $playlists,
- info => $info,
+ info => $results,
mode => 'playlists',
)
) {
@@ -3637,6 +3635,11 @@ sub print_videos {
my $url = $results->{url};
my $videos = $results->{results} // [];
+
+ if (ref($videos) eq 'HASH' and exists $videos->{videos}) {
+ $videos = $videos->{videos};
+ }
+
#my $videos = $info->{items} // [];
#~ foreach my $entry (@$videos) {