Tuning replace_files.py
This commit is contained in:
parent
a0c074adad
commit
c9a411d15d
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
|
import pydymenu
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@ -33,9 +34,9 @@ from sqlalchemy.exc import IntegrityError
|
|||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
# ###################### SETTINGS #########################
|
# ###################### SETTINGS #########################
|
||||||
process_multiple_matches = False
|
process_multiple_matches = True
|
||||||
do_processing = False
|
do_processing = True
|
||||||
process_no_matches = False
|
process_no_matches = True
|
||||||
# #########################################################
|
# #########################################################
|
||||||
|
|
||||||
|
|
||||||
@ -96,37 +97,28 @@ def main():
|
|||||||
match_count = len(matches)
|
match_count = len(matches)
|
||||||
if match_count == 0:
|
if match_count == 0:
|
||||||
if process_no_matches:
|
if process_no_matches:
|
||||||
print(f"\n file={fname}\n title={us_t}\n artist={us_a}\n")
|
prompt = f"\n file={fname}\n title={us_t}\n artist={us_a}: "
|
||||||
# Try fuzzy search
|
# Use fzf to search
|
||||||
d = {}
|
choice = pydymenu.fzf(tracks, prompt)
|
||||||
while True:
|
if choice:
|
||||||
for i, match in enumerate(
|
old_file = os.path.join(parent_dir, choice[0])
|
||||||
[a[0] for a in process.extract(fname, tracks, limit=5)]
|
|
||||||
):
|
|
||||||
d[i] = match
|
|
||||||
for k, v in d.items():
|
|
||||||
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)
|
oldtags = get_tags(old_file)
|
||||||
old_title = oldtags['title']
|
old_title = oldtags['title']
|
||||||
old_artist = oldtags['artist']
|
old_artist = oldtags['artist']
|
||||||
print()
|
print()
|
||||||
print(f" Title tag will change {old_title} → {us_t}")
|
print(f" File name will change {choice[0]}")
|
||||||
print(f" Artist tag will change {old_artist} → {us_a}")
|
print(f" → {fname}")
|
||||||
|
print()
|
||||||
|
print(f" Title tag will change {old_title}")
|
||||||
|
print(f" → {us_t}")
|
||||||
|
print()
|
||||||
|
print(f" Artist tag will change {old_artist}")
|
||||||
|
print(f" → {us_a}")
|
||||||
print()
|
print()
|
||||||
data = input("Go ahead (y to accept)? ")
|
data = input("Go ahead (y to accept)? ")
|
||||||
if data == "y":
|
if data == "y":
|
||||||
process_track(new_file, old_file, us_t, us_a)
|
process_track(new_file, old_file, us_t, us_a)
|
||||||
break
|
continue
|
||||||
else:
|
else:
|
||||||
no_match.append(f"{fname}, {us_t=}, {us_a=}")
|
no_match.append(f"{fname}, {us_t=}, {us_a=}")
|
||||||
continue
|
continue
|
||||||
|
|||||||
44
poetry.lock
generated
44
poetry.lock
generated
@ -73,6 +73,17 @@ category = "dev"
|
|||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
|
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "commonmark"
|
||||||
|
version = "0.9.1"
|
||||||
|
description = "Python parser for the CommonMark Markdown spec"
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = "*"
|
||||||
|
|
||||||
|
[package.extras]
|
||||||
|
test = ["hypothesis (==3.55.3)", "flake8 (==3.7.8)"]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "decorator"
|
name = "decorator"
|
||||||
version = "5.1.1"
|
version = "5.1.1"
|
||||||
@ -366,6 +377,17 @@ category = "dev"
|
|||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.8,<4.0"
|
python-versions = ">=3.8,<4.0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pydymenu"
|
||||||
|
version = "0.5.2"
|
||||||
|
description = "A pythonic wrapper interface for fzf, dmenu, and rofi."
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = "*"
|
||||||
|
|
||||||
|
[package.dependencies]
|
||||||
|
rich = "*"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pyfzf"
|
name = "pyfzf"
|
||||||
version = "0.3.1"
|
version = "0.3.1"
|
||||||
@ -378,7 +400,7 @@ python-versions = "*"
|
|||||||
name = "pygments"
|
name = "pygments"
|
||||||
version = "2.11.2"
|
version = "2.11.2"
|
||||||
description = "Pygments is a syntax highlighting package written in Python."
|
description = "Pygments is a syntax highlighting package written in Python."
|
||||||
category = "dev"
|
category = "main"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.5"
|
python-versions = ">=3.5"
|
||||||
|
|
||||||
@ -519,6 +541,21 @@ category = "main"
|
|||||||
optional = false
|
optional = false
|
||||||
python-versions = "*"
|
python-versions = "*"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rich"
|
||||||
|
version = "12.5.1"
|
||||||
|
description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal"
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.6.3,<4.0.0"
|
||||||
|
|
||||||
|
[package.dependencies]
|
||||||
|
commonmark = ">=0.9.0,<0.10.0"
|
||||||
|
pygments = ">=2.6.0,<3.0.0"
|
||||||
|
|
||||||
|
[package.extras]
|
||||||
|
jupyter = ["ipywidgets (>=7.5.1,<8.0.0)"]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "six"
|
name = "six"
|
||||||
version = "1.16.0"
|
version = "1.16.0"
|
||||||
@ -671,7 +708,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 = "91e055875df86707e1ce1544b1d29126265011d750897912daa37af3fe005498"
|
||||||
|
|
||||||
[metadata.files]
|
[metadata.files]
|
||||||
alembic = [
|
alembic = [
|
||||||
@ -702,6 +739,7 @@ colorama = [
|
|||||||
{file = "colorama-0.4.4-py2.py3-none-any.whl", hash = "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"},
|
{file = "colorama-0.4.4-py2.py3-none-any.whl", hash = "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"},
|
||||||
{file = "colorama-0.4.4.tar.gz", hash = "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b"},
|
{file = "colorama-0.4.4.tar.gz", hash = "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b"},
|
||||||
]
|
]
|
||||||
|
commonmark = []
|
||||||
decorator = [
|
decorator = [
|
||||||
{file = "decorator-5.1.1-py3-none-any.whl", hash = "sha256:b8c3f85900b9dc423225913c5aace94729fe1fa9763b38939a95226f02d37186"},
|
{file = "decorator-5.1.1-py3-none-any.whl", hash = "sha256:b8c3f85900b9dc423225913c5aace94729fe1fa9763b38939a95226f02d37186"},
|
||||||
{file = "decorator-5.1.1.tar.gz", hash = "sha256:637996211036b6385ef91435e4fae22989472f9d571faba8927ba8253acbc330"},
|
{file = "decorator-5.1.1.tar.gz", hash = "sha256:637996211036b6385ef91435e4fae22989472f9d571faba8927ba8253acbc330"},
|
||||||
@ -944,6 +982,7 @@ 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 = []
|
||||||
|
pydymenu = []
|
||||||
pyfzf = []
|
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"},
|
||||||
@ -1020,6 +1059,7 @@ python-vlc = [
|
|||||||
{file = "python-vlc-3.0.16120.tar.gz", hash = "sha256:92f98fee088f72bd6d063b3b3312d0bd29b37e7ad65ddeb3a7303320300c2807"},
|
{file = "python-vlc-3.0.16120.tar.gz", hash = "sha256:92f98fee088f72bd6d063b3b3312d0bd29b37e7ad65ddeb3a7303320300c2807"},
|
||||||
{file = "python_vlc-3.0.16120-py3-none-any.whl", hash = "sha256:c409afb38fe9f788a663b4302ca583f31289ef0860ab2b1668da96bbe8f14bfc"},
|
{file = "python_vlc-3.0.16120-py3-none-any.whl", hash = "sha256:c409afb38fe9f788a663b4302ca583f31289ef0860ab2b1668da96bbe8f14bfc"},
|
||||||
]
|
]
|
||||||
|
rich = []
|
||||||
six = [
|
six = [
|
||||||
{file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"},
|
{file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"},
|
||||||
{file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"},
|
{file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"},
|
||||||
|
|||||||
@ -22,6 +22,7 @@ python-slugify = "^6.1.2"
|
|||||||
thefuzz = "^0.19.0"
|
thefuzz = "^0.19.0"
|
||||||
python-Levenshtein = "^0.12.2"
|
python-Levenshtein = "^0.12.2"
|
||||||
pyfzf = "^0.3.1"
|
pyfzf = "^0.3.1"
|
||||||
|
pydymenu = "^0.5.2"
|
||||||
|
|
||||||
[tool.poetry.dev-dependencies]
|
[tool.poetry.dev-dependencies]
|
||||||
ipdb = "^0.13.9"
|
ipdb = "^0.13.9"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user