Skip to content

Commit

Permalink
Return error on invalid item in search
Browse files Browse the repository at this point in the history
  • Loading branch information
justin025 committed Oct 21, 2024
1 parent 735b98a commit 3345c07
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/onthespot/gui/mainui.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,14 +620,18 @@ def fill_search_table(self):
content_types.append('audiobook')

results = get_search_results(search_term, content_types)
if results == None:
if results is None:
self.__splash_dialog.run(self.tr("You need to login to at least one account to use this feature."))
self.inp_search_term.setText('')
return
elif results == True:
elif results is True:
self.__splash_dialog.run(self.tr("Item is being parsed and will be added to the download queue shortly."))
self.inp_search_term.setText('')
return
elif results is False:
self.__splash_dialog.run(self.tr("Invalid item, please check your account settings"))
self.inp_search_term.setText('')
return


for result in results:
Expand Down
4 changes: 2 additions & 2 deletions src/onthespot/parse_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def parse_url(url):
item_type = match.group("Type")
item_service = "spotify"
else:
logger.info('Invalid Url')
return
logger.info(f'Invalid Url: {url}')
return False
parsing[item_id] = {
'item_url': url,
'item_service': item_service,
Expand Down
4 changes: 3 additions & 1 deletion src/onthespot/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ def get_search_results(search_term, content_types=None):

if search_term.startswith('https://'):
logger.info(f"Search clicked with value with url {search_term}")
parse_url(search_term)
result = parse_url(search_term)
if result is False:
return False
return True
else:
if os.path.isfile(search_term):
Expand Down

0 comments on commit 3345c07

Please sign in to comment.