Added argument parsing in search function

Added a block for parsing arguments passed with options
-l -limit
-t -type
in the search_term. They work as follows:

* -l -limit <number> : sets the limit of results to that number
  and raises a ValueError if that number exceeds 50. Default is 10.

* -t -type <album/track/playlist> : sets the type that is requested
  from the API about the search query. Raises a ValueError if an arguments
  passed are different than track, album, playlist. Default is all three.

Example:
Enter search or URL: <query> -l 30 -t track album

This will result with 30 tracks and 30 albums associated with query.
Options can be passed in any order but the query must be first.
This commit is contained in:
yiannisha
2021-10-24 18:07:12 +03:00
parent 1c62ff6604
commit 18fca559b3
3 changed files with 158 additions and 59 deletions

View File

@@ -54,6 +54,8 @@ ERROR = 'error'
EXPLICIT = 'explicit'
PLAYLIST = 'playlist'
PLAYLISTS = 'playlists'
OWNER = 'owner'