mirror of
https://github.com/tcsenpai/swingmusic.git
synced 2025-06-06 19:25:34 +00:00
fix: errors raised by Pycharm
This commit is contained in:
parent
95c1524b68
commit
838e19cf0f
@ -48,9 +48,9 @@ class ArtistsCache:
|
|||||||
"""
|
"""
|
||||||
for (index, albums) in enumerate(cls.artists):
|
for (index, albums) in enumerate(cls.artists):
|
||||||
if albums.artisthash == artisthash:
|
if albums.artisthash == artisthash:
|
||||||
return (albums.albums, index)
|
return albums.albums, index
|
||||||
|
|
||||||
return ([], -1)
|
return [], -1
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def albums_cached(cls, artisthash: str) -> bool:
|
def albums_cached(cls, artisthash: str) -> bool:
|
||||||
@ -214,7 +214,6 @@ def get_artist_albums(artisthash: str):
|
|||||||
|
|
||||||
limit = int(limit)
|
limit = int(limit)
|
||||||
|
|
||||||
all_albums = []
|
|
||||||
is_cached = ArtistsCache.albums_cached(artisthash)
|
is_cached = ArtistsCache.albums_cached(artisthash)
|
||||||
|
|
||||||
if not is_cached:
|
if not is_cached:
|
||||||
|
@ -22,6 +22,7 @@ def get_folder_tree():
|
|||||||
Returns a list of all the folders and tracks in the given folder.
|
Returns a list of all the folders and tracks in the given folder.
|
||||||
"""
|
"""
|
||||||
data = request.get_json()
|
data = request.get_json()
|
||||||
|
req_dir = "$home"
|
||||||
|
|
||||||
if data is not None:
|
if data is not None:
|
||||||
try:
|
try:
|
||||||
@ -60,7 +61,6 @@ def get_folder_tree():
|
|||||||
else:
|
else:
|
||||||
req_dir = "/" + req_dir + "/" if not req_dir.startswith("/") else req_dir + "/"
|
req_dir = "/" + req_dir + "/" if not req_dir.startswith("/") else req_dir + "/"
|
||||||
|
|
||||||
print(req_dir)
|
|
||||||
tracks, folders = GetFilesAndDirs(req_dir)()
|
tracks, folders = GetFilesAndDirs(req_dir)()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -127,9 +127,3 @@ def list_folders():
|
|||||||
return {
|
return {
|
||||||
"folders": sorted(dirs, key=lambda i: i["name"]),
|
"folders": sorted(dirs, key=lambda i: i["name"]),
|
||||||
}
|
}
|
||||||
|
|
||||||
# todo:
|
|
||||||
|
|
||||||
# - handle showing windows disks in root_dir configuration
|
|
||||||
# - handle the above, but for all partitions mounted in linux.
|
|
||||||
# - handle the "\" in client's folder page breadcrumb
|
|
||||||
|
@ -97,7 +97,7 @@ def add_track_to_playlist(playlist_id: str):
|
|||||||
return {"error": "Track already exists in playlist"}, 409
|
return {"error": "Track already exists in playlist"}, 409
|
||||||
|
|
||||||
add_artist_to_playlist(int(playlist_id), trackhash)
|
add_artist_to_playlist(int(playlist_id), trackhash)
|
||||||
PL.update_last_updated(playlist_id)
|
PL.update_last_updated(int(playlist_id))
|
||||||
|
|
||||||
return {"msg": "Done"}, 200
|
return {"msg": "Done"}, 200
|
||||||
|
|
||||||
|
@ -199,20 +199,20 @@ def search_load_more():
|
|||||||
if s_type == "tracks":
|
if s_type == "tracks":
|
||||||
t = SearchResults.tracks
|
t = SearchResults.tracks
|
||||||
return {
|
return {
|
||||||
"tracks": t[index : index + SEARCH_COUNT],
|
"tracks": t[index: index + SEARCH_COUNT],
|
||||||
"more": len(t) > index + SEARCH_COUNT,
|
"more": len(t) > index + SEARCH_COUNT,
|
||||||
}
|
}
|
||||||
|
|
||||||
elif s_type == "albums":
|
elif s_type == "albums":
|
||||||
a = SearchResults.albums
|
a = SearchResults.albums
|
||||||
return {
|
return {
|
||||||
"albums": a[index : index + SEARCH_COUNT],
|
"albums": a[index: index + SEARCH_COUNT],
|
||||||
"more": len(a) > index + SEARCH_COUNT,
|
"more": len(a) > index + SEARCH_COUNT,
|
||||||
}
|
}
|
||||||
|
|
||||||
elif s_type == "artists":
|
elif s_type == "artists":
|
||||||
a = SearchResults.artists
|
a = SearchResults.artists
|
||||||
return {
|
return {
|
||||||
"artists": a[index : index + SEARCH_COUNT],
|
"artists": a[index: index + SEARCH_COUNT],
|
||||||
"more": len(a) > index + SEARCH_COUNT,
|
"more": len(a) > index + SEARCH_COUNT,
|
||||||
}
|
}
|
||||||
|
@ -90,23 +90,9 @@ class SQLitePlaylistMethods:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def add_item_to_json_list(playlist_id: int, field: str, items: list[str]):
|
def add_item_to_json_list(playlist_id: int, field: str, items: list[str]):
|
||||||
"""
|
"""
|
||||||
Adds a string item to a json dumped list using a playlist id and field name. Takes the playlist ID, a field name, an item to add to the field, and an error to raise if the item is already in the field.
|
Adds a string item to a json dumped list using a playlist id and field name.
|
||||||
|
Takes the playlist ID, a field name,
|
||||||
Parameters
|
an item to add to the field, and an error to raise if the item is already in the field.
|
||||||
----------
|
|
||||||
playlist_id : int
|
|
||||||
The ID of the playlist to add the item to.
|
|
||||||
field : str
|
|
||||||
The field in the database that you want to add the item to.
|
|
||||||
item : str
|
|
||||||
The item to add to the list.
|
|
||||||
error : Exception
|
|
||||||
The error to raise if the item is already in the list.
|
|
||||||
|
|
||||||
Returns
|
|
||||||
-------
|
|
||||||
A list of strings.
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
sql = f"SELECT {field} FROM playlists WHERE id = ?"
|
sql = f"SELECT {field} FROM playlists WHERE id = ?"
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ class SQLiteTrackMethods:
|
|||||||
cur.execute("DELETE FROM tracks WHERE filepath=?", (filepath,))
|
cur.execute("DELETE FROM tracks WHERE filepath=?", (filepath,))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def remove_tracks_by_folders(folders: list[str]):
|
def remove_tracks_by_folders(folders: set[str]):
|
||||||
sql = "DELETE FROM tracks WHERE folder = ?"
|
sql = "DELETE FROM tracks WHERE folder = ?"
|
||||||
|
|
||||||
with SQLiteManager() as cur:
|
with SQLiteManager() as cur:
|
||||||
|
@ -7,8 +7,8 @@ from requests import ReadTimeout
|
|||||||
|
|
||||||
from app import utils
|
from app import utils
|
||||||
from app.lib.artistlib import CheckArtistImages
|
from app.lib.artistlib import CheckArtistImages
|
||||||
from app.lib.colorlib import ProcessAlbumColors, ProcessArtistColors
|
from app.lib.colorlib import ProcessArtistColors
|
||||||
from app.lib.populate import Populate, ProcessTrackThumbnails, PopulateCancelledError
|
from app.lib.populate import Populate, PopulateCancelledError
|
||||||
from app.lib.trackslib import validate_tracks
|
from app.lib.trackslib import validate_tracks
|
||||||
from app.logger import log
|
from app.logger import log
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ class CheckArtistImages:
|
|||||||
"""
|
"""
|
||||||
Checks if an artist image exists and downloads it if not.
|
Checks if an artist image exists and downloads it if not.
|
||||||
|
|
||||||
:param artistname: The artist name
|
:param artist: The artist name
|
||||||
"""
|
"""
|
||||||
img_path = Path(settings.ARTIST_IMG_SM_PATH) / f"{artist.artisthash}.webp"
|
img_path = Path(settings.ARTIST_IMG_SM_PATH) / f"{artist.artisthash}.webp"
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ class GetFilesAndDirs:
|
|||||||
try:
|
try:
|
||||||
entries = os.scandir(self.path)
|
entries = os.scandir(self.path)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
return ([], [])
|
return [], []
|
||||||
|
|
||||||
dirs, files = [], []
|
dirs, files = [], []
|
||||||
|
|
||||||
@ -56,4 +56,4 @@ class GetFilesAndDirs:
|
|||||||
|
|
||||||
folders = filter(lambda f: f.has_tracks, folders)
|
folders = filter(lambda f: f.has_tracks, folders)
|
||||||
|
|
||||||
return (tracks, folders) # type: ignore
|
return tracks, folders # type: ignore
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
from concurrent.futures import ThreadPoolExecutor
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
import os
|
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
|
|
||||||
from app import settings
|
from app import settings
|
||||||
@ -139,4 +138,4 @@ class ProcessTrackThumbnails:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
results = [r for r in results]
|
list(results)
|
||||||
|
@ -111,7 +111,7 @@ def get_tags(filepath: str):
|
|||||||
if p == "" or p is None:
|
if p == "" or p is None:
|
||||||
maybe = parse_artist_from_filename(filename)
|
maybe = parse_artist_from_filename(filename)
|
||||||
|
|
||||||
if maybe != []:
|
if maybe:
|
||||||
setattr(tags, tag, ", ".join(maybe))
|
setattr(tags, tag, ", ".join(maybe))
|
||||||
else:
|
else:
|
||||||
setattr(tags, tag, "Unknown")
|
setattr(tags, tag, "Unknown")
|
||||||
@ -174,8 +174,3 @@ def get_tags(filepath: str):
|
|||||||
del tags[tag]
|
del tags[tag]
|
||||||
|
|
||||||
return tags
|
return tags
|
||||||
|
|
||||||
for tag in to_delete:
|
|
||||||
del tags[tag]
|
|
||||||
|
|
||||||
return tags
|
|
||||||
|
@ -181,6 +181,7 @@ def log_startup_info():
|
|||||||
adresses = ["localhost", get_ip()]
|
adresses = ["localhost", get_ip()]
|
||||||
|
|
||||||
for address in adresses:
|
for address in adresses:
|
||||||
|
# noinspection HttpUrlsUsage
|
||||||
print(
|
print(
|
||||||
f"Started app on: {TCOLOR.OKGREEN}http://{address}:{Variables.FLASK_PORT}{TCOLOR.ENDC}"
|
f"Started app on: {TCOLOR.OKGREEN}http://{address}:{Variables.FLASK_PORT}{TCOLOR.ENDC}"
|
||||||
)
|
)
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
from hypothesis import given
|
from hypothesis import given
|
||||||
from hypothesis import strategies as st
|
|
||||||
|
|
||||||
import app.utils
|
|
||||||
from app.utils import parse_feat_from_title
|
from app.utils import parse_feat_from_title
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user