Skip to content

Commit

Permalink
gtk: added the right-click "Author"->"Save channel" menu entry.
Browse files Browse the repository at this point in the history
It saves a given channel in the list of saved channels (which is used for subscriptions).
  • Loading branch information
trizen committed Mar 7, 2021
1 parent 1a2e742 commit 882de74
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
12 changes: 12 additions & 0 deletions bin/gtk-youtube-viewer
Original file line number Diff line number Diff line change
Expand Up @@ -1368,6 +1368,16 @@ sub menu_popup {
$author->append($item);
}

# Save channel in the user-list
{
my $item = 'Gtk3::ImageMenuItem'->new("Save channel");
$item->set_property(tooltip_text => "Save the channel in the user-list");
$item->signal_connect(activate => sub { save_channel_by_id($channel_id) });
$item->set_image('Gtk3::Image'->new_from_icon_name("star-new-symbolic", q{menu}));
$item->show;
$author->append($item);
}

# Open the YouTube channel page
{
my $item = 'Gtk3::ImageMenuItem'->new("YouTube page");
Expand Down Expand Up @@ -3083,6 +3093,7 @@ sub add_subscription_entry {
4 => encode_entities($description),
6 => $channel_id,
7 => 'subscription',
8 => $yv_obj->make_json_string($subscription),
);

if ($CONFIG{show_thumbs}) {
Expand Down Expand Up @@ -3203,6 +3214,7 @@ $symbols{subs}\t %s subs",
4 => encode_entities($description),
6 => $channel_id,
7 => 'channel',
8 => $yv_obj->make_json_string($channel),
);

if ($CONFIG{show_thumbs}) {
Expand Down
5 changes: 3 additions & 2 deletions bin/youtube-viewer
Original file line number Diff line number Diff line change
Expand Up @@ -2278,15 +2278,16 @@ sub get_and_play_video_ids {
(my @ids = grep { defined($_) } map { get_valid_video_id($_) } @_) || return;

while (@ids) {
my $info = $yv_obj->video_details(join(',', splice(@ids, 0, 50)), VIDEO_PART);
my @video_ids = splice(@ids, 0, 50);
my $info = $yv_obj->video_details(join(',', @video_ids), VIDEO_PART);

if ($yv_utils->has_entries($info)) {
if (not play_videos($info->{results}{items})) {
return;
}
}
else {
warn_cant_do('get info for', @ids);
warn_cant_do('get info for', @video_ids);
}
}

Expand Down

0 comments on commit 882de74

Please sign in to comment.