Compare commits

..

No commits in common. "5f8d8572ad59b169ec3b4bb4b201fbba1b997551" and "bcc6634e348b82a37b47249887983f1dc5ee2ba3" have entirely different histories.

5 changed files with 31 additions and 98 deletions

View File

@ -508,7 +508,7 @@ class Tracks(Base):
start_gap = Column(Integer, index=False)
fade_at = Column(Integer, index=False)
silence_at = Column(Integer, index=False)
path = Column(String(2048), index=False, nullable=False, unique=True)
path = Column(String(2048), index=False, nullable=False)
mtime = Column(Float, index=True)
playlistrows = relationship("PlaylistRows", back_populates="track")
playlists = association_proxy("playlistrows", "playlist")

View File

@ -32,12 +32,6 @@ from thefuzz import process
from string import ascii_lowercase as letters
from typing import List
# ###################### SETTINGS #########################
process_multiple_matches = True
do_processing = True
process_no_matches = True
# #########################################################
def insensitive_glob(pattern):
def either(c):
@ -50,6 +44,10 @@ source_dir = '/home/kae/music/Singles/tmp' # os.getcwd()
parent_dir = os.path.dirname(source_dir)
assert source_dir != parent_dir
process_multiple_matches = True
do_processing = False
process_no_matches = True
name_and_tags: List[str] = []
name_not_tags: List[str] = []
tags_not_name: List[str] = []
@ -91,7 +89,7 @@ def main():
matches = insensitive_glob(os.path.join(parent_dir, stem) + '*')
match_count = len(matches)
if match_count == 0:
if process_no_matches:
no_match.append(f"{fname}, {us_t=}, {us_a=}")
print(f"\n file={fname}\n title={us_t}\n artist={us_a}\n")
# Try fuzzy search
d = {}
@ -104,34 +102,20 @@ def main():
print(f"{k}: {v}")
data = input("pick one, return to quit: ")
if data == "":
no_match.append(f"{fname}, {us_t=}, {us_a=}")
break
try:
key = int(data)
except ValueError:
continue
if key in d:
old_file = os.path.join(parent_dir, d[key])
oldtags = get_tags(old_file)
old_title = oldtags['title']
old_artist = oldtags['artist']
print()
print(f" Title tag will change {old_title}{us_t}")
print(f" Artist tag will change {old_artist}{us_a}")
print()
data = input("Go ahead (y to accept)? ")
if data == "y":
process_track(new_file, old_file, us_t, us_a)
print("***KAE confirm with tags")
dst = d[key]
process_track(new_file, dst, us_t, us_a)
break
else:
no_match.append(f"{fname}, {us_t=}, {us_a=}")
continue
no_match.append(f"{fname}, {us_t=}, {us_a=}")
continue # from break after testing for "" in data
continue
else:
no_match.append(f"{fname}, {us_t=}, {us_a=}")
continue
if match_count > 1:
multiple_similar.append(fname + "\n " + "\n ".join(matches))
if match_count <= 26 and process_multiple_matches:
@ -220,10 +204,7 @@ def process_track(src, dst, title, artist):
os.unlink(dst)
shutil.move(src, new_path)
try:
track = Tracks.get_by_path(session, new_path)
except:
import ipdb; ipdb.set_trace()
if track:
track.rescan(session)
else:

View File

@ -1,28 +0,0 @@
"""Don't allow duplicate track paths
Revision ID: fe2e127b3332
Revises: 0c604bf490f8
Create Date: 2022-08-21 19:46:35.768659
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'fe2e127b3332'
down_revision = '0c604bf490f8'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_unique_constraint(None, 'tracks', ['path'])
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'tracks', type_='unique')
# ### end Alembic commands ###

20
poetry.lock generated
View File

@ -366,14 +366,6 @@ category = "dev"
optional = false
python-versions = ">=3.8,<4.0"
[[package]]
name = "pyfzf"
version = "0.3.1"
description = "Python wrapper for junegunn's fuzzyfinder (fzf)"
category = "main"
optional = false
python-versions = "*"
[[package]]
name = "pygments"
version = "2.11.2"
@ -489,14 +481,6 @@ pytest = ">=3.0.0"
dev = ["pre-commit", "tox"]
doc = ["sphinx", "sphinx-rtd-theme"]
[[package]]
name = "python-levenshtein"
version = "0.12.2"
description = "Python extension for computing string edit distances and similarities."
category = "main"
optional = false
python-versions = "*"
[[package]]
name = "python-slugify"
version = "6.1.2"
@ -671,7 +655,7 @@ python-versions = "*"
[metadata]
lock-version = "1.1"
python-versions = "^3.9"
content-hash = "b181eb743e8b6c9cb7e03c4db0bcef425fe410d2ec3c4c801ce20e448a26f166"
content-hash = "f56b509dd26d76adcd2c01ee04f9e80ed736fb5189b27bcb5e005fc50ba773c9"
[metadata.files]
alembic = [
@ -944,7 +928,6 @@ pydub = [
{file = "pydub-0.25.1.tar.gz", hash = "sha256:980a33ce9949cab2a569606b65674d748ecbca4f0796887fd6f46173a7b0d30f"},
]
pydub-stubs = []
pyfzf = []
pygments = [
{file = "Pygments-2.11.2-py3-none-any.whl", hash = "sha256:44238f1b60a76d78fc8ca0528ee429702aae011c265fe6a8dd8b63049ae41c65"},
{file = "Pygments-2.11.2.tar.gz", hash = "sha256:4e426f72023d88d03b2fa258de560726ce890ff3b630f88c21cbb8b2503b8c6a"},
@ -1014,7 +997,6 @@ pytest-qt = [
{file = "pytest-qt-4.0.2.tar.gz", hash = "sha256:dfc5240dec7eb43b76bcb5f9a87eecae6ef83592af49f3af5f1d5d093acaa93e"},
{file = "pytest_qt-4.0.2-py2.py3-none-any.whl", hash = "sha256:e03847ac02a890ccaac0fde1748855b9dce425aceba62005c6cfced6cf7d5456"},
]
python-levenshtein = []
python-slugify = []
python-vlc = [
{file = "python-vlc-3.0.16120.tar.gz", hash = "sha256:92f98fee088f72bd6d063b3b3312d0bd29b37e7ad65ddeb3a7303320300c2807"},

View File

@ -20,8 +20,6 @@ PyQt5-sip = "^12.9.1"
types-psutil = "^5.8.22"
python-slugify = "^6.1.2"
thefuzz = "^0.19.0"
python-Levenshtein = "^0.12.2"
pyfzf = "^0.3.1"
[tool.poetry.dev-dependencies]
ipdb = "^0.13.9"