Fix latest_mtime.txt in server script
This commit is contained in:
parent
2c4d96a070
commit
e2d460ff06
@ -180,6 +180,7 @@ def main(queue_length):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# Get all other songs coordinates
|
# Get all other songs coordinates
|
||||||
|
# TODO: Don't rebuild entire cache if cache is already built
|
||||||
closest_song = None
|
closest_song = None
|
||||||
cur.execute("SELECT id, tempo1, tempo2, tempo3, amplitude, frequency, attack, filename FROM songs")
|
cur.execute("SELECT id, tempo1, tempo2, tempo3, amplitude, frequency, attack, filename FROM songs")
|
||||||
for tmp_song_data in cur.fetchall():
|
for tmp_song_data in cur.fetchall():
|
||||||
|
@ -77,8 +77,13 @@ def full_rescan(mpd_root):
|
|||||||
all_songs = [x["file"] for x in client.listall() if "file" in x]
|
all_songs = [x["file"] for x in client.listall() if "file" in x]
|
||||||
subprocess.check_call(["blissify", mpd_root] + all_songs)
|
subprocess.check_call(["blissify", mpd_root] + all_songs)
|
||||||
# Update the latest mtime stored
|
# Update the latest mtime stored
|
||||||
with open(os.path.join(_BLISSIFY_DATA_HOME, "latest_mtime.txt"), "r") as fh:
|
latest_mtime = 0
|
||||||
latest_mtime = int(fh.read())
|
try:
|
||||||
|
with open(os.path.join(_BLISSIFY_DATA_HOME, "latest_mtime.txt"),
|
||||||
|
"r") as fh:
|
||||||
|
latest_mtime = int(fh.read())
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
for song in all_songs:
|
for song in all_songs:
|
||||||
last_modified = client.find("file", song)["last_modified"]
|
last_modified = client.find("file", song)["last_modified"]
|
||||||
last_modified = int(dateutil.parser.parse(last_modified).timestamp())
|
last_modified = int(dateutil.parser.parse(last_modified).timestamp())
|
||||||
@ -113,13 +118,14 @@ def update_db(mpd_root):
|
|||||||
Update the blissify db taking newly added songs in MPD library.
|
Update the blissify db taking newly added songs in MPD library.
|
||||||
"""
|
"""
|
||||||
client = init_connection()
|
client = init_connection()
|
||||||
with open(os.path.join(_BLISSIFY_DATA_HOME, "latest_mtime.txt"), "r") as fh:
|
latest_mtime = 0
|
||||||
latest_mtime = int(fh.read())
|
try:
|
||||||
|
with open(os.path.join(_BLISSIFY_DATA_HOME, "latest_mtime.txt"), "r") as fh:
|
||||||
|
latest_mtime = int(fh.read())
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
songs = [x["file"] for x in client.find("modified-since", latest_mtime)]
|
songs = [x["file"] for x in client.find("modified-since", latest_mtime)]
|
||||||
subprocess.check_call(["blissify", mpd_root] + songs)
|
subprocess.check_call(["blissify", mpd_root] + songs)
|
||||||
# Update the latest mtime stored
|
|
||||||
with open(os.path.join(_BLISSIFY_DATA_HOME, "latest_mtime.txt"), "r") as fh:
|
|
||||||
latest_mtime = int(fh.read())
|
|
||||||
for song in songs:
|
for song in songs:
|
||||||
last_modified = client.find("file", song)["last_modified"]
|
last_modified = client.find("file", song)["last_modified"]
|
||||||
last_modified = int(dateutil.parser.parse(last_modified).timestamp())
|
last_modified = int(dateutil.parser.parse(last_modified).timestamp())
|
||||||
|
Loading…
Reference in New Issue
Block a user