Fixed issues with spotify playlist and the queue manager
This commit is contained in:
parent
d4bcc728f4
commit
e8357cf5e1
|
@ -1,3 +1,3 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
__version__ = "1.1.31"
|
__version__ = "1.2.0"
|
||||||
|
|
|
@ -92,7 +92,7 @@ class DownloadJob:
|
||||||
self.dz = dz
|
self.dz = dz
|
||||||
self.sp = sp
|
self.sp = sp
|
||||||
self.interface = interface
|
self.interface = interface
|
||||||
if isinstance(queueItem, QIConvertable):
|
if isinstance(queueItem, QIConvertable) and queueItem.extra:
|
||||||
self.sp.convert_spotify_playlist(self.dz, queueItem, interface=self.interface)
|
self.sp.convert_spotify_playlist(self.dz, queueItem, interface=self.interface)
|
||||||
self.queueItem = queueItem
|
self.queueItem = queueItem
|
||||||
self.settings = queueItem.settings
|
self.settings = queueItem.settings
|
||||||
|
@ -609,7 +609,7 @@ class DownloadJob:
|
||||||
if 'error' in result:
|
if 'error' in result:
|
||||||
self.completeTrackPercentage()
|
self.completeTrackPercentage()
|
||||||
self.queueItem.failed += 1
|
self.queueItem.failed += 1
|
||||||
self.queueItem.errors.append(result['error']['message'])
|
self.queueItem.errors.append(result['error'])
|
||||||
if self.interface:
|
if self.interface:
|
||||||
error = result['error']
|
error = result['error']
|
||||||
self.interface.send("updateQueue", {
|
self.interface.send("updateQueue", {
|
||||||
|
|
|
@ -3,11 +3,12 @@ from deemix.app.downloadjob import DownloadJob
|
||||||
from deemix.utils.misc import getIDFromLink, getTypeFromLink, getBitrateInt
|
from deemix.utils.misc import getIDFromLink, getTypeFromLink, getBitrateInt
|
||||||
from deemix.api.deezer import APIError
|
from deemix.api.deezer import APIError
|
||||||
from spotipy.exceptions import SpotifyException
|
from spotipy.exceptions import SpotifyException
|
||||||
from deemix.app.queueitem import QISingle, QICollection
|
from deemix.app.queueitem import QISingle, QICollection, QIConvertable
|
||||||
import logging
|
import logging
|
||||||
import os.path as path
|
import os.path as path
|
||||||
import json
|
import json
|
||||||
from os import remove
|
from os import remove
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
logger = logging.getLogger('deemix')
|
logger = logging.getLogger('deemix')
|
||||||
|
@ -304,9 +305,7 @@ class QueueManager:
|
||||||
return QueueError(url, "Spotify Features is not setted up correctly.", "spotifyDisabled")
|
return QueueError(url, "Spotify Features is not setted up correctly.", "spotifyDisabled")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
playlist = sp.generate_playlist_queueitem(dz, id, settings)
|
return sp.generate_playlist_queueitem(dz, id, bitrate, settings)
|
||||||
playlist.bitrate = bitrate
|
|
||||||
return playlist
|
|
||||||
except SpotifyException as e:
|
except SpotifyException as e:
|
||||||
return QueueError(url, "Wrong URL: "+e.msg[e.msg.find('\n')+2:])
|
return QueueError(url, "Wrong URL: "+e.msg[e.msg.find('\n')+2:])
|
||||||
|
|
||||||
|
@ -423,7 +422,6 @@ class QueueManager:
|
||||||
queueList[uuid] = self.queueList[uuid].getResettedItem()
|
queueList[uuid] = self.queueList[uuid].getResettedItem()
|
||||||
else:
|
else:
|
||||||
queueList[uuid] = self.queueList[uuid].toDict()
|
queueList[uuid] = self.queueList[uuid].toDict()
|
||||||
print(self.queueList[uuid].progress)
|
|
||||||
return queueList
|
return queueList
|
||||||
|
|
||||||
def slimQueueList(self):
|
def slimQueueList(self):
|
||||||
|
@ -432,14 +430,14 @@ class QueueManager:
|
||||||
queueList[uuid] = self.queueList[uuid].getSlimmedItem()
|
queueList[uuid] = self.queueList[uuid].getSlimmedItem()
|
||||||
return queueList
|
return queueList
|
||||||
|
|
||||||
def loadQueue(self, dz, sp, configFolder, settings, interface=None):
|
def loadQueue(self, configFolder, settings, interface=None):
|
||||||
if path.isfile(path.join(configFolder, 'queue.json')) and not len(self.queue):
|
if path.isfile(path.join(configFolder, 'queue.json')) and not len(self.queue):
|
||||||
if interface:
|
if interface:
|
||||||
interface.send('restoringQueue')
|
interface.send('restoringQueue')
|
||||||
with open(path.join(configFolder, 'queue.json'), 'r') as f:
|
with open(path.join(configFolder, 'queue.json'), 'r') as f:
|
||||||
qd = json.load(f)
|
qd = json.load(f)
|
||||||
remove(path.join(configFolder, 'queue.json'))
|
remove(path.join(configFolder, 'queue.json'))
|
||||||
self.restoreQueue(qd['queue'], qd['queueComplete'], qd['queueList'], settings, dz, sp, interface)
|
self.restoreQueue(qd['queue'], qd['queueComplete'], qd['queueList'], settings)
|
||||||
if interface:
|
if interface:
|
||||||
interface.send('init_downloadQueue', {
|
interface.send('init_downloadQueue', {
|
||||||
'queue': self.queue,
|
'queue': self.queue,
|
||||||
|
@ -447,9 +445,8 @@ class QueueManager:
|
||||||
'queueList': self.slimQueueList(),
|
'queueList': self.slimQueueList(),
|
||||||
'restored': True
|
'restored': True
|
||||||
})
|
})
|
||||||
self.nextItem(dz, sp, interface)
|
|
||||||
|
|
||||||
def restoreQueue(self, queue, queueComplete, queueList, settings, dz, sp, interface=None):
|
def restoreQueue(self, queue, queueComplete, queueList, settings):
|
||||||
self.queue = queue
|
self.queue = queue
|
||||||
self.queueComplete = queueComplete
|
self.queueComplete = queueComplete
|
||||||
self.queueList = {}
|
self.queueList = {}
|
||||||
|
|
|
@ -183,7 +183,7 @@ class SpotifyHelper:
|
||||||
return dz_album
|
return dz_album
|
||||||
|
|
||||||
|
|
||||||
def generate_playlist_queueitem(self, dz, playlist_id, settings):
|
def generate_playlist_queueitem(self, dz, playlist_id, bitrate, settings):
|
||||||
if not self.spotifyEnabled:
|
if not self.spotifyEnabled:
|
||||||
raise spotifyFeaturesNotEnabled
|
raise spotifyFeaturesNotEnabled
|
||||||
spotify_playlist = self.sp.playlist(playlist_id)
|
spotify_playlist = self.sp.playlist(playlist_id)
|
||||||
|
@ -215,7 +215,7 @@ class SpotifyHelper:
|
||||||
extra['playlistAPI'] = playlistAPI
|
extra['playlistAPI'] = playlistAPI
|
||||||
return QIConvertable(
|
return QIConvertable(
|
||||||
playlist_id,
|
playlist_id,
|
||||||
0,
|
bitrate,
|
||||||
spotify_playlist['name'],
|
spotify_playlist['name'],
|
||||||
spotify_playlist['owner']['display_name'],
|
spotify_playlist['owner']['display_name'],
|
||||||
cover,
|
cover,
|
||||||
|
@ -264,7 +264,7 @@ class SpotifyHelper:
|
||||||
collection.append(deezerTrack)
|
collection.append(deezerTrack)
|
||||||
|
|
||||||
convertPercentage = (pos / queueItem.size) * 100
|
convertPercentage = (pos / queueItem.size) * 100
|
||||||
if round(convertPercentage) != lastPercentage and round(convertPercentage) % 2 == 0:
|
if round(convertPercentage) != lastPercentage and round(convertPercentage) % 5 == 0:
|
||||||
lastPercentage = round(convertPercentage)
|
lastPercentage = round(convertPercentage)
|
||||||
if interface:
|
if interface:
|
||||||
interface.send("updateQueue", {'uuid': queueItem.uuid, 'conversion': lastPercentage})
|
interface.send("updateQueue", {'uuid': queueItem.uuid, 'conversion': lastPercentage})
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -7,7 +7,7 @@ README = (HERE / "README.md").read_text()
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="deemix",
|
name="deemix",
|
||||||
version="1.1.31",
|
version="1.2.0",
|
||||||
description="A barebone deezer downloader library",
|
description="A barebone deezer downloader library",
|
||||||
long_description=README,
|
long_description=README,
|
||||||
long_description_content_type="text/markdown",
|
long_description_content_type="text/markdown",
|
||||||
|
|
Loading…
Reference in New Issue