datetime fix for yyyymmdd format
This commit is contained in:
parent
773b4a8a46
commit
5d6c85387d
7
main.py
7
main.py
@ -287,9 +287,10 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
|
||||
self.permanent_status_label.setText(message)
|
||||
|
||||
def play_audio_file(self) -> None:
|
||||
"""Start playback of tableView.current_song_filepath track & moves playback slider"""
|
||||
"""Start playback of `tableView.current_song_filepath` & moves playback slider"""
|
||||
# get metadata
|
||||
self.current_song_metadata = self.tableView.get_current_song_metadata()
|
||||
print(f'current_song_metadata: {self.current_song_metadata}')
|
||||
# read the file
|
||||
url = QUrl.fromLocalFile(self.tableView.get_current_song_filepath())
|
||||
# load the audio content
|
||||
@ -300,7 +301,7 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
|
||||
self.move_slider() # mover
|
||||
# self.player.setPlaybackRate(1.5)
|
||||
|
||||
# assign metadata
|
||||
# assign "now playing" labels & album artwork
|
||||
if self.current_song_metadata is not None:
|
||||
artist = (
|
||||
self.current_song_metadata["TPE1"][0]
|
||||
@ -313,7 +314,7 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
|
||||
else None
|
||||
)
|
||||
title = self.current_song_metadata["TIT2"][0]
|
||||
# edit labels
|
||||
|
||||
self.artistLabel.setText(artist)
|
||||
self.albumLabel.setText(album)
|
||||
self.titleLabel.setText(title)
|
||||
|
||||
@ -7,5 +7,8 @@ def id3_timestamp_to_datetime(timestamp: ID3TimeStamp):
|
||||
if len(timestamp.text) == 4: # If only year is provided
|
||||
datetime_obj = datetime.datetime.strptime(timestamp.text, '%Y')
|
||||
else:
|
||||
try:
|
||||
datetime_obj = datetime.datetime.strptime(timestamp.text, '%Y-%m-%d')
|
||||
except ValueError:
|
||||
datetime_obj = datetime.datetime.strptime(timestamp.text, '%Y%m%d')
|
||||
return datetime_obj.strftime('%Y-%m-%d')
|
||||
|
||||
@ -136,6 +136,6 @@ def set_id3_tag(filepath: str, tag_name: str, value: str):
|
||||
audio_file.save(filepath)
|
||||
return True
|
||||
except Exception as e:
|
||||
dialog = ErrorDialog(f"An unhandled exception occurred:\n{e}")
|
||||
dialog = ErrorDialog(f"set_id3_tag.py | An unhandled exception occurred:\n{e}")
|
||||
dialog.exec_()
|
||||
return False
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user