From 28be65df8524e17b3d47d52ee5f162deaf69725c Mon Sep 17 00:00:00 2001 From: Lars Noack Date: Mon, 16 Jan 2023 12:57:04 +0100 Subject: [PATCH] crime --- src/music_kraken/database/new_database.py | 2 +- src/music_kraken/database/objects/metadata.py | 41 +++++++++++++++--- test.db | Bin 69632 -> 69632 bytes 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/music_kraken/database/new_database.py b/src/music_kraken/database/new_database.py index a0888fe..b0cf386 100644 --- a/src/music_kraken/database/new_database.py +++ b/src/music_kraken/database/new_database.py @@ -546,7 +546,7 @@ class Database: label=album_result['label'], album_status=album_result['album_status'], language=pycountry.languages.get(alpha_3=album_result['language']), - date=datetime.datetime.strptime(album_result['date'], "%Y-%m-%d").date(), + date=ID3Timestamp.strptime(album_result['date'], "%Y-%m-%d"), country=album_result['country'], barcode=album_result['barcode'], is_split=album_result['is_split'], diff --git a/src/music_kraken/database/objects/metadata.py b/src/music_kraken/database/objects/metadata.py index e452c21..4060c5b 100644 --- a/src/music_kraken/database/objects/metadata.py +++ b/src/music_kraken/database/objects/metadata.py @@ -184,15 +184,42 @@ class ID3Timestamp: @classmethod def strptime(cls, time_stamp: str, format: str): - date_obj = datetime.datetime.strftime(time_stamp, format) + """ + day: "%d" + month: "%b", "%B", "%m" + year: "%y", "%Y" + hour: "%H", "%I" + minute: "%M" + second: "%S" + """ + date_obj = datetime.datetime.strptime(time_stamp, format) + + day = None + if "%d" in format: + day = date_obj.day + month = None + if any([i in format for i in ("%b", "%B", "%m")]): + month = date_obj.month + year = None + if any([i in format for i in ("%y", "%Y")]): + year = date_obj.year + hour = None + if any([i in format for i in ("%H", "%I")]): + hour = date_obj.hour + minute = None + if "%M" in format: + minute = date_obj.minute + second = None + if "%S" in format: + second = date_obj.second return cls( - year=date_obj.year, - month=date_obj.month, - day=date_obj.day, - hour=date_obj.hour, - minute=date_obj.minute, - second=date_obj.second + year=year, + month=month, + day=day, + hour=hour, + minute=minute, + second=second ) @classmethod diff --git a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