mirror of
https://github.com/tcsenpai/swingmusic.git
synced 2025-06-06 03:05:35 +00:00
default migrations value to -1
+ tiny fixes
This commit is contained in:
parent
50aa971972
commit
d9688455fb
@ -91,6 +91,6 @@ CREATE TABLE IF NOT EXISTS dbmigrations (
|
||||
);
|
||||
|
||||
INSERT INTO dbmigrations (version)
|
||||
SELECT 0
|
||||
SELECT -1
|
||||
WHERE NOT EXISTS (SELECT 1 FROM dbmigrations);
|
||||
"""
|
||||
|
@ -1,4 +1,3 @@
|
||||
import json
|
||||
import os
|
||||
from collections import deque
|
||||
from typing import Generator
|
||||
@ -9,7 +8,8 @@ from tqdm import tqdm
|
||||
|
||||
from app import settings
|
||||
from app.db.sqlite.favorite import SQLiteFavoriteMethods as favdb
|
||||
from app.db.sqlite.lastfm.similar_artists import SQLiteLastFMSimilarArtists as lastfmdb
|
||||
from app.db.sqlite.lastfm.similar_artists import \
|
||||
SQLiteLastFMSimilarArtists as lastfmdb
|
||||
from app.db.sqlite.settings import SettingsSQLMethods as sdb
|
||||
from app.db.sqlite.tracks import SQLiteTrackMethods
|
||||
from app.lib.albumslib import validate_albums
|
||||
@ -124,7 +124,7 @@ class Populate:
|
||||
|
||||
for track in tracks:
|
||||
try:
|
||||
if track.last_mod == os.path.getmtime(track.filepath):
|
||||
if track.last_mod == round(os.path.getmtime(track.filepath)):
|
||||
unmodified_paths.add(track.filepath)
|
||||
continue
|
||||
except (FileNotFoundError, OSError) as e:
|
||||
@ -271,19 +271,13 @@ class FetchSimilarArtistsLastFM:
|
||||
def __init__(self) -> None:
|
||||
artists = ArtistStore.artists
|
||||
|
||||
try:
|
||||
with Pool(processes=cpu_count()) as pool:
|
||||
results = list(
|
||||
tqdm(
|
||||
pool.imap_unordered(save_similar_artists, artists),
|
||||
total=len(artists),
|
||||
desc="Fetching similar artists",
|
||||
)
|
||||
with Pool(processes=cpu_count()) as pool:
|
||||
results = list(
|
||||
tqdm(
|
||||
pool.imap_unordered(save_similar_artists, artists),
|
||||
total=len(artists),
|
||||
desc="Fetching similar artists",
|
||||
)
|
||||
)
|
||||
|
||||
list(results)
|
||||
except TypeError:
|
||||
print("TypeError: Handled!!")
|
||||
# 🤷
|
||||
# TypeError: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'
|
||||
pass
|
||||
list(results)
|
||||
|
@ -88,7 +88,7 @@ def get_tags(filepath: str):
|
||||
filename = (filepath.split("/")[-1]).replace(f".{filetype}", "")
|
||||
|
||||
try:
|
||||
last_mod = os.path.getmtime(filepath)
|
||||
last_mod = round(os.path.getmtime(filepath))
|
||||
except FileNotFoundError:
|
||||
return None
|
||||
|
||||
|
@ -34,6 +34,11 @@ def apply_migrations():
|
||||
|
||||
version = MigrationManager.get_version()
|
||||
|
||||
# is clean install
|
||||
if version == -1:
|
||||
MigrationManager.set_version(len(migrations))
|
||||
return
|
||||
|
||||
if version != len(migrations):
|
||||
# run migrations after the previous migration version
|
||||
for migration in migrations[(version - 1) :]:
|
||||
|
@ -33,7 +33,7 @@ class Track:
|
||||
title: str
|
||||
track: int
|
||||
trackhash: str
|
||||
last_mod: float
|
||||
last_mod: str | int
|
||||
|
||||
filetype: str = ""
|
||||
image: str = ""
|
||||
@ -46,6 +46,7 @@ class Track:
|
||||
def __post_init__(self):
|
||||
self.og_title = self.title
|
||||
self.og_album = self.album
|
||||
self.last_mod = int(self.last_mod)
|
||||
|
||||
if self.artist is not None:
|
||||
artists = split_artists(self.artist)
|
||||
|
Loading…
x
Reference in New Issue
Block a user