Some rework done on types
This commit is contained in:
parent
b91d2a1af3
commit
0f733ceaaa
|
@ -14,19 +14,19 @@ class Album:
|
|||
self.artist = {"Main": []}
|
||||
self.artists = []
|
||||
self.mainArtist = None
|
||||
self.dateString = None
|
||||
self.barcode = "Unknown"
|
||||
self.date = None
|
||||
self.dateString = None
|
||||
self.trackTotal = "0"
|
||||
self.discTotal = "0"
|
||||
self.embeddedCoverPath = None
|
||||
self.embeddedCoverURL = None
|
||||
self.explicit = False
|
||||
self.genre = []
|
||||
self.barcode = "Unknown"
|
||||
self.label = "Unknown"
|
||||
self.recordType = "album"
|
||||
self.rootArtist = None
|
||||
self.trackTotal = "0"
|
||||
self.bitrate = 0
|
||||
self.rootArtist = None
|
||||
self.variousArtists = None
|
||||
|
||||
def parseAlbum(self, albumAPI):
|
||||
|
@ -42,9 +42,12 @@ class Album:
|
|||
pic_md5 = artistPicture
|
||||
)
|
||||
if albumAPI.get('root_artist'):
|
||||
artistPicture = albumAPI['root_artist']['picture_small']
|
||||
artistPicture = artistPicture[artistPicture.find('artist/') + 7:-24]
|
||||
self.rootArtist = Artist(
|
||||
id = albumAPI['root_artist']['id'],
|
||||
name = albumAPI['root_artist']['name']
|
||||
name = albumAPI['root_artist']['name'],
|
||||
pic_md5 = artistPicture
|
||||
)
|
||||
|
||||
for artist in albumAPI['contributors']:
|
||||
|
@ -82,7 +85,7 @@ class Album:
|
|||
self.discTotal = albumAPI.get('nb_disk')
|
||||
self.copyright = albumAPI.get('copyright')
|
||||
|
||||
if not self.pic.md5:
|
||||
if self.pic.md5 == "":
|
||||
# Getting album cover MD5
|
||||
# ex: https://e-cdns-images.dzcdn.net/images/cover/2e018122cb56986277102d2041a592c8/56x56-000000-80-0-0.jpg
|
||||
self.pic.md5 = albumAPI['cover_small'][albumAPI['cover_small'].find('cover/') + 6:-24]
|
||||
|
@ -106,7 +109,7 @@ class Album:
|
|||
explicitLyricsStatus = albumAPI_gw.get('EXPLICIT_ALBUM_CONTENT', {}).get('EXPLICIT_LYRICS_STATUS', LyricsStatus.UNKNOWN)
|
||||
self.explicit = explicitLyricsStatus in [LyricsStatus.EXPLICIT, LyricsStatus.PARTIALLY_EXPLICIT]
|
||||
|
||||
if not self.pic.md5:
|
||||
if self.pic.md5 == "":
|
||||
self.pic.md5 = albumAPI_gw['ALB_PICTURE']
|
||||
if 'PHYSICAL_RELEASE_DATE' in albumAPI_gw:
|
||||
day = albumAPI_gw["PHYSICAL_RELEASE_DATE"][8:10]
|
||||
|
|
|
@ -2,11 +2,11 @@ from deemix.types.Picture import Picture
|
|||
from deemix import VARIOUS_ARTISTS
|
||||
|
||||
class Artist:
|
||||
def __init__(self, id="0", name="", pic_md5="", role=""):
|
||||
def __init__(self, id="0", name="", role="", pic_md5=""):
|
||||
self.id = str(id)
|
||||
self.name = name
|
||||
self.pic = Picture(md5=pic_md5, type="artist")
|
||||
self.role = ""
|
||||
self.role = role
|
||||
self.save = True
|
||||
|
||||
def isVariousArtists(self):
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class Date(object):
|
||||
def __init__(self, year="XXXX", month="00", day="00"):
|
||||
def __init__(self, day="00", month="00", year="XXXX"):
|
||||
self.year = year
|
||||
self.month = month
|
||||
self.day = day
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
class Lyrics:
|
||||
def __init__(self, id="0"):
|
||||
self.id = id
|
||||
self.sync = None
|
||||
self.unsync = None
|
||||
self.syncID3 = None
|
||||
self.sync = ""
|
||||
self.unsync = ""
|
||||
self.syncID3 = []
|
||||
|
||||
def parseLyrics(self, lyricsAPI):
|
||||
self.unsync = lyricsAPI.get("LYRICS_TEXT")
|
||||
if "LYRICS_SYNC_JSON" in lyricsAPI:
|
||||
syncLyricsJson = lyricsAPI["LYRICS_SYNC_JSON"]
|
||||
self.sync = ""
|
||||
self.syncID3 = []
|
||||
timestamp = ""
|
||||
milliseconds = 0
|
||||
for line in range(len(syncLyricsJson)):
|
||||
|
|
|
@ -1,27 +1,26 @@
|
|||
class Picture:
|
||||
def __init__(self, md5="", type=None, url=None):
|
||||
def __init__(self, md5="", type="", url=None):
|
||||
self.md5 = md5
|
||||
self.type = type
|
||||
self.url = url
|
||||
self.staticUrl = url
|
||||
|
||||
def generatePictureURL(self, size, format):
|
||||
if self.url: return self.url
|
||||
if self.staticUrl: return self.staticUrl
|
||||
|
||||
url = "https://e-cdns-images.dzcdn.net/images/{}/{}/{}x{}".format(
|
||||
self.type,
|
||||
self.md5,
|
||||
size, size
|
||||
)
|
||||
|
||||
if format.startswith("jpg"):
|
||||
if '-' in format:
|
||||
quality = format[4:]
|
||||
else:
|
||||
quality = 80
|
||||
format = 'jpg'
|
||||
return "https://e-cdns-images.dzcdn.net/images/{}/{}/{}x{}-{}".format(
|
||||
self.type,
|
||||
self.md5,
|
||||
size, size,
|
||||
f'000000-{quality}-0-0.jpg'
|
||||
)
|
||||
return url + f'-000000-{quality}-0-0.jpg'
|
||||
if format == 'png':
|
||||
return "https://e-cdns-images.dzcdn.net/images/{}/{}/{}x{}-{}".format(
|
||||
self.type,
|
||||
self.md5,
|
||||
size, size,
|
||||
'none-100-0-0.png'
|
||||
)
|
||||
return url + '-none-100-0-0.png'
|
||||
|
||||
return url+'.jpg'
|
||||
|
|
|
@ -4,17 +4,6 @@ from deemix.types.Picture import Picture
|
|||
|
||||
class Playlist:
|
||||
def __init__(self, playlistAPI):
|
||||
if 'various_artist' in playlistAPI:
|
||||
playlistAPI['various_artist']['role'] = "Main"
|
||||
self.variousArtists = Artist(
|
||||
id = playlistAPI['various_artist']['id'],
|
||||
name = playlistAPI['various_artist']['name'],
|
||||
pic_md5 = playlistAPI['various_artist']['picture_small'][
|
||||
playlistAPI['various_artist']['picture_small'].find('artist/') + 7:-24],
|
||||
role = playlistAPI['various_artist']['role']
|
||||
)
|
||||
self.mainArtist = self.variousArtists
|
||||
|
||||
self.id = "pl_" + str(playlistAPI['id'])
|
||||
self.title = playlistAPI['title']
|
||||
self.rootArtist = None
|
||||
|
@ -30,11 +19,12 @@ class Playlist:
|
|||
year = playlistAPI["creation_date"][0:4]
|
||||
month = playlistAPI["creation_date"][5:7]
|
||||
day = playlistAPI["creation_date"][8:10]
|
||||
self.date = Date(year, month, day)
|
||||
self.date = Date(day, month, year)
|
||||
|
||||
self.discTotal = "1"
|
||||
self.playlistId = playlistAPI['id']
|
||||
self.playlistID = playlistAPI['id']
|
||||
self.owner = playlistAPI['creator']
|
||||
|
||||
if 'dzcdn.net' in playlistAPI['picture_small']:
|
||||
url = playlistAPI['picture_small']
|
||||
picType = url[url.find('images/')+7:]
|
||||
|
@ -46,3 +36,14 @@ class Playlist:
|
|||
)
|
||||
else:
|
||||
self.pic = Picture(url = playlistAPI['picture_xl'])
|
||||
|
||||
if 'various_artist' in playlistAPI:
|
||||
pic_md5 = playlistAPI['various_artist']['picture_small']
|
||||
pic_md5 = pic_md5[pic_md5.indexOf('artist/') + 7:-24]
|
||||
self.variousArtists = Artist(
|
||||
id = playlistAPI['various_artist']['id'],
|
||||
name = playlistAPI['various_artist']['name'],
|
||||
role = "Main",
|
||||
pic_md5 = pic_md5
|
||||
)
|
||||
self.mainArtist = self.variousArtists
|
||||
|
|
Loading…
Reference in New Issue