add route to open a file in file manager

+ try a new approach of cleaning remasters from track titles
This commit is contained in:
geoffrey45
2023-05-09 13:25:31 +03:00
parent b9f0204225
commit 740f45b9ac
5 changed files with 83 additions and 8 deletions
+4 -1
View File
@@ -2,7 +2,6 @@
Contains all the artist(s) routes. Contains all the artist(s) routes.
""" """
from collections import deque from collections import deque
from pprint import pprint
from flask import Blueprint, request from flask import Blueprint, request
@@ -44,6 +43,10 @@ class ArtistsCache:
""" """
artists: deque[CacheEntry] = deque(maxlen=1) 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 @classmethod
def get_albums_by_artisthash(cls, artisthash: str) -> tuple[list[Album], int]: def get_albums_by_artisthash(cls, artisthash: str) -> tuple[list[Album], int]:
+14 -1
View File
@@ -6,13 +6,14 @@ import psutil
from pathlib import Path from pathlib import Path
from flask import Blueprint, request from flask import Blueprint, request
from showinfm import show_in_file_manager
from app import settings from app import settings
from app.lib.folderslib import GetFilesAndDirs, get_folders from app.lib.folderslib import GetFilesAndDirs, get_folders
from app.db.sqlite.settings import SettingsSQLMethods as db from app.db.sqlite.settings import SettingsSQLMethods as db
from app.utils.wintools import win_replace_slash, is_windows 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"]) @api.route("/folder", methods=["POST"])
@@ -116,3 +117,15 @@ def list_folders():
return { return {
"folders": sorted(dirs, key=lambda i: i["name"]), "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}
+9 -4
View File
@@ -235,8 +235,13 @@ def clean_title(title: str) -> str:
if "remaster" not in title.lower(): if "remaster" not in title.lower():
return title return title
if "-" in title: rem_1 = remove_bracketed_remaster(title)
return remove_hyphen_remasters(title) rem_2 = remove_hyphen_remasters(title)
if "[" in title or "(" in title: return rem_1 if len(rem_2) > len(rem_1) else rem_2
return remove_bracketed_remaster(title)
# if "[" in title or "(" in title:
# return remove_bracketed_remaster(title)
#
# if "-" in title:
# return remove_hyphen_remasters(title)
Generated
+55 -2
View File
@@ -568,7 +568,7 @@ files = [
name = "packaging" name = "packaging"
version = "23.0" version = "23.0"
description = "Core utilities for Python packages" description = "Core utilities for Python packages"
category = "dev" category = "main"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
@@ -849,6 +849,30 @@ tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""}
[package.extras] [package.extras]
testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "xmlschema"] testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "xmlschema"]
[[package]]
name = "pywin32"
version = "306"
description = "Python for Window Extensions"
category = "main"
optional = false
python-versions = "*"
files = [
{file = "pywin32-306-cp310-cp310-win32.whl", hash = "sha256:06d3420a5155ba65f0b72f2699b5bacf3109f36acbe8923765c22938a69dfc8d"},
{file = "pywin32-306-cp310-cp310-win_amd64.whl", hash = "sha256:84f4471dbca1887ea3803d8848a1616429ac94a4a8d05f4bc9c5dcfd42ca99c8"},
{file = "pywin32-306-cp311-cp311-win32.whl", hash = "sha256:e65028133d15b64d2ed8f06dd9fbc268352478d4f9289e69c190ecd6818b6407"},
{file = "pywin32-306-cp311-cp311-win_amd64.whl", hash = "sha256:a7639f51c184c0272e93f244eb24dafca9b1855707d94c192d4a0b4c01e1100e"},
{file = "pywin32-306-cp311-cp311-win_arm64.whl", hash = "sha256:70dba0c913d19f942a2db25217d9a1b726c278f483a919f1abfed79c9cf64d3a"},
{file = "pywin32-306-cp312-cp312-win32.whl", hash = "sha256:383229d515657f4e3ed1343da8be101000562bf514591ff383ae940cad65458b"},
{file = "pywin32-306-cp312-cp312-win_amd64.whl", hash = "sha256:37257794c1ad39ee9be652da0462dc2e394c8159dfd913a8a4e8eb6fd346da0e"},
{file = "pywin32-306-cp312-cp312-win_arm64.whl", hash = "sha256:5821ec52f6d321aa59e2db7e0a35b997de60c201943557d108af9d4ae1ec7040"},
{file = "pywin32-306-cp37-cp37m-win32.whl", hash = "sha256:1c73ea9a0d2283d889001998059f5eaaba3b6238f767c9cf2833b13e6a685f65"},
{file = "pywin32-306-cp37-cp37m-win_amd64.whl", hash = "sha256:72c5f621542d7bdd4fdb716227be0dd3f8565c11b280be6315b06ace35487d36"},
{file = "pywin32-306-cp38-cp38-win32.whl", hash = "sha256:e4c092e2589b5cf0d365849e73e02c391c1349958c5ac3e9d5ccb9a28e017b3a"},
{file = "pywin32-306-cp38-cp38-win_amd64.whl", hash = "sha256:e8ac1ae3601bee6ca9f7cb4b5363bf1c0badb935ef243c4733ff9a393b1690c0"},
{file = "pywin32-306-cp39-cp39-win32.whl", hash = "sha256:e25fd5b485b55ac9c057f67d94bc203f3f6595078d1fb3b458c9c28b7153a802"},
{file = "pywin32-306-cp39-cp39-win_amd64.whl", hash = "sha256:39b61c15272833b5c329a2989999dcae836b1eed650252ab1b7bfbe1d59f30f4"},
]
[[package]] [[package]]
name = "pywin32-ctypes" name = "pywin32-ctypes"
version = "0.2.0" version = "0.2.0"
@@ -861,6 +885,18 @@ files = [
{file = "pywin32_ctypes-0.2.0-py2.py3-none-any.whl", hash = "sha256:9dc2d991b3479cc2df15930958b674a48a227d5361d413827a4cfd0b5876fc98"}, {file = "pywin32_ctypes-0.2.0-py2.py3-none-any.whl", hash = "sha256:9dc2d991b3479cc2df15930958b674a48a227d5361d413827a4cfd0b5876fc98"},
] ]
[[package]]
name = "pyxdg"
version = "0.28"
description = "PyXDG contains implementations of freedesktop.org standards in python."
category = "main"
optional = false
python-versions = "*"
files = [
{file = "pyxdg-0.28-py2.py3-none-any.whl", hash = "sha256:bdaf595999a0178ecea4052b7f4195569c1ff4d344567bccdc12dfdf02d545ab"},
{file = "pyxdg-0.28.tar.gz", hash = "sha256:3267bb3074e934df202af2ee0868575484108581e6f3cb006af1da35395e88b4"},
]
[[package]] [[package]]
name = "rapidfuzz" name = "rapidfuzz"
version = "2.13.7" version = "2.13.7"
@@ -1002,6 +1038,23 @@ docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "pygments-g
testing = ["build[virtualenv]", "filelock (>=3.4.0)", "flake8 (<5)", "flake8-2020", "ini2toml[lite] (>=0.9)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pip (>=19.1)", "pip-run (>=8.8)", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)", "pytest-perf", "pytest-timeout", "pytest-xdist", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"] testing = ["build[virtualenv]", "filelock (>=3.4.0)", "flake8 (<5)", "flake8-2020", "ini2toml[lite] (>=0.9)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pip (>=19.1)", "pip-run (>=8.8)", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)", "pytest-perf", "pytest-timeout", "pytest-xdist", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"]
testing-integration = ["build[virtualenv]", "filelock (>=3.4.0)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pytest", "pytest-enabler", "pytest-xdist", "tomli", "virtualenv (>=13.0.0)", "wheel"] testing-integration = ["build[virtualenv]", "filelock (>=3.4.0)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pytest", "pytest-enabler", "pytest-xdist", "tomli", "virtualenv (>=13.0.0)", "wheel"]
[[package]]
name = "show-in-file-manager"
version = "1.1.4"
description = "Open the system file manager and select files in it"
category = "main"
optional = false
python-versions = ">=3.6"
files = [
{file = "show-in-file-manager-1.1.4.tar.gz", hash = "sha256:15d16e4a875b9e217b038d02f029c3800c4a6ad645e3f73c9e107ea26bab3adb"},
{file = "show_in_file_manager-1.1.4-py3-none-any.whl", hash = "sha256:ccfbf212866b70f94e6e8bc1d7acf6bf0ad4447ff7dca50e7a64573b59e1a2c9"},
]
[package.dependencies]
packaging = "*"
pywin32 = {version = ">=301", markers = "platform_system == \"Windows\""}
pyxdg = {version = ">=0.25", markers = "platform_system == \"Linux\""}
[[package]] [[package]]
name = "six" name = "six"
version = "1.16.0" version = "1.16.0"
@@ -1272,4 +1325,4 @@ files = [
[metadata] [metadata]
lock-version = "2.0" lock-version = "2.0"
python-versions = ">=3.10,<3.12" python-versions = ">=3.10,<3.12"
content-hash = "28389b0d505d21df1d75e24b3662e695d076f3e387ebc807b019b676359d3157" content-hash = "cb65430f7a95cd82d5011f293ff3bba2fa972fe4f9973b2b1fffff2abb97bffd"
+1
View File
@@ -18,6 +18,7 @@ rapidfuzz = "^2.13.7"
tinytag = "^1.8.1" tinytag = "^1.8.1"
Unidecode = "^1.3.6" Unidecode = "^1.3.6"
psutil = "^5.9.4" psutil = "^5.9.4"
show-in-file-manager = "^1.1.4"
[tool.poetry.dev-dependencies] [tool.poetry.dev-dependencies]
pylint = "^2.15.5" pylint = "^2.15.5"