Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chanid search #856

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions mps_youtube/commands/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
]

Expand Down Expand Up @@ -317,19 +318,23 @@ def search(term):
_search(term, query, msg, failmsg)


@command(r'u(?:ser)?pl\s(.*)', 'userpl', 'upl')
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*(.*)', 'plsearch')
def pl_search(term, page=0, splash=True, is_user=False):
@command(r'(?:\.\.|\/\/|pls(?:earch)?\s)\s*(.*)')
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()
Expand All @@ -346,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)
Expand All @@ -367,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
Expand Down
1 change: 1 addition & 0 deletions mps_youtube/helptext.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def helptext():
{2}user <username>{1} - list YouTube uploads by <username>.
{2}user <username>/<query>{1} - as above, but matches <query>.
{2}userpl <username>{1} - list YouTube playlists created by <username>.
{2}chanpl <channel_id>{1} - list YouTube playlists made available on <channel_id>
{2}pl <url or id>{1} - Open YouTube playlist by url or id.
{2}url <url or id>{1} - Retrieve specific YouTube video by url or id.
{2}url <url> <url> ... <url>{1} - Retrieve specific YouTube videos by url or id.
Expand Down