mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 04:53:01 +00:00
add route to open a file in file manager
+ try a new approach of cleaning remasters from track titles
This commit is contained in:
+4
-1
@@ -2,7 +2,6 @@
|
||||
Contains all the artist(s) routes.
|
||||
"""
|
||||
from collections import deque
|
||||
from pprint import pprint
|
||||
|
||||
from flask import Blueprint, request
|
||||
|
||||
@@ -44,6 +43,10 @@ class ArtistsCache:
|
||||
"""
|
||||
|
||||
artists: deque[CacheEntry] = deque(maxlen=1)
|
||||
# THE ABOVE IS SET TO MAXLEN=1 TO AVOID A BUG THAT I WAS TOO LAZY TO INVESTIGATE
|
||||
# ARTIST TRACKS SOMEHOW DISAPPEARED FOR SOME REASON I COULDN'T UNDERSTAND. BY
|
||||
# DISAPPEARING I MEAN AN ARTIST YOU ARE SURE HAS 150 TRACKS ONLY SHOWING LIKE 3 IN
|
||||
# THE ARTIST PAGE. 🤷🏿 (TODO: MAYBE FIX THIS BUG?)
|
||||
|
||||
@classmethod
|
||||
def get_albums_by_artisthash(cls, artisthash: str) -> tuple[list[Album], int]:
|
||||
|
||||
+14
-1
@@ -6,13 +6,14 @@ import psutil
|
||||
|
||||
from pathlib import Path
|
||||
from flask import Blueprint, request
|
||||
from showinfm import show_in_file_manager
|
||||
|
||||
from app import settings
|
||||
from app.lib.folderslib import GetFilesAndDirs, get_folders
|
||||
from app.db.sqlite.settings import SettingsSQLMethods as db
|
||||
from app.utils.wintools import win_replace_slash, is_windows
|
||||
|
||||
api = Blueprint("folder", __name__, url_prefix="/")
|
||||
api = Blueprint("folder", __name__, url_prefix="")
|
||||
|
||||
|
||||
@api.route("/folder", methods=["POST"])
|
||||
@@ -116,3 +117,15 @@ def list_folders():
|
||||
return {
|
||||
"folders": sorted(dirs, key=lambda i: i["name"]),
|
||||
}
|
||||
|
||||
|
||||
@api.route("/folder/show-in-files")
|
||||
def open_in_file_manager():
|
||||
path = request.args.get("path")
|
||||
|
||||
if path is None:
|
||||
return {"error": "No path provided."}, 400
|
||||
|
||||
show_in_file_manager(path)
|
||||
|
||||
return {"success": True}
|
||||
|
||||
@@ -235,8 +235,13 @@ def clean_title(title: str) -> str:
|
||||
if "remaster" not in title.lower():
|
||||
return title
|
||||
|
||||
if "-" in title:
|
||||
return remove_hyphen_remasters(title)
|
||||
rem_1 = remove_bracketed_remaster(title)
|
||||
rem_2 = remove_hyphen_remasters(title)
|
||||
|
||||
if "[" in title or "(" in title:
|
||||
return remove_bracketed_remaster(title)
|
||||
return rem_1 if len(rem_2) > len(rem_1) else rem_2
|
||||
|
||||
# if "[" in title or "(" in title:
|
||||
# return remove_bracketed_remaster(title)
|
||||
#
|
||||
# if "-" in title:
|
||||
# return remove_hyphen_remasters(title)
|
||||
|
||||
Reference in New Issue
Block a user