Fixup replace_files for Alchemical
This commit is contained in:
parent
2e8fae99ed
commit
1011b2f549
@ -4,20 +4,25 @@
|
|||||||
# the current directory contains a "better" version of the file than the
|
# the current directory contains a "better" version of the file than the
|
||||||
# parent (eg, bettet bitrate).
|
# parent (eg, bettet bitrate).
|
||||||
|
|
||||||
|
# Standard library imports
|
||||||
import os
|
import os
|
||||||
import pydymenu # type: ignore
|
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
# PyQt imports
|
||||||
|
|
||||||
|
# Third party imports
|
||||||
|
import pydymenu # type: ignore
|
||||||
|
from sqlalchemy.exc import IntegrityError
|
||||||
|
from sqlalchemy.orm.session import Session
|
||||||
|
|
||||||
|
# App imports
|
||||||
from helpers import (
|
from helpers import (
|
||||||
get_tags,
|
get_tags,
|
||||||
set_track_metadata,
|
set_track_metadata,
|
||||||
)
|
)
|
||||||
|
from models import db, Tracks
|
||||||
from models import Tracks
|
|
||||||
from dbconfig import Session
|
|
||||||
from sqlalchemy.exc import IntegrityError
|
|
||||||
from typing import List
|
|
||||||
|
|
||||||
# ###################### SETTINGS #########################
|
# ###################### SETTINGS #########################
|
||||||
process_name_and_tags_matches = True
|
process_name_and_tags_matches = True
|
||||||
@ -42,7 +47,7 @@ def main():
|
|||||||
# We only want to run this against the production database because
|
# We only want to run this against the production database because
|
||||||
# we will affect files in the common pool of tracks used by all
|
# we will affect files in the common pool of tracks used by all
|
||||||
# databases
|
# databases
|
||||||
if "musicmuster_prod" not in os.environ.get("MM_DB"):
|
if "musicmuster_prod" not in os.environ.get("ALCHEMICAL_DATABASE_URI"):
|
||||||
response = input("Not on production database - c to continue: ")
|
response = input("Not on production database - c to continue: ")
|
||||||
if response != "c":
|
if response != "c":
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
@ -51,7 +56,7 @@ def main():
|
|||||||
assert source_dir != parent_dir
|
assert source_dir != parent_dir
|
||||||
|
|
||||||
# Scan parent directory
|
# Scan parent directory
|
||||||
with Session() as session:
|
with db.Session() as session:
|
||||||
all_tracks = Tracks.get_all(session)
|
all_tracks = Tracks.get_all(session)
|
||||||
parent_tracks = [a for a in all_tracks if parent_dir in a.path]
|
parent_tracks = [a for a in all_tracks if parent_dir in a.path]
|
||||||
parent_fnames = [os.path.basename(a.path) for a in parent_tracks]
|
parent_fnames = [os.path.basename(a.path) for a in parent_tracks]
|
||||||
@ -239,7 +244,7 @@ def process_track(src, dst, title, artist, bitrate):
|
|||||||
if not do_processing:
|
if not do_processing:
|
||||||
return
|
return
|
||||||
|
|
||||||
with Session() as session:
|
with db.Session() as session:
|
||||||
track = Tracks.get_by_path(session, dst)
|
track = Tracks.get_by_path(session, dst)
|
||||||
if track:
|
if track:
|
||||||
# Update path, but workaround MariaDB bug
|
# Update path, but workaround MariaDB bug
|
||||||
|
|||||||
@ -59,7 +59,7 @@ explicit_package_bases = true
|
|||||||
[tool.pytest.ini_options]
|
[tool.pytest.ini_options]
|
||||||
addopts = "--exitfirst --showlocals --capture=no"
|
addopts = "--exitfirst --showlocals --capture=no"
|
||||||
pythonpath = [".", "app"]
|
pythonpath = [".", "app"]
|
||||||
filterwarnings = "ignore:'audioop' is deprecated"
|
filterwarnings = ["ignore:'audioop' is deprecated", "ignore:pkg_resources"]
|
||||||
|
|
||||||
[tool.vulture]
|
[tool.vulture]
|
||||||
exclude = ["migrations", "app/ui", "archive"]
|
exclude = ["migrations", "app/ui", "archive"]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user