from deezloader.deezer_settings import qualities from deezloader.exceptions import QualityNotFound from flask import Flask, request, send_file, render_template config = ConfigParser() config.read("setting.ini") try: deezer_token = config["login"]["token"] except KeyError: print("Something went wrong with configuration file") exit() app = Flask(__name__) downloa = Login(deezer_token) qualities = qualities.keys() output = "%s/Songs/" % os.getcwd() ip = "127.0.0.1" port = 8000 download_api = "http://{}:{}/download?path=%s".format(ip, port) player_api = "http://{}:{}/play?path=%s".format(ip, port) want_api = "http://{}:{}/want?link=%s&quality=%s".format(ip, port) def check_all(): dirs = "/".join(os.path.realpath(__file__).split("/")[:-1]) folder1 = "%s/templates/" % dirs folder2 = "%s/static/" % dirs
try: ini_file = args.setting except AttributeError: ini_file = "setting.ini" config = ConfigParser() config.read(ini_file) try: token = config["login"]["token"] except KeyError: print("Something went wrong with configuration file") exit() downloa = Login(token) link = args.link output = args.output quality = args.quality if quality and quality != "FLAC": quality = "MP3_%s" % quality recursive_quality = bool(args.recursive_quality) recursive_download = bool(args.recursive_download) zips = bool(args.zip) song = args.song artist = args.artist not_gui = bool(args.not_gui) if not output:
async def deeznuts(event): if DEEZER_ARL_TOKEN is None: return await event.edit("**Set** `DEEZER_ARL_TOKEN` **first.**") try: loader = Login(DEEZER_ARL_TOKEN) except Exception as e: return await event.edit(f"**Error:** `{e}`") try: link = get(event.pattern_match.group(1)).url except BaseException: return await event.edit("**Error: Invalid link provided.**") quality = {"flac": "FLAC", "320": "MP3_320", "256": "MP3_256", "128": "MP3_128"} quality = quality[event.pattern_match.group(2)] temp_dl_path = os.path.join(TEMP_DOWNLOAD_DIRECTORY, str(time())) if not os.path.exists(temp_dl_path): os.makedirs(temp_dl_path) await event.edit("`Downloading...`") if "spotify" in link: if "track" in link: try: track = loader.download_trackspo( link, output=temp_dl_path, quality=quality, recursive_quality=True, recursive_download=True, not_interface=True, ) except Exception as e: return await event.edit(f"**Error:** `{e}`") await event.edit("`Uploading...`") await upload_track(track, event) rmtree(temp_dl_path) return await event.delete() if "album" in link: try: album = loader.download_albumspo( link, output=temp_dl_path, quality=quality, recursive_quality=True, recursive_download=True, not_interface=True, zips=False, ) except Exception as e: return await event.edit(f"**Error:** `{e}`") await event.edit("`Uploading...`") for track in album: await upload_track(track, event) rmtree(temp_dl_path) return await event.delete() if "deezer" in link: if "track" in link: try: track = loader.download_trackdee( link, output=temp_dl_path, quality=quality, recursive_quality=True, recursive_download=True, not_interface=True, ) except Exception as e: return await event.edit(f"**Error:** `{e}`") await event.edit("`Uploading...`") await upload_track(track, event) rmtree(temp_dl_path) return await event.delete() if "album" in link: try: album = loader.download_albumdee( link, output=temp_dl_path, quality=quality, recursive_quality=True, recursive_download=True, not_interface=True, zips=False, ) except Exception as e: return await event.edit(f"**Error:** `{e}`") await event.edit("`Uploading...`") for track in album: await upload_track(track, event) rmtree(temp_dl_path) return await event.delete() await event.edit("**Syntax error!\nRead** `.help deezloader`**.**")
async def deeznuts(event): if DEEZER_ARL_TOKEN is None: return await event.edit( "**Configure** `DEEZER_ARL_TOKEN` **primeiro.**") try: loader = Login(DEEZER_ARL_TOKEN) except Exception as e: return await event.edit(f"**Erro:** `{e}`") try: link = get(event.pattern_match.group(1)).url except: return await event.edit("**Erro: Link inválido fornecido.**") quality = { "flac": "FLAC", "320": "MP3_320", "256": "MP3_256", "128": "MP3_128" } quality = quality[event.pattern_match.group(2)] temp_dl_path = os.path.join(TEMP_DOWNLOAD_DIRECTORY, str(time())) if not os.path.exists(temp_dl_path): os.makedirs(temp_dl_path) await event.edit("**Baixando...**") if "spotify" in link: if "track" in link: try: track = loader.download_trackspo( link, output=temp_dl_path, quality=quality, recursive_quality=True, recursive_download=True, not_interface=True, ) except Exception as e: return await event.edit(f"**Erro:** `{e}`") await event.edit("**Enviando...**") await upload_track(track, event) rmtree(temp_dl_path) return await event.delete() if "album" in link: try: album = loader.download_albumspo( link, output=temp_dl_path, quality=quality, recursive_quality=True, recursive_download=True, not_interface=True, zips=False, ) except Exception as e: return await event.edit(f"**Erro:** `{e}`") await event.edit("**Enviando...**") for track in album: await upload_track(track, event) rmtree(temp_dl_path) return await event.delete() if "deezer" in link: if "track" in link: try: track = loader.download_trackdee( link, output=temp_dl_path, quality=quality, recursive_quality=True, recursive_download=True, not_interface=True, ) except Exception as e: return await event.edit(f"**Erro:** `{e}`") await event.edit("**Enviando...**") await upload_track(track, event) rmtree(temp_dl_path) return await event.delete() if "album" in link: try: album = loader.download_albumdee( link, output=temp_dl_path, quality=quality, recursive_quality=True, recursive_download=True, not_interface=True, zips=False, ) except Exception as e: return await event.edit(f"**Erro:** `{e}`") await event.edit("**Enviando...**") for track in album: await upload_track(track, event) rmtree(temp_dl_path) return await event.delete() await event.edit("**Erro de sintaxe!\nVeja** `.help deezloader`**.**")