db.query("DELETE FROM import_queue WHERE queueid = ?", [queueid])
current_app.logger.info(f"dreams_importer: Removed {queueid} from queue")
-def add_to_queue(songid, indreams_url, duration):
- print(songid, indreams_url)
+def add_to_queue(songid, indreams_url, duration, fade_out):
timestamp = datetime.now(timezone.utc).isoformat()
+ fade_out = fade_out in [True, "true", "True", "TRUE", 1]
result = db.query(
"""
- INSERT INTO import_queue (created, indreamsurl, songid, status, duration)
- VALUES (?, ?, ?, 0, ?)
+ INSERT INTO import_queue (created, indreamsurl, songid, status, duration, fadeout)
+ VALUES (?, ?, ?, 0, ?, ?)
RETURNING queueid
""",
- [timestamp, indreams_url, songid, duration],
+ [timestamp, indreams_url, songid, duration, int(fade_out)],
expect_one=True)
queueid = result["queueid"]
description = request.form["description"]
upload_type = request.form["upload-type"]
song_duration = request.form["song-duration"]
+ fade_out = request.form["fade-out"] if "fade-out" in request.form else "False"
tags = [t.strip() for t in request.form["tags"].split(",") if t]
collaborators = [c.strip() for c in request.form["collabs"].split(",") if c]
if upload_type == "dreams" and url:
duration = duration_in_seconds(song_duration)
- dreams_importer.add_to_queue(songid, url, duration)
+ dreams_importer.add_to_queue(songid, url, duration, fade_out)
db.commit()
flash_and_log(f"Successfully updated '{title}'", "success")
description = request.form["description"]
upload_type = request.form["upload-type"]
song_duration = request.form["song-duration"]
+ fade_out = request.form["fade-out"] if "fade-out" in request.form else "False"
tags = [t.strip() for t in request.form["tags"].split(",") if t]
collaborators = [c.strip() for c in request.form["collabs"].split(",") if c]
try:
if upload_type == "dreams":
duration = duration_in_seconds(song_duration)
- dreams_importer.add_to_queue(songid, url, duration)
+ dreams_importer.add_to_queue(songid, url, duration, fade_out)
db.commit()
indreamsurl TEXT NOT NULL,
songid INTEGER NOT NULL REFERENCES songs(songid) ON DELETE CASCADE,
status INTEGER NOT NULL,
- duration INTEGER NOT NULL
+ duration INTEGER NOT NULL,
+ fadeout INTEGER NOT NULL
);
DROP VIEW IF EXISTS songs_view;
client, b"Queued for import from Dreams",
upload_type="dreams",
song_url=TEST_URL,
- song_duration="3:19")
+ song_duration="3:19",
+ fade_out=True)
response = client.get(f"/users/user")
assert b"[Hidden]" in response.data
assert b"[Queue Pos: 1]" in response.data
assert response.json["next"]["songid"] == 1
assert response.json["next"]["queueid"] == 1
assert response.json["next"]["duration"] == 199
+ assert response.json["next"]["fadeout"] == 1
# Now in progress
response = client.get(f"/users/user")
def upload_song(
client, msg, error=False, songid=None, eventid=None,
user="user", userid=1, filename=TEST_DATA/"sample-3s.mp3",
- upload_type="file", song_url=None, song_duration=None, **kwargs):
+ upload_type="file", song_url=None, song_duration=None, fade_out=False,
+ **kwargs):
song_file = None
if filename:
"upload-type": upload_type,
"song-url": song_url,
"song-duration": song_duration,
+ "fade-out": fade_out,
}
for k, v in kwargs.items():
data[k] = v