Integrating SpotifySearcher and Searcher

This commit is contained in:
Rafael Vargas 2021-12-25 01:38:39 -04:00
parent 93046da491
commit 7775f259af
2 changed files with 5 additions and 26 deletions

View File

@ -33,11 +33,8 @@ class Searcher():
if "https://www.youtu" in music or "https://youtu.be" in music:
return Provider.YouTube
if "https://open.spotify.com/track" in music:
if "https://open.spotify.com" in music:
return Provider.Spotify
if "https://open.spotify.com/playlist" in music or "https://open.spotify.com/album" in music:
return Provider.Spotify_Playlist
# If no match
return Provider.Unknown

View File

@ -86,9 +86,8 @@ class SpotifySearch():
except:
pass
return musicsTitle
except:
if config.SPOTIFY_ID != "" or config.SPOTIFY_SECRET != "":
print("ERROR: Check spotify CLIENT_ID and SECRET")
except Exception as e:
raise e
def __get_playlist(self, code) -> list:
"""Get the externals urls of a playlist
@ -114,12 +113,10 @@ class SpotifySearch():
titles.append(title)
except Exception as e:
raise e
return titles
except Exception as e:
if config.SPOTIFY_ID != "" or config.SPOTIFY_SECRET != "":
print("ERROR: Check spotify CLIENT_ID and SECRET")
else:
raise e
def __get_track(self, code) -> list:
@ -150,18 +147,3 @@ class SpotifySearch():
"""(Experimental) - Convert the external_url link to the title of music using browser"""
title = self.__browser(url)
return title
if __name__ == '__main__':
spSearch = SpotifySearch()
spSearch.connect()
lista = spSearch.search(
'https://open.spotify.com/track/7wpnz7hje4FbnjZuWQtJHP')
lista2 = spSearch.search(
'https://open.spotify.com/album/6wEkHIUHNb1kZiV2nCnVoh')
lista3 = spSearch.search(
'https://open.spotify.com/playlist/5DOtjJ6rSMddAKyStv7Yc7?si=v893Wv0VSyuh0PokQvC8-g&utm_source=whatsapp')
print(lista3)
print(lista2)
print(lista)