diff --git a/files/routes/settings.py b/files/routes/settings.py index c4f14d09a..7b582bb20 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -986,8 +986,8 @@ def settings_name_change(v): def settings_song_change(v): song=request.values.get("song").strip() - if song == "" and v.song and path.isfile(f"songs/{v.song}.mp3") and g.db.query(User.id).filter_by(song=v.song).count() == 1: - os.remove(f"songs/{v.song}.mp3") + if song == "" and v.song and path.isfile(f"/songs/{v.song}.mp3") and g.db.query(User.id).filter_by(song=v.song).count() == 1: + os.remove(f"/songs/{v.song}.mp3") v.song = None g.db.add(v) g.db.commit() @@ -1006,7 +1006,7 @@ def settings_song_change(v): if "?" in id: id = id.split("?")[0] if "&" in id: id = id.split("&")[0] - if path.isfile(f'songs/{id}.mp3'): + if path.isfile(f'/songs/{id}.mp3'): v.song = id g.db.add(v) g.db.commit() @@ -1028,11 +1028,11 @@ def settings_song_change(v): error=f"Duration of the video must not exceed 10 minutes.") - if v.song and path.isfile(f"songs/{v.song}.mp3") and g.db.query(User.id).filter_by(song=v.song).count() == 1: - os.remove(f"songs/{v.song}.mp3") + if v.song and path.isfile(f"/songs/{v.song}.mp3") and g.db.query(User.id).filter_by(song=v.song).count() == 1: + os.remove(f"/songs/{v.song}.mp3") ydl_opts = { - 'outtmpl': 'songs/%(title)s.%(ext)s', + 'outtmpl': '/songs/%(title)s.%(ext)s', 'format': 'bestaudio/best', 'postprocessors': [{ 'key': 'FFmpegExtractAudio', @@ -1049,10 +1049,10 @@ def settings_song_change(v): v=v, error=f"Age-restricted videos aren't allowed.") - files = os.listdir("songs/") - paths = [path.join("songs/", basename) for basename in files] + files = os.listdir("/songs/") + paths = [path.join("/songs/", basename) for basename in files] songfile = max(paths, key=path.getctime) - os.rename(songfile, f"songs/{id}.mp3") + os.rename(songfile, f"/songs/{id}.mp3") v.song = id g.db.add(v) diff --git a/files/routes/static.py b/files/routes/static.py index 31bec0dca..88e2cbf15 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -265,7 +265,7 @@ def static_service(path): @app.get('/hostedimages/') @limiter.exempt def images(path): - resp = make_response(send_from_directory('../images', path.replace('.WEBP','.webp'))) + resp = make_response(send_from_directory('/images', path.replace('.WEBP','.webp'))) resp.headers.remove("Cache-Control") resp.headers.add("Cache-Control", "public, max-age=2628000") if request.path.endswith('.webp'): diff --git a/files/routes/users.py b/files/routes/users.py index 5b6eba904..adc32dca1 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -307,7 +307,7 @@ def songs(id): @app.get("/song/") def song(song): - resp = make_response(send_from_directory('songs/', song)) + resp = make_response(send_from_directory('/songs/', song)) resp.headers.remove("Cache-Control") resp.headers.add("Cache-Control", "public, max-age=2628000") return resp