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