def video(): cwd = os.getcwd() print("Current working directory:", cwd) if not cwd.endswith("/static/videos") and not cwd.endswith("/static/videos/"): os.chdir(cwd + "/static/videos") video_id = request.args.get("id", "") video_meta = api.get_video(video_id) path = os.getcwd() + r"/" + video_meta.video_id + r".mp3" if os.path.isfile(path): return render_template("video.jinja", video=video_meta, filename=video_meta.video_id + ".mp3") else: DownloadScheduler.download(video_meta.video_id) return render_template("video.jinja", video=video_meta, filename=video_meta.video_id + ".mp3")
def download_video(): DownloadScheduler.download(request.args.get("id", ""), async=True) return "downloading..."