Fixed some issues to make the lib work
This commit is contained in:
parent
8b7417f8c4
commit
97cd903289
|
@ -154,8 +154,8 @@ class Downloader:
|
||||||
if isinstance(self.downloadObject, Single):
|
if isinstance(self.downloadObject, Single):
|
||||||
track = self.downloadWrapper({
|
track = self.downloadWrapper({
|
||||||
'trackAPI_gw': self.downloadObject.single['trackAPI_gw'],
|
'trackAPI_gw': self.downloadObject.single['trackAPI_gw'],
|
||||||
'trackAPI': self.downloadObject.single['trackAPI'],
|
'trackAPI': self.downloadObject.single.get('trackAPI'),
|
||||||
'albumAPI': self.downloadObject.single['albumAPI']
|
'albumAPI': self.downloadObject.single.get('albumAPI')
|
||||||
})
|
})
|
||||||
if track: self.afterDownloadSingle(track)
|
if track: self.afterDownloadSingle(track)
|
||||||
elif isinstance(self.downloadObject, Collection):
|
elif isinstance(self.downloadObject, Collection):
|
||||||
|
@ -164,8 +164,8 @@ class Downloader:
|
||||||
for pos, track in enumerate(self.downloadObject.collection['tracks_gw'], start=0):
|
for pos, track in enumerate(self.downloadObject.collection['tracks_gw'], start=0):
|
||||||
tracks[pos] = executor.submit(self.downloadWrapper, {
|
tracks[pos] = executor.submit(self.downloadWrapper, {
|
||||||
'trackAPI_gw': track,
|
'trackAPI_gw': track,
|
||||||
'albumAPI': self.downloadObject.collection['albumAPI'],
|
'albumAPI': self.downloadObject.collection.get('albumAPI'),
|
||||||
'playlistAPI': self.downloadObject.collection['playlistAPI']
|
'playlistAPI': self.downloadObject.collection.get('playlistAPI')
|
||||||
})
|
})
|
||||||
self.afterDownloadCollection(tracks)
|
self.afterDownloadCollection(tracks)
|
||||||
|
|
||||||
|
@ -179,9 +179,9 @@ class Downloader:
|
||||||
def download(self, extraData, track=None):
|
def download(self, extraData, track=None):
|
||||||
returnData = {}
|
returnData = {}
|
||||||
trackAPI_gw = extraData['trackAPI_gw']
|
trackAPI_gw = extraData['trackAPI_gw']
|
||||||
trackAPI = extraData['trackAPI']
|
trackAPI = extraData.get('trackAPI')
|
||||||
albumAPI = extraData['albumAPI']
|
albumAPI = extraData.get('albumAPI')
|
||||||
playlistAPI = extraData['playlistAPI']
|
playlistAPI = extraData.get('playlistAPI')
|
||||||
if self.downloadObject.isCanceled: raise DownloadCanceled
|
if self.downloadObject.isCanceled: raise DownloadCanceled
|
||||||
if trackAPI_gw['SNG_ID'] == "0": raise DownloadFailed("notOnDeezer")
|
if trackAPI_gw['SNG_ID'] == "0": raise DownloadFailed("notOnDeezer")
|
||||||
|
|
||||||
|
@ -327,6 +327,8 @@ class Downloader:
|
||||||
try:
|
try:
|
||||||
with open(writepath, 'wb') as stream:
|
with open(writepath, 'wb') as stream:
|
||||||
streamTrack(stream, track, downloadObject=self.downloadObject, listener=self.listener)
|
streamTrack(stream, track, downloadObject=self.downloadObject, listener=self.listener)
|
||||||
|
except requests.exceptions.HTTPError as e:
|
||||||
|
raise DownloadFailed('notAvailable', track) from e
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
if writepath.is_file(): writepath.unlink()
|
if writepath.is_file(): writepath.unlink()
|
||||||
if e.errno == errno.ENOSPC: raise DownloadFailed("noSpaceLeft") from e
|
if e.errno == errno.ENOSPC: raise DownloadFailed("noSpaceLeft") from e
|
||||||
|
@ -386,7 +388,7 @@ class Downloader:
|
||||||
if trackAPI_gw.get('VERSION') and trackAPI_gw['VERSION'] not in trackAPI_gw['SNG_TITLE']:
|
if trackAPI_gw.get('VERSION') and trackAPI_gw['VERSION'] not in trackAPI_gw['SNG_TITLE']:
|
||||||
tempTrack['title'] += f" {trackAPI_gw['VERSION']}".strip()
|
tempTrack['title'] += f" {trackAPI_gw['VERSION']}".strip()
|
||||||
|
|
||||||
itemName = f"[{track.mainArtist.name} - {track.title}]"
|
itemName = f"[{tempTrack['artist']} - {tempTrack['title']}]"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = self.download(extraData, track)
|
result = self.download(extraData, track)
|
||||||
|
|
|
@ -20,7 +20,7 @@ class FeaturesOption():
|
||||||
MOVE_TITLE = "2" # Move to track title
|
MOVE_TITLE = "2" # Move to track title
|
||||||
|
|
||||||
DEFAULTS = {
|
DEFAULTS = {
|
||||||
"downloadLocation": localpaths.getMusicFolder(),
|
"downloadLocation": str(localpaths.getMusicFolder()),
|
||||||
"tracknameTemplate": "%artist% - %title%",
|
"tracknameTemplate": "%artist% - %title%",
|
||||||
"albumTracknameTemplate": "%tracknumber% - %title%",
|
"albumTracknameTemplate": "%tracknumber% - %title%",
|
||||||
"playlistTracknameTemplate": "%position% - %artist% - %title%",
|
"playlistTracknameTemplate": "%position% - %artist% - %title%",
|
||||||
|
@ -122,11 +122,11 @@ def load(configFolder=None):
|
||||||
def check(settings):
|
def check(settings):
|
||||||
changes = 0
|
changes = 0
|
||||||
for i_set in DEFAULTS:
|
for i_set in DEFAULTS:
|
||||||
if not i_set in settings or not isinstance(settings[i_set], DEFAULTS[i_set]):
|
if not i_set in settings or not isinstance(settings[i_set], type(DEFAULTS[i_set])):
|
||||||
settings[i_set] = DEFAULTS[i_set]
|
settings[i_set] = DEFAULTS[i_set]
|
||||||
changes += 1
|
changes += 1
|
||||||
for i_set in DEFAULTS['tags']:
|
for i_set in DEFAULTS['tags']:
|
||||||
if not i_set in settings['tags'] or not isinstance(settings['tags'][i_set], DEFAULTS['tags'][i_set]):
|
if not i_set in settings['tags'] or not isinstance(settings['tags'][i_set], type(DEFAULTS['tags'][i_set])):
|
||||||
settings['tags'][i_set] = DEFAULTS['tags'][i_set]
|
settings['tags'][i_set] = DEFAULTS['tags'][i_set]
|
||||||
changes += 1
|
changes += 1
|
||||||
if settings['downloadLocation'] == "":
|
if settings['downloadLocation'] == "":
|
||||||
|
|
|
@ -8,7 +8,7 @@ class IDownloadObject:
|
||||||
self.artist = obj['artist']
|
self.artist = obj['artist']
|
||||||
self.cover = obj['cover']
|
self.cover = obj['cover']
|
||||||
self.explicit = obj.get('explicit', False)
|
self.explicit = obj.get('explicit', False)
|
||||||
self.size = obj['size']
|
self.size = obj.get('size', 0)
|
||||||
self.downloaded = obj.get('downloaded', 0)
|
self.downloaded = obj.get('downloaded', 0)
|
||||||
self.failed = obj.get('failed', 0)
|
self.failed = obj.get('failed', 0)
|
||||||
self.progress = obj.get('progress', 0)
|
self.progress = obj.get('progress', 0)
|
||||||
|
@ -16,6 +16,7 @@ class IDownloadObject:
|
||||||
self.files = obj.get('files', [])
|
self.files = obj.get('files', [])
|
||||||
self.progressNext = 0
|
self.progressNext = 0
|
||||||
self.uuid = f"{self.type}_{self.id}_{self.bitrate}"
|
self.uuid = f"{self.type}_{self.id}_{self.bitrate}"
|
||||||
|
self.isCanceled = False
|
||||||
self.__type__ = None
|
self.__type__ = None
|
||||||
|
|
||||||
def toDict(self):
|
def toDict(self):
|
||||||
|
|
|
@ -11,7 +11,7 @@ class Lyrics:
|
||||||
syncLyricsJson = lyricsAPI["LYRICS_SYNC_JSON"]
|
syncLyricsJson = lyricsAPI["LYRICS_SYNC_JSON"]
|
||||||
timestamp = ""
|
timestamp = ""
|
||||||
milliseconds = 0
|
milliseconds = 0
|
||||||
for line in enumerate(syncLyricsJson):
|
for line, _ in enumerate(syncLyricsJson):
|
||||||
if syncLyricsJson[line]["line"] != "":
|
if syncLyricsJson[line]["line"] != "":
|
||||||
timestamp = syncLyricsJson[line]["lrc_timestamp"]
|
timestamp = syncLyricsJson[line]["lrc_timestamp"]
|
||||||
milliseconds = int(syncLyricsJson[line]["milliseconds"])
|
milliseconds = int(syncLyricsJson[line]["milliseconds"])
|
||||||
|
|
|
@ -74,7 +74,7 @@ def generatePath(track, downloadObject, settings):
|
||||||
elif downloadObject.type == "album":
|
elif downloadObject.type == "album":
|
||||||
filenameTemplate = settings['albumTracknameTemplate']
|
filenameTemplate = settings['albumTracknameTemplate']
|
||||||
else:
|
else:
|
||||||
filenameTemplate = settings['plyalistTracknameTemplate']
|
filenameTemplate = settings['playlistTracknameTemplate']
|
||||||
|
|
||||||
filename = generateTrackName(filenameTemplate, track, settings)
|
filename = generateTrackName(filenameTemplate, track, settings)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue