Set bitrate in replace_files.py
This commit is contained in:
parent
c9a411d15d
commit
688267834d
@ -73,6 +73,7 @@ def main():
|
|||||||
us = get_tags(new_file)
|
us = get_tags(new_file)
|
||||||
us_t = us['title']
|
us_t = us['title']
|
||||||
us_a = us['artist']
|
us_a = us['artist']
|
||||||
|
bitrate = us['bitrate']
|
||||||
|
|
||||||
if os.path.exists(parent_file):
|
if os.path.exists(parent_file):
|
||||||
# File exists, check tags
|
# File exists, check tags
|
||||||
@ -85,10 +86,10 @@ def main():
|
|||||||
):
|
):
|
||||||
name_not_tags.append(
|
name_not_tags.append(
|
||||||
f" {fname=}, {p_t} → {us_t}, {p_a} → {us_a}")
|
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
|
continue
|
||||||
name_and_tags.append(new_file)
|
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
|
continue
|
||||||
|
|
||||||
# Try to find a near match
|
# Try to find a near match
|
||||||
@ -117,7 +118,7 @@ def main():
|
|||||||
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, bitrate)
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
no_match.append(f"{fname}, {us_t=}, {us_a=}")
|
no_match.append(f"{fname}, {us_t=}, {us_a=}")
|
||||||
@ -147,7 +148,7 @@ def main():
|
|||||||
continue
|
continue
|
||||||
if key in d:
|
if key in d:
|
||||||
dst = d[key]
|
dst = d[key]
|
||||||
process_track(new_file, dst, us_t, us_a)
|
process_track(new_file, dst, us_t, us_a, bitrate)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
@ -165,10 +166,10 @@ def main():
|
|||||||
f"File: {os.path.basename(sim_name)} → {fname}"
|
f"File: {os.path.basename(sim_name)} → {fname}"
|
||||||
f"\n {p_t} → {us_t}\n {p_a} → {us_a}"
|
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
|
continue
|
||||||
tags_not_name.append(f"Rename {os.path.basename(sim_name)} → {fname}")
|
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(f"Name and tags match ({len(name_and_tags)}):")
|
||||||
# print(" \n".join(name_and_tags))
|
# print(" \n".join(name_and_tags))
|
||||||
@ -195,7 +196,7 @@ def main():
|
|||||||
print()
|
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))
|
new_path = os.path.join(os.path.dirname(dst), os.path.basename(src))
|
||||||
print(
|
print(
|
||||||
@ -212,6 +213,7 @@ def process_track(src, dst, title, artist):
|
|||||||
track.title = title
|
track.title = title
|
||||||
track.artist = artist
|
track.artist = artist
|
||||||
track.path = new_path
|
track.path = new_path
|
||||||
|
track.bitrate = bitrate
|
||||||
try:
|
try:
|
||||||
session.commit()
|
session.commit()
|
||||||
except IntegrityError:
|
except IntegrityError:
|
||||||
@ -220,6 +222,7 @@ def process_track(src, dst, title, artist):
|
|||||||
track.title = title
|
track.title = title
|
||||||
track.artist = artist
|
track.artist = artist
|
||||||
track.path = "DUMMY"
|
track.path = "DUMMY"
|
||||||
|
track.bitrate = bitrate
|
||||||
session.commit()
|
session.commit()
|
||||||
track.path = new_path
|
track.path = new_path
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user