Set bitrate in replace_files.py

This commit is contained in:
Keith Edmunds 2022-08-23 09:32:26 +01:00
parent c9a411d15d
commit 688267834d

View File

@ -73,6 +73,7 @@ def main():
us = get_tags(new_file)
us_t = us['title']
us_a = us['artist']
bitrate = us['bitrate']
if os.path.exists(parent_file):
# File exists, check tags
@ -85,10 +86,10 @@ def main():
):
name_not_tags.append(
f" {fname=}, {p_t}{us_t}, {p_a}{us_a}")
process_track(new_file, parent_file, us_t, us_a)
process_track(new_file, parent_file, us_t, us_a, bitrate)
continue
name_and_tags.append(new_file)
process_track(new_file, parent_file, us_t, us_a)
process_track(new_file, parent_file, us_t, us_a, bitrate)
continue
# Try to find a near match
@ -117,7 +118,7 @@ def main():
print()
data = input("Go ahead (y to accept)? ")
if data == "y":
process_track(new_file, old_file, us_t, us_a)
process_track(new_file, old_file, us_t, us_a, bitrate)
continue
else:
no_match.append(f"{fname}, {us_t=}, {us_a=}")
@ -147,7 +148,7 @@ def main():
continue
if key in d:
dst = d[key]
process_track(new_file, dst, us_t, us_a)
process_track(new_file, dst, us_t, us_a, bitrate)
break
else:
continue
@ -165,10 +166,10 @@ def main():
f"File: {os.path.basename(sim_name)}{fname}"
f"\n {p_t}{us_t}\n {p_a}{us_a}"
)
process_track(new_file, sim_name, us_t, us_a)
process_track(new_file, sim_name, us_t, us_a, bitrate)
continue
tags_not_name.append(f"Rename {os.path.basename(sim_name)}{fname}")
process_track(new_file, sim_name, us_t, us_a)
process_track(new_file, sim_name, us_t, us_a, bitrate)
print(f"Name and tags match ({len(name_and_tags)}):")
# print(" \n".join(name_and_tags))
@ -195,7 +196,7 @@ def main():
print()
def process_track(src, dst, title, artist):
def process_track(src, dst, title, artist, bitrate):
new_path = os.path.join(os.path.dirname(dst), os.path.basename(src))
print(
@ -212,6 +213,7 @@ def process_track(src, dst, title, artist):
track.title = title
track.artist = artist
track.path = new_path
track.bitrate = bitrate
try:
session.commit()
except IntegrityError:
@ -220,6 +222,7 @@ def process_track(src, dst, title, artist):
track.title = title
track.artist = artist
track.path = "DUMMY"
track.bitrate = bitrate
session.commit()
track.path = new_path
session.commit()