From 5b192d28ac3d54af073c39bffce08b8d2163d6a7 Mon Sep 17 00:00:00 2001 From: Tommy Stigen Olsen Date: Mon, 4 Jun 2018 13:49:02 +0200 Subject: [PATCH 1/2] Show Channel ID in channel search --- mps_youtube/commands/search.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mps_youtube/commands/search.py b/mps_youtube/commands/search.py index af349eb8..1fb19f51 100644 --- a/mps_youtube/commands/search.py +++ b/mps_youtube/commands/search.py @@ -173,6 +173,7 @@ def channelsearch(q_user): columns = [ {"name": "idx", "size": 3, "heading": "Num"}, {"name": "name", "size": 30, "heading": "Username"}, + {"name": "id", "size": 24, "heading": "Channel ID"}, {"name": "description", "size": "remaining", "heading": "Description"}, ] From 223782aa996a61943256c966465d383fc1a8e4ba Mon Sep 17 00:00:00 2001 From: Tommy Stigen Olsen Date: Mon, 4 Jun 2018 13:46:32 +0200 Subject: [PATCH 2/2] Add ability to search for videos based on channel ID --- mps_youtube/commands/search.py | 15 +++++++++------ mps_youtube/helptext.py | 1 + 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/mps_youtube/commands/search.py b/mps_youtube/commands/search.py index 1fb19f51..e2e28cfb 100644 --- a/mps_youtube/commands/search.py +++ b/mps_youtube/commands/search.py @@ -318,19 +318,23 @@ def search(term): _search(term, query, msg, failmsg) -@command(r'u(?:ser)?pl\s(.*)') -def user_pls(user): +@command(r'(?:(u(?:ser)?)|(c(?:han)?))pl\s(.*)') +def user_pls(user_search, channel_search, user): """ Retrieve user playlists. """ - return pl_search(user, is_user=True) + return pl_search(user, is_user= user_search!=None, is_channel= channel_search != None) @command(r'(?:\.\.|\/\/|pls(?:earch)?\s)\s*(.*)') -def pl_search(term, page=0, splash=True, is_user=False): +def pl_search(term, page=0, splash=True, is_user=False, is_channel=False): """ Search for YouTube playlists. term can be query str or dict indicating user playlist search. """ + if(is_channel): + channel_id = term + prog = "channel: " + term + if not term or len(term) < 2: g.message = c.r + "Not enough input" + c.w g.content = content.generate_songlist_display() @@ -347,7 +351,6 @@ def pl_search(term, page=0, splash=True, is_user=False): if not ret: # Error return user, channel_id = ret - else: # playlist search is done with the above url and param type=playlist logging.info("playlist search for %s", prog) @@ -368,7 +371,7 @@ def pl_search(term, page=0, splash=True, is_user=False): qs = {'part': 'contentDetails,snippet', 'maxResults': 50} - if is_user: + if is_user or is_channel: if page: qs['pageToken'] = token(page) qs['channelId'] = channel_id diff --git a/mps_youtube/helptext.py b/mps_youtube/helptext.py index c23b1ea1..0e7a6aee 100644 --- a/mps_youtube/helptext.py +++ b/mps_youtube/helptext.py @@ -63,6 +63,7 @@ def helptext(): {2}user {1} - list YouTube uploads by . {2}user /{1} - as above, but matches . {2}userpl {1} - list YouTube playlists created by . + {2}chanpl {1} - list YouTube playlists made available on {2}pl {1} - Open YouTube playlist by url or id. {2}url {1} - Retrieve specific YouTube video by url or id. {2}url ... {1} - Retrieve specific YouTube videos by url or id.