metadata window fixes + maybe config

This commit is contained in:
billy 2024-08-31 09:50:47 -04:00
parent 23d0cdf437
commit a30054b6dc
3 changed files with 25 additions and 40 deletions

View File

@ -9,8 +9,7 @@ git clone https://github.com/billypom/musicpom
```
install system packages
```
sudo apt install ffmpeg
sudo apt install python3-pyqt5
sudo apt install ffmpeg, python3-pyqt5
```
create environment
```

View File

@ -74,23 +74,22 @@ class MetadataWindow(QDialog):
tag_sets[tag].append(song_data[tag].text[0])
except KeyError:
pass
print("tag sets:")
print(tag_sets)
# UI Creation
current_layout = QHBoxLayout()
for idx, (tag, value) in enumerate(tag_sets.items()):
# Layout creation
if idx == 0:
pass
elif idx % 2 == 0:
# if idx == 0:
# pass
if idx % 2 == 0:
# Make a new horizontal layout for every 2 items
layout.addLayout(current_layout)
current_layout = QHBoxLayout()
# print(f"type: {type(value)} | value: {value}")
# Field Creation
if value == list(set(value)):
print(value)
if len(set(value)) <= 1:
# If the ID3 tag is the same for every item we're editing
field_text = str(value[0]) if value else ""
# Normal field
@ -98,11 +97,10 @@ class MetadataWindow(QDialog):
input_field = ID3LineEdit(field_text, tag)
input_field.setStyleSheet(None)
else:
print(value)
# Danger field
# this means the metadata differs between the selected items for this tag
# so be careful...dangerous
field_text = str(value[0]) if value else ""
field_text = ""
label = QLabel(str(self.id3_tag_mapping[tag]))
input_field = ID3LineEdit(field_text, tag)
input_field.setStyleSheet("border: 1px solid red")
@ -124,20 +122,6 @@ class MetadataWindow(QDialog):
for tag, field in self.input_fields.items():
if field.text() is not None and field.text() != "":
if field.has_changed():
# date crap...
# if tag == "TYER":
# continue
# if tag == "TDAT":
# match = re.match(
# r"(\d{4})[-/](\d{2})[-/](\d{2})", field.text()
# )
# if not match:
# continue
# year, _, _ = match.groups()
# _ = set_id3_tag(
# filepath=song[0], tag_name="TYER", value=str(year)
# )
# BUSINESS AS USUAL
# Update the ID3 tag if the tag is not blank,
# and has been edited
success = set_id3_tag(

32
main.py
View File

@ -431,25 +431,27 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
if __name__ == "__main__":
print("its main")
# First run initialization
if not os.path.exists("config.ini"):
# Create config file from sample
run(["cp", "sample_config.ini", "config.ini"])
config = ConfigParser()
config.read("config.ini")
db_name = config.get("db", "database")
db_path = db_name.split("/")
db_path.pop()
path_as_string = "/".join(db_path)
if not os.path.exists(path_as_string):
os.makedirs(path_as_string)
# Create database on first run
with DBA.DBAccess() as db:
with open("utils/init.sql", "r") as file:
lines = file.read()
for statement in lines.split(";"):
print(f"executing [{statement}]")
db.execute(statement, ())
config = ConfigParser()
config.read("config.ini")
db_name = config.get("db", "database")
db_path = db_name.split("/")
db_path.pop()
db_path_as_string = "/".join(db_path)
print(f"db_path_as_string: {db_path_as_string}")
if not os.path.exists(db_path_as_string):
os.makedirs(db_path_as_string)
# Create database on first run
with DBA.DBAccess() as db:
with open("utils/init.sql", "r") as file:
lines = file.read()
for statement in lines.split(";"):
print(f"executing [{statement}]")
db.execute(statement, ())
# logging setup
logging.basicConfig(filename="musicpom.log", encoding="utf-8", level=logging.DEBUG)
# Allow for dynamic imports of my custom classes and utilities