fix: music not saved after downloading. some tricky oneshot problem #91
This commit is contained in:
parent
e10059a76e
commit
487b5b9616
@ -201,8 +201,8 @@ url_from_playlist_item = <a href="{url}"><b>{title}</b></a> <i>from playlist</i>
|
|||||||
url_item = <a href="{url}"><b>{title}</b></a> <i>added by</i> {user}
|
url_item = <a href="{url}"><b>{title}</b></a> <i>added by</i> {user}
|
||||||
not_in_my_channel = You're not in my channel, command refused!
|
not_in_my_channel = You're not in my channel, command refused!
|
||||||
pm_not_allowed = Private message aren't allowed.
|
pm_not_allowed = Private message aren't allowed.
|
||||||
too_long = {song} is too long, removed from playlist!
|
too_long = <b>{song}</b> is too long, removed from playlist!
|
||||||
download_in_progress = Download of {item} in progress...
|
download_in_progress = Download of <b>{item}</b> in progress...
|
||||||
removing_item = Removed entry {item} from playlist.
|
removing_item = Removed entry {item} from playlist.
|
||||||
user_ban = You are banned, not allowed to do that!
|
user_ban = You are banned, not allowed to do that!
|
||||||
url_ban = This url is banned!
|
url_ban = This url is banned!
|
||||||
|
@ -74,7 +74,7 @@ class FileItem(BaseItem):
|
|||||||
self.send_client_message(constants.strings('file_missed', file=self.path))
|
self.send_client_message(constants.strings('file_missed', file=self.path))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self.version += 1 # 0 -> 1, notify the wrapper to save me when validate() is visited the first time
|
#self.version += 1 # 0 -> 1, notify the wrapper to save me when validate() is visited the first time
|
||||||
self.ready = "yes"
|
self.ready = "yes"
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ class PlaylistItemWrapper:
|
|||||||
|
|
||||||
def async_prepare(self):
|
def async_prepare(self):
|
||||||
th = threading.Thread(
|
th = threading.Thread(
|
||||||
target=self.item().prepare, name="Prepare-" + self.id[:7])
|
target=self.prepare, name="Prepare-" + self.id[:7])
|
||||||
self.log.info(
|
self.log.info(
|
||||||
"%s: start preparing item in thread: " % self.item().type + self.format_debug_string())
|
"%s: start preparing item in thread: " % self.item().type + self.format_debug_string())
|
||||||
th.daemon = True
|
th.daemon = True
|
||||||
@ -222,6 +222,13 @@ class BasePlaylist(list):
|
|||||||
if self.current_index > index:
|
if self.current_index > index:
|
||||||
self.current_index -= 1
|
self.current_index -= 1
|
||||||
|
|
||||||
|
# reference counter
|
||||||
|
counter = 0
|
||||||
|
for wrapper in self:
|
||||||
|
if wrapper.id == removed.id:
|
||||||
|
counter += 1
|
||||||
|
|
||||||
|
if counter == 0:
|
||||||
var.library.free(removed.id)
|
var.library.free(removed.id)
|
||||||
return removed
|
return removed
|
||||||
|
|
||||||
@ -272,6 +279,7 @@ class BasePlaylist(list):
|
|||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
var.db.remove_section("playlist_item")
|
var.db.remove_section("playlist_item")
|
||||||
|
assert self.current_index is not None
|
||||||
var.db.set("playlist", "current_index", self.current_index)
|
var.db.set("playlist", "current_index", self.current_index)
|
||||||
|
|
||||||
for index, music in enumerate(self):
|
for index, music in enumerate(self):
|
||||||
@ -331,8 +339,10 @@ class OneshotPlaylist(BasePlaylist):
|
|||||||
|
|
||||||
def from_list(self, _list, current_index):
|
def from_list(self, _list, current_index):
|
||||||
if len(_list) > 0:
|
if len(_list) > 0:
|
||||||
|
if current_index > -1:
|
||||||
for i in range(current_index):
|
for i in range(current_index):
|
||||||
_list.pop()
|
_list.pop(0)
|
||||||
|
return super().from_list(_list, 0)
|
||||||
return super().from_list(_list, -1)
|
return super().from_list(_list, -1)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
@ -450,6 +460,7 @@ class AutoPlaylist(BasePlaylist):
|
|||||||
|
|
||||||
def next(self):
|
def next(self):
|
||||||
if len(self) == 0:
|
if len(self) == 0:
|
||||||
|
self.refresh()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self.version += 1
|
self.version += 1
|
||||||
|
@ -70,12 +70,15 @@ class URLItem(BaseItem):
|
|||||||
def validate(self):
|
def validate(self):
|
||||||
self.validating_lock.acquire()
|
self.validating_lock.acquire()
|
||||||
if self.ready in ['yes', 'validated']:
|
if self.ready in ['yes', 'validated']:
|
||||||
|
self.validating_lock.release()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if self.ready == 'failed':
|
if self.ready == 'failed':
|
||||||
|
self.validating_lock.release()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if os.path.exists(self.path):
|
if os.path.exists(self.path):
|
||||||
|
self.validating_lock.release()
|
||||||
self.ready = "yes"
|
self.ready = "yes"
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -219,10 +222,12 @@ class URLItem(BaseItem):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def format_song_string(self, user):
|
def format_song_string(self, user):
|
||||||
|
if self.ready in ['validated', 'yes']:
|
||||||
return constants.strings("url_item",
|
return constants.strings("url_item",
|
||||||
title=self.title,
|
title=self.title,
|
||||||
url=self.url,
|
url=self.url,
|
||||||
user=user)
|
user=user)
|
||||||
|
return self.url
|
||||||
|
|
||||||
def format_current_playing(self, user):
|
def format_current_playing(self, user):
|
||||||
display = constants.strings("now_playing", item=self.format_song_string(user))
|
display = constants.strings("now_playing", item=self.format_song_string(user))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user