Update zotify/app.py

This commit is contained in:
Zotify 2021-12-27 23:15:23 +00:00
parent 91b1fa6ed3
commit 2aef2f3171
1 changed files with 11 additions and 11 deletions

View File

@ -10,23 +10,23 @@ from podcast import download_episode, get_show_episodes
from termoutput import Printer, PrintChannel from termoutput import Printer, PrintChannel
from track import download_track, get_saved_tracks from track import download_track, get_saved_tracks
from utils import splash, split_input, regex_input_for_urls from utils import splash, split_input, regex_input_for_urls
from zspotify import ZSpotify from zotify import Zotify
SEARCH_URL = 'https://api.spotify.com/v1/search' SEARCH_URL = 'https://api.spotify.com/v1/search'
def client(args) -> None: def client(args) -> None:
""" Connects to spotify to perform query's and get songs to download """ """ Connects to download server to perform query's and get songs to download """
ZSpotify(args) Zotify(args)
Printer.print(PrintChannel.SPLASH, splash()) Printer.print(PrintChannel.SPLASH, splash())
if ZSpotify.check_premium(): if Zotify.check_premium():
Printer.print(PrintChannel.SPLASH, '[ DETECTED PREMIUM ACCOUNT - USING VERY_HIGH QUALITY ]\n\n') Printer.print(PrintChannel.SPLASH, '[ DETECTED PREMIUM ACCOUNT - USING VERY_HIGH QUALITY ]\n\n')
ZSpotify.DOWNLOAD_QUALITY = AudioQuality.VERY_HIGH Zotify.DOWNLOAD_QUALITY = AudioQuality.VERY_HIGH
else: else:
Printer.print(PrintChannel.SPLASH, '[ DETECTED FREE ACCOUNT - USING HIGH QUALITY ]\n\n') Printer.print(PrintChannel.SPLASH, '[ DETECTED FREE ACCOUNT - USING HIGH QUALITY ]\n\n')
ZSpotify.DOWNLOAD_QUALITY = AudioQuality.HIGH Zotify.DOWNLOAD_QUALITY = AudioQuality.HIGH
if args.download: if args.download:
urls = [] urls = []
@ -49,7 +49,7 @@ def client(args) -> None:
if args.liked_songs: if args.liked_songs:
for song in get_saved_tracks(): for song in get_saved_tracks():
if not song[TRACK][NAME] or not song[TRACK][ID]: if not song[TRACK][NAME] or not song[TRACK][ID]:
Printer.print(PrintChannel.SKIPS, '### SKIPPING: SONG DOES NOT EXIST ON SPOTIFY ANYMORE ###' + "\n") Printer.print(PrintChannel.SKIPS, '### SKIPPING: SONG DOES NOT EXIST ANYMORE ###' + "\n")
else: else:
download_track('liked', song[TRACK][ID]) download_track('liked', song[TRACK][ID])
@ -62,7 +62,7 @@ def client(args) -> None:
search(search_text) search(search_text)
def download_from_urls(urls: list[str]) -> bool: def download_from_urls(urls: list[str]) -> bool:
""" Downloads from a list of spotify urls """ """ Downloads from a list of urls """
download = False download = False
for spotify_url in urls: for spotify_url in urls:
@ -86,7 +86,7 @@ def download_from_urls(urls: list[str]) -> bool:
char_num = len(str(len(playlist_songs))) char_num = len(str(len(playlist_songs)))
for song in playlist_songs: for song in playlist_songs:
if not song[TRACK][NAME] or not song[TRACK][ID]: if not song[TRACK][NAME] or not song[TRACK][ID]:
Printer.print(PrintChannel.SKIPS, '### SKIPPING: SONG DOES NOT EXIST ON SPOTIFY ANYMORE ###' + "\n") Printer.print(PrintChannel.SKIPS, '### SKIPPING: SONG DOES NOT EXIST ANYMORE ###' + "\n")
else: else:
download_track('playlist', song[TRACK][ID], extra_keys= download_track('playlist', song[TRACK][ID], extra_keys=
{ {
@ -109,7 +109,7 @@ def download_from_urls(urls: list[str]) -> bool:
def search(search_term): def search(search_term):
""" Searches Spotify's API for relevant data """ """ Searches download server's API for relevant data """
params = {'limit': '10', params = {'limit': '10',
'offset': '0', 'offset': '0',
'q': search_term, 'q': search_term,
@ -163,7 +163,7 @@ def search(search_term):
raise ValueError("Invalid query.") raise ValueError("Invalid query.")
params["q"] = ' '.join(search_term_list) params["q"] = ' '.join(search_term_list)
resp = ZSpotify.invoke_url_with_params(SEARCH_URL, **params) resp = Zotify.invoke_url_with_params(SEARCH_URL, **params)
counter = 1 counter = 1
dics = [] dics = []