Compare commits
No commits in common. "5f8d8572ad59b169ec3b4bb4b201fbba1b997551" and "bcc6634e348b82a37b47249887983f1dc5ee2ba3" have entirely different histories.
5f8d8572ad
...
bcc6634e34
@ -508,7 +508,7 @@ class Tracks(Base):
|
|||||||
start_gap = Column(Integer, index=False)
|
start_gap = Column(Integer, index=False)
|
||||||
fade_at = Column(Integer, index=False)
|
fade_at = Column(Integer, index=False)
|
||||||
silence_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)
|
mtime = Column(Float, index=True)
|
||||||
playlistrows = relationship("PlaylistRows", back_populates="track")
|
playlistrows = relationship("PlaylistRows", back_populates="track")
|
||||||
playlists = association_proxy("playlistrows", "playlist")
|
playlists = association_proxy("playlistrows", "playlist")
|
||||||
|
|||||||
@ -32,12 +32,6 @@ from thefuzz import process
|
|||||||
from string import ascii_lowercase as letters
|
from string import ascii_lowercase as letters
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
# ###################### SETTINGS #########################
|
|
||||||
process_multiple_matches = True
|
|
||||||
do_processing = True
|
|
||||||
process_no_matches = True
|
|
||||||
# #########################################################
|
|
||||||
|
|
||||||
|
|
||||||
def insensitive_glob(pattern):
|
def insensitive_glob(pattern):
|
||||||
def either(c):
|
def either(c):
|
||||||
@ -50,6 +44,10 @@ source_dir = '/home/kae/music/Singles/tmp' # os.getcwd()
|
|||||||
parent_dir = os.path.dirname(source_dir)
|
parent_dir = os.path.dirname(source_dir)
|
||||||
assert source_dir != parent_dir
|
assert source_dir != parent_dir
|
||||||
|
|
||||||
|
process_multiple_matches = True
|
||||||
|
do_processing = False
|
||||||
|
process_no_matches = True
|
||||||
|
|
||||||
name_and_tags: List[str] = []
|
name_and_tags: List[str] = []
|
||||||
name_not_tags: List[str] = []
|
name_not_tags: List[str] = []
|
||||||
tags_not_name: List[str] = []
|
tags_not_name: List[str] = []
|
||||||
@ -91,47 +89,33 @@ def main():
|
|||||||
matches = insensitive_glob(os.path.join(parent_dir, stem) + '*')
|
matches = insensitive_glob(os.path.join(parent_dir, stem) + '*')
|
||||||
match_count = len(matches)
|
match_count = len(matches)
|
||||||
if match_count == 0:
|
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")
|
print(f"\n file={fname}\n title={us_t}\n artist={us_a}\n")
|
||||||
# Try fuzzy search
|
# Try fuzzy search
|
||||||
d = {}
|
d = {}
|
||||||
while True:
|
while True:
|
||||||
for i, match in enumerate(
|
for i, match in enumerate(
|
||||||
[a[0] for a in process.extract(fname, tracks, limit=5)]
|
[a[0] for a in process.extract(fname, tracks, limit=5)]
|
||||||
):
|
):
|
||||||
d[i] = match
|
d[i] = match
|
||||||
for k, v in d.items():
|
for k, v in d.items():
|
||||||
print(f"{k}: {v}")
|
print(f"{k}: {v}")
|
||||||
data = input("pick one, return to quit: ")
|
data = input("pick one, return to quit: ")
|
||||||
if data == "":
|
if data == "":
|
||||||
no_match.append(f"{fname}, {us_t=}, {us_a=}")
|
break
|
||||||
break
|
try:
|
||||||
try:
|
key = int(data)
|
||||||
key = int(data)
|
except ValueError:
|
||||||
except ValueError:
|
continue
|
||||||
continue
|
if key in d:
|
||||||
if key in d:
|
print("***KAE confirm with tags")
|
||||||
old_file = os.path.join(parent_dir, d[key])
|
dst = d[key]
|
||||||
oldtags = get_tags(old_file)
|
process_track(new_file, dst, us_t, us_a)
|
||||||
old_title = oldtags['title']
|
break
|
||||||
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)
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
no_match.append(f"{fname}, {us_t=}, {us_a=}")
|
|
||||||
continue
|
|
||||||
no_match.append(f"{fname}, {us_t=}, {us_a=}")
|
|
||||||
continue
|
|
||||||
else:
|
else:
|
||||||
no_match.append(f"{fname}, {us_t=}, {us_a=}")
|
|
||||||
continue
|
continue
|
||||||
|
continue # from break after testing for "" in data
|
||||||
|
continue
|
||||||
if match_count > 1:
|
if match_count > 1:
|
||||||
multiple_similar.append(fname + "\n " + "\n ".join(matches))
|
multiple_similar.append(fname + "\n " + "\n ".join(matches))
|
||||||
if match_count <= 26 and process_multiple_matches:
|
if match_count <= 26 and process_multiple_matches:
|
||||||
@ -220,10 +204,7 @@ def process_track(src, dst, title, artist):
|
|||||||
|
|
||||||
os.unlink(dst)
|
os.unlink(dst)
|
||||||
shutil.move(src, new_path)
|
shutil.move(src, new_path)
|
||||||
try:
|
track = Tracks.get_by_path(session, new_path)
|
||||||
track = Tracks.get_by_path(session, new_path)
|
|
||||||
except:
|
|
||||||
import ipdb; ipdb.set_trace()
|
|
||||||
if track:
|
if track:
|
||||||
track.rescan(session)
|
track.rescan(session)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@ -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
20
poetry.lock
generated
@ -366,14 +366,6 @@ category = "dev"
|
|||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.8,<4.0"
|
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]]
|
[[package]]
|
||||||
name = "pygments"
|
name = "pygments"
|
||||||
version = "2.11.2"
|
version = "2.11.2"
|
||||||
@ -489,14 +481,6 @@ pytest = ">=3.0.0"
|
|||||||
dev = ["pre-commit", "tox"]
|
dev = ["pre-commit", "tox"]
|
||||||
doc = ["sphinx", "sphinx-rtd-theme"]
|
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]]
|
[[package]]
|
||||||
name = "python-slugify"
|
name = "python-slugify"
|
||||||
version = "6.1.2"
|
version = "6.1.2"
|
||||||
@ -671,7 +655,7 @@ python-versions = "*"
|
|||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "1.1"
|
lock-version = "1.1"
|
||||||
python-versions = "^3.9"
|
python-versions = "^3.9"
|
||||||
content-hash = "b181eb743e8b6c9cb7e03c4db0bcef425fe410d2ec3c4c801ce20e448a26f166"
|
content-hash = "f56b509dd26d76adcd2c01ee04f9e80ed736fb5189b27bcb5e005fc50ba773c9"
|
||||||
|
|
||||||
[metadata.files]
|
[metadata.files]
|
||||||
alembic = [
|
alembic = [
|
||||||
@ -944,7 +928,6 @@ pydub = [
|
|||||||
{file = "pydub-0.25.1.tar.gz", hash = "sha256:980a33ce9949cab2a569606b65674d748ecbca4f0796887fd6f46173a7b0d30f"},
|
{file = "pydub-0.25.1.tar.gz", hash = "sha256:980a33ce9949cab2a569606b65674d748ecbca4f0796887fd6f46173a7b0d30f"},
|
||||||
]
|
]
|
||||||
pydub-stubs = []
|
pydub-stubs = []
|
||||||
pyfzf = []
|
|
||||||
pygments = [
|
pygments = [
|
||||||
{file = "Pygments-2.11.2-py3-none-any.whl", hash = "sha256:44238f1b60a76d78fc8ca0528ee429702aae011c265fe6a8dd8b63049ae41c65"},
|
{file = "Pygments-2.11.2-py3-none-any.whl", hash = "sha256:44238f1b60a76d78fc8ca0528ee429702aae011c265fe6a8dd8b63049ae41c65"},
|
||||||
{file = "Pygments-2.11.2.tar.gz", hash = "sha256:4e426f72023d88d03b2fa258de560726ce890ff3b630f88c21cbb8b2503b8c6a"},
|
{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.tar.gz", hash = "sha256:dfc5240dec7eb43b76bcb5f9a87eecae6ef83592af49f3af5f1d5d093acaa93e"},
|
||||||
{file = "pytest_qt-4.0.2-py2.py3-none-any.whl", hash = "sha256:e03847ac02a890ccaac0fde1748855b9dce425aceba62005c6cfced6cf7d5456"},
|
{file = "pytest_qt-4.0.2-py2.py3-none-any.whl", hash = "sha256:e03847ac02a890ccaac0fde1748855b9dce425aceba62005c6cfced6cf7d5456"},
|
||||||
]
|
]
|
||||||
python-levenshtein = []
|
|
||||||
python-slugify = []
|
python-slugify = []
|
||||||
python-vlc = [
|
python-vlc = [
|
||||||
{file = "python-vlc-3.0.16120.tar.gz", hash = "sha256:92f98fee088f72bd6d063b3b3312d0bd29b37e7ad65ddeb3a7303320300c2807"},
|
{file = "python-vlc-3.0.16120.tar.gz", hash = "sha256:92f98fee088f72bd6d063b3b3312d0bd29b37e7ad65ddeb3a7303320300c2807"},
|
||||||
|
|||||||
@ -20,8 +20,6 @@ PyQt5-sip = "^12.9.1"
|
|||||||
types-psutil = "^5.8.22"
|
types-psutil = "^5.8.22"
|
||||||
python-slugify = "^6.1.2"
|
python-slugify = "^6.1.2"
|
||||||
thefuzz = "^0.19.0"
|
thefuzz = "^0.19.0"
|
||||||
python-Levenshtein = "^0.12.2"
|
|
||||||
pyfzf = "^0.3.1"
|
|
||||||
|
|
||||||
[tool.poetry.dev-dependencies]
|
[tool.poetry.dev-dependencies]
|
||||||
ipdb = "^0.13.9"
|
ipdb = "^0.13.9"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user