Skip to content

Commit

Permalink
GUI: ckeck search keywords for a playlist ID
Browse files Browse the repository at this point in the history
CLI: ckeck search keywords for a channel ID or a playlist ID

Example:

	youtube-viewer "UC..."		# display channel videos by channel ID
	youtube-viewer "PL..."		# display playlist videos by playlist ID
  • Loading branch information
trizen committed Nov 11, 2022
1 parent c3efcf5 commit 383ac83
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
5 changes: 4 additions & 1 deletion bin/gtk-youtube-viewer
Original file line number Diff line number Diff line change
Expand Up @@ -2464,9 +2464,12 @@ sub check_keywords {
return;
}
}
elsif ($yv_utils->is_channelID($key)) {
elsif ($key ne 'mine' and $yv_utils->is_channelID($key)) {
list_channel_videos($key);
}
elsif ($yv_utils->is_playlistID($key)) {
list_playlist($key);
}
elsif ($key =~ /$get_playlist_id_re/o) {
list_playlist($+{playlist_id});
}
Expand Down
8 changes: 7 additions & 1 deletion bin/youtube-viewer
Original file line number Diff line number Diff line change
Expand Up @@ -2493,7 +2493,13 @@ sub _bold_color {
sub youtube_urls {
my ($arg) = @_;

if ($arg =~ /$get_video_id_re/) {
if ($arg ne 'mine' and $yv_utils->is_channelID($arg)) {
print_videos($yv_obj->uploads($arg));
}
elsif ($yv_utils->is_playlistID($arg)) {
get_and_print_videos_from_playlist($arg);
}
elsif ($arg =~ /$get_video_id_re/) {
get_and_play_video_ids($+{video_id});
}
elsif ($arg =~ /$get_playlist_id_re/) {
Expand Down
6 changes: 6 additions & 0 deletions lib/WWW/YoutubeViewer/Utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,12 @@ sub is_channelID {
$id eq 'mine' or $id =~ /^UC[-a-zA-Z0-9_]{22}\z/;
}

sub is_playlistID {
my ($self, $id) = @_;
$id || return;
$id =~ m{^PL[-a-zA-Z0-9_]{32}\z};
}

sub is_videoID {
my ($self, $id) = @_;
$id || return;
Expand Down

0 comments on commit 383ac83

Please sign in to comment.