mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 20:43:04 +00:00
Restyle Save complete albums to the db for faster startup (#38)
This commit is contained in:
@@ -5,13 +5,13 @@ import random
|
||||
import urllib
|
||||
from pprint import pprint
|
||||
from typing import List
|
||||
from progress.bar import Bar
|
||||
|
||||
from app import api
|
||||
from app import functions
|
||||
from app import instances
|
||||
from app import models
|
||||
from app.lib import trackslib
|
||||
from app import instances
|
||||
from progress.bar import Bar
|
||||
|
||||
|
||||
def get_all_albums() -> List[models.Album]:
|
||||
@@ -63,7 +63,8 @@ def find_album(albumtitle: str, artist: str) -> models.Album:
|
||||
iter += 1
|
||||
mid = (left + right) // 2
|
||||
|
||||
if api.ALBUMS[mid].title == albumtitle and api.ALBUMS[mid].artist == artist:
|
||||
if api.ALBUMS[mid].title == albumtitle and api.ALBUMS[
|
||||
mid].artist == artist:
|
||||
return mid
|
||||
|
||||
if api.ALBUMS[mid].title < albumtitle:
|
||||
@@ -101,7 +102,8 @@ def get_album_image(album: list) -> str:
|
||||
"""
|
||||
|
||||
for track in album:
|
||||
img_p = (track["album"] + track["albumartist"] + ".webp").replace("/", "::")
|
||||
img_p = (track["album"] + track["albumartist"] + ".webp").replace(
|
||||
"/", "::")
|
||||
img = functions.extract_thumb(track["filepath"], webp_path=img_p)
|
||||
|
||||
if img is not None:
|
||||
@@ -140,8 +142,7 @@ def create_album(track) -> models.Album:
|
||||
album["date"] = album_tracks[0]["date"]
|
||||
|
||||
album["artistimage"] = urllib.parse.quote_plus(
|
||||
album_tracks[0]["albumartist"] + ".webp"
|
||||
)
|
||||
album_tracks[0]["albumartist"] + ".webp")
|
||||
|
||||
album["image"] = get_album_image(album_tracks)
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import colorgram
|
||||
from progress.bar import Bar
|
||||
from PIL import Image
|
||||
from io import BytesIO
|
||||
|
||||
from app import api, instances
|
||||
import colorgram
|
||||
from app import api
|
||||
from app import instances
|
||||
from app.lib.taglib import return_album_art
|
||||
from PIL import Image
|
||||
from progress.bar import Bar
|
||||
|
||||
|
||||
def get_image_colors(image) -> list:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import time
|
||||
from typing import List, Set
|
||||
from typing import List
|
||||
from typing import Set
|
||||
|
||||
from app import api
|
||||
from app import helpers
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import os
|
||||
from mutagen.flac import FLAC
|
||||
from mutagen.id3 import ID3
|
||||
from mutagen.flac import MutagenError
|
||||
import mutagen
|
||||
import urllib
|
||||
from PIL import Image
|
||||
from io import BytesIO
|
||||
|
||||
import mutagen
|
||||
from app import settings
|
||||
from mutagen.flac import FLAC
|
||||
from mutagen.flac import MutagenError
|
||||
from mutagen.id3 import ID3
|
||||
from PIL import Image
|
||||
|
||||
|
||||
def return_album_art(filepath: str):
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
"""
|
||||
This library contains the classes and functions related to the watchdog file watcher.
|
||||
"""
|
||||
|
||||
import time
|
||||
import os
|
||||
import time
|
||||
|
||||
from watchdog.observers import Observer
|
||||
from watchdog.events import PatternMatchingEventHandler
|
||||
|
||||
from app import api
|
||||
from app import instances
|
||||
from app import models
|
||||
from app import api
|
||||
from app.lib import folderslib
|
||||
from app.lib.taglib import get_tags
|
||||
from app.lib.albumslib import create_album
|
||||
from app.lib.taglib import get_tags
|
||||
from watchdog.events import PatternMatchingEventHandler
|
||||
from watchdog.observers import Observer
|
||||
|
||||
|
||||
class OnMyWatch:
|
||||
@@ -76,7 +74,8 @@ def remove_track(filepath: str) -> None:
|
||||
fpath = filepath.replace(fname, "")
|
||||
|
||||
try:
|
||||
trackid = instances.tracks_instance.get_song_by_path(filepath)["_id"]["$oid"]
|
||||
trackid = instances.tracks_instance.get_song_by_path(
|
||||
filepath)["_id"]["$oid"]
|
||||
except TypeError:
|
||||
print(f"💙 Watchdog Error: Error removing track {filepath} TypeError")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user