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!
pm_not_allowed = Private message aren't allowed.
-too_long = {song} is too long, removed from playlist!
-download_in_progress = Download of {item} in progress...
+too_long = <b>{song}</b> is too long, removed from playlist!
+download_in_progress = Download of <b>{item}</b> in progress...
removing_item = Removed entry {item} from playlist.
user_ban = You are banned, not allowed to do that!
url_ban = This url is banned!
self.send_client_message(constants.strings('file_missed', file=self.path))
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"
return True
def async_prepare(self):
th = threading.Thread(
- target=self.item().prepare, name="Prepare-" + self.id[:7])
+ target=self.prepare, name="Prepare-" + self.id[:7])
self.log.info(
"%s: start preparing item in thread: " % self.item().type + self.format_debug_string())
th.daemon = True
if self.current_index > index:
self.current_index -= 1
- var.library.free(removed.id)
+ # reference counter
+ counter = 0
+ for wrapper in self:
+ if wrapper.id == removed.id:
+ counter += 1
+
+ if counter == 0:
+ var.library.free(removed.id)
return removed
def remove_by_id(self, id):
def save(self):
var.db.remove_section("playlist_item")
+ assert self.current_index is not None
var.db.set("playlist", "current_index", self.current_index)
for index, music in enumerate(self):
def from_list(self, _list, current_index):
if len(_list) > 0:
- for i in range(current_index):
- _list.pop()
+ if current_index > -1:
+ for i in range(current_index):
+ _list.pop(0)
+ return super().from_list(_list, 0)
return super().from_list(_list, -1)
return self
def next(self):
if len(self) == 0:
+ self.refresh()
return False
self.version += 1
def validate(self):
self.validating_lock.acquire()
if self.ready in ['yes', 'validated']:
+ self.validating_lock.release()
return True
if self.ready == 'failed':
+ self.validating_lock.release()
return False
if os.path.exists(self.path):
+ self.validating_lock.release()
self.ready = "yes"
return True
)
def format_song_string(self, user):
- return constants.strings("url_item",
- title=self.title,
- url=self.url,
- user=user)
+ if self.ready in ['validated', 'yes']:
+ return constants.strings("url_item",
+ title=self.title,
+ url=self.url,
+ user=user)
+ return self.url
def format_current_playing(self, user):
display = constants.strings("now_playing", item=self.format_song_string(user))