diff --git a/mps_youtube/commands/search.py b/mps_youtube/commands/search.py index 196d6f4a..36a5c6e5 100644 --- a/mps_youtube/commands/search.py +++ b/mps_youtube/commands/search.py @@ -216,7 +216,14 @@ def usersearch_id(user, channel_id, term): else: failmsg = "User %s not found or has no videos." % termuser[1] msg = str(msg).format(c.w, c.y, c.y, term, user) - results = pafy.all_videos_from_channel(channel_id) + + videos = pafy.all_videos_from_channel(channel_id) + query = term.lower() if term else None + + if query: + results = [v for v in videos if query in v.get('title', '').lower() or query in v.get('description', '').lower()] + else: + results = videos _display_search_results(progtext, results, msg, failmsg) diff --git a/mps_youtube/pafy.py b/mps_youtube/pafy.py index db4a5c2e..b8c818cd 100644 --- a/mps_youtube/pafy.py +++ b/mps_youtube/pafy.py @@ -119,7 +119,13 @@ def channel_id_from_name(query): return (channel_id, channel_name) def all_videos_from_channel(channel_id): + ''' + Get all videos of a playlist identified by channel_id + ''' + playlist = Playlist(playlist_from_channel_id(channel_id)) + while playlist.hasMoreVideos: + playlist.getNextVideos() return playlist.videos def search_videos_from_channel(channel_id, query):