From 0ca8adac6f39fa623569952e66f7c30cc8acf7bc Mon Sep 17 00:00:00 2001 From: Hellow Date: Tue, 10 Jan 2023 19:21:11 +0100 Subject: [PATCH] yaaay --- src/.fuse_hidden000083f100000001 | Bin 65536 -> 0 bytes src/goof.py | 16 +++--- .../database/objects/id3_mapping.py | 5 +- src/music_kraken/database/objects/song.py | 54 ++++++++++-------- src/test.db | Bin 65536 -> 69632 bytes 5 files changed, 43 insertions(+), 32 deletions(-) delete mode 100644 src/.fuse_hidden000083f100000001 diff --git a/src/.fuse_hidden000083f100000001 b/src/.fuse_hidden000083f100000001 deleted file mode 100644 index 6a74b7527f6663d009eb4bc6c93db6bdcefba700..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 65536 zcmeI*-*4N-0S9nO^6$i9@{kI~UasgvY$O+v6e*D{y4Goxz>8xqw%9g6G2=)cWi~S9 zl2ld$`+>OYfW2%FeaqYaf&lvi_Pn>f2K!6)wjD`Pvb;H=i#bTTFJY6?kv!gg?sO7) z{IUCRGe|h`2hjmbNK?8hRVvcQgh-O~j`+VS{)=HjyqGE8h-u}->$6_IBi;V|XUpB^twzc1IWB$pmtezBxpy0!GLMY=Sz@W(}IJ`%GrKmY;|fWZH^z|$|~`TBeB zRgQm~FsIMg`_AxSJxYQ&Iq~x9Cp(?>ZijT&?`(F+i5W|)OC%duy53&k1^EFBKJFwR*N{+$WG^OXQ#9ENoP0T*lOUd6|qgNQN%pGN*0=~ zv$S@+a%H~$?z@$5f1PD-cM$gS+)ZA|Q<nkgj zryt}cpJgD&S)L-v!$us_MNHQ1?)KismRSBlXRAwozO(UQedkeHoOvEXc97+@+xeoq zw03iOuKv+VMG8WXe-nS*7e9vf*f1Gn@AvZU?5X+m%G2&rmcDOmS^74QqQH&w@ujKs ze8o~#QeYjW9=5(bxEW{~G)PtB*7 zpWdI(4359f47x1p@gyHFOc~^1rwm55@Kt5x2mMpIJY>m!Dl*Y1@;!>u-r9I*cXE<* zWPR~vS-Bo&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B*y_009U<00OU9AnpGzb4(!X|1WbmAn*V8B>6A0 z_j+K dZ{!975P$##AOHafKmY;|fB*y_0D)w^jfE diff --git a/src/goof.py b/src/goof.py index 2d025bd..56fb076 100644 --- a/src/goof.py +++ b/src/goof.py @@ -10,8 +10,9 @@ from music_kraken import ( import music_kraken.database.new_database as db -def div(msg:str=""): - print("-"*50+msg+"-"*50) + +def div(msg: str = ""): + print("-" * 50 + msg + "-" * 50) cache = music_kraken.database.new_database.Database("test.db") @@ -42,6 +43,7 @@ album_input.artists = [ song_input = Song( title="Vein Deep in the Solution", length=666, + isrc="US-S1Z-99-00001", tracksort=2, target=Target(file="~/Music/genre/artist/album/song.mp3", path="~/Music/genre/artist/album"), lyrics=[ @@ -52,9 +54,9 @@ song_input = Song( Source(src="youtube", url="https://youtu.be/dfnsdajlhkjhsd"), Source(src="musify", url="https://ln.topdf.de/Music-Kraken/") ], - album = album_input, - main_artist_list = [main_artist], - feature_artist_list = [feature_artist] + album=album_input, + main_artist_list=[main_artist], + feature_artist_list=[feature_artist] ) other_song = Song( @@ -82,7 +84,8 @@ div() song_output_list = cache.pull_songs(song_ref=song_ref) print(len(song_output_list), song_output_list, song_output_list[0].album, sep=" | ") print("tracksort", song_output_list[0].tracksort, sep=": ") -print("id3", str(song_output_list[0].metadata)) +print("ID3 stuff") +print(str(song_output_list[0].metadata)) # getting song by album ref div() @@ -103,7 +106,6 @@ print("--artist--") for artist in album_output.artists: print(artist) - # getting album by song div() album_output_list = cache.pull_albums(song_ref=song_ref) diff --git a/src/music_kraken/database/objects/id3_mapping.py b/src/music_kraken/database/objects/id3_mapping.py index 7b2e489..9f651b3 100644 --- a/src/music_kraken/database/objects/id3_mapping.py +++ b/src/music_kraken/database/objects/id3_mapping.py @@ -1,11 +1,13 @@ from enum import Enum class Mapping(Enum): + TITLE = "TIT2" + ISRC = "TSRC" + LENGTH = "TLEN" DATE = "TYER" UNSYNCED_LYRICS = "USLT" TRACKNUMBER = "TRCK" TOTALTRACKS = "TRCK" # Stored in the same frame with TRACKNUMBER, separated by '/': e.g. '4/9'. - TITLE = "TIT2" TITLESORTORDER = "TSOT" ENCODING_SETTINGS = "TSSE" SUBTITLE = "TIT3" @@ -34,7 +36,6 @@ class Mapping(Enum): ARTIST = "TPE1" LANGUAGE = "TLAN" ITUNESCOMPILATION = "TCMP" - ISRC = "TSRC" REMIXED_BY = "TPE4" RADIO_STATION_OWNER = "TRSO" RADIO_STATION = "TRSN" diff --git a/src/music_kraken/database/objects/song.py b/src/music_kraken/database/objects/song.py index c675061..0be2301 100644 --- a/src/music_kraken/database/objects/song.py +++ b/src/music_kraken/database/objects/song.py @@ -65,7 +65,6 @@ class Metadata: return "\n".join(rows) - class Source(DatabaseObject, SongAttribute): """ create somehow like that @@ -170,19 +169,21 @@ class Song(DatabaseObject): """ super().__init__(id_=id_) # attributes - # self.id_: str | None = id_ + # *private* attributes self._title = None - - self.mb_id: str | None = mb_id - self.album_name: str | None = album_name - self.isrc: str | None = isrc - self.length_: int | None = length - self.artist_names = artist_names - self.tracksort: int | None = tracksort + self._isrc = None + self._length = None self.metadata = Metadata() self.title = title + self.isrc = isrc + self.length = length + + self.mb_id: str | None = mb_id + self.album_name: str | None = album_name + self.artist_names = artist_names + self.tracksort: int | None = tracksort if sources is None: sources = [] @@ -240,44 +241,51 @@ class Song(DatabaseObject): the attribute the same as the defined property, but with one underscore infront: title -> _title """ + if value is None: + return attribute_map = { - "_title": ID3_MAPPING.TITLE + "_title": ID3_MAPPING.TITLE, + "_isrc": ID3_MAPPING.ISRC, + "_length": ID3_MAPPING.LENGTH } - # if this crashes/raises an error the function is - # called wrongly. I DO NOT CACH ERRORS DUE TO PERFORMANCE AND DEBUGGING + # if this crashes/raises an error the function is + # called wrongly. I DO NOT CATCH ERRORS DUE TO PERFORMANCE AND DEBUGGING self.__setattr__(name, value) - self.metadata[attribute_map[name].value] = value + # convert value to id3 value if necessary + id3_value = value + if type(value) == int: + id3_value = str(value) + + self.metadata[attribute_map[name].value] = id3_value def get_metadata(self): return self.metadata.get_all_metadata() def has_isrc(self) -> bool: - return self.isrc is not None + return self._isrc is not None def get_artist_names(self) -> List[str]: return self.artist_names def get_length(self): - if self.length_ is None: + if self._length is None: return None - return int(self.length_) - - def set_length(self, length: int): - if type(length) != int: - raise TypeError(f"length of a song must be of the type int not {type(length)}") - self.length_ = length + return int(self._length) def get_album_id(self): if self.album is None: return None return self.album.id - title: str = property(fget=lambda self: self._title, fset=lambda self, value: self.set_simple_metadata("_title", value)) + title: str = property(fget=lambda self: self._title, + fset=lambda self, value: self.set_simple_metadata("_title", value)) + isrc: str = property(fget=lambda self: self._isrc, + fset=lambda self, value: self.set_simple_metadata("_isrc", value)) + length: int = property(fget=get_length, fset=lambda self, value: self.set_simple_metadata("_length", value)) album_id: str = property(fget=get_album_id) - length: int = property(fget=get_length, fset=set_length) """ diff --git a/src/test.db b/src/test.db index c1356e7fdbf8095d4e88ef582cafa995d538af81..8a6e3f7f0088b7bfc54625446ff7a9933021eec0 100644 GIT binary patch delta 2586 zcmd5-&ubi29G~6ErrBV3vh+~2!Axao1Id#&^M1{PViIdmY(lNcU=XCfpKZvRgziSf z%cLR&PrA&_Q;yz3v*5)`4uTg^kb=ci{s6&x^XS_V!9aq~n~&XLn3?x^-|y%1`F_9q z`(yhDV_#fpUk!qw?f!qS=3pK@cQttVoi{H=e*{yFCxfk-dgICC!5fX@;f<*amoHta zeR8)iWY=tJx{U#dajeAd zW?yvUuIZZxy|}x%W#aXXjg4yOhoZZ8YG?Jdw^M%GTpX6;z2?M85Pce5Yn=?+Q$MxJ z-(GBXq~Jy)E&x&{1(?GWaF$A7XoggVIOZrRr)OR&c*Z4@sQ}nu4luP62uw5(B+-gN zXeF{su~l1}+xOzNo$Y%B(o7j)fMCMyVn~6E8VJ%PLnsj_r7-=tb|GJwtJiWXwXsku zKuBf*)`9`46Ah#hiALJW(6~5`XP$p8Uju8&yMS{5-Ad|T)_o3|bTWm}qaZqr9z{=w z?ZuCx^6++}@W?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