fix: still one-shot
This commit is contained in:
parent
f7042db657
commit
091d303729
@ -275,9 +275,8 @@ help = <h3>Commands</h3>
|
||||
<li> <b>!<u>li</u>stfile </b> [{pattern}] - display list of available files (that match the regex pattern if {pattern} is given) </li>
|
||||
<li> <b>!<u>rbq</u>uery </b> {keyword} - query http://www.radio-browser.info for a radio station </li>
|
||||
<li> <b>!<u>rbp</u>lay </b> {id} - play a radio station with {id} (eg. !rbplay 96746) </li>
|
||||
<li> <b>!<u>ys</u>earch </b> {keyword} - query youtube. Use <i>!ytquery -n</i> to turn the page. </li>
|
||||
<li> <b>!<u>yp</u>lay </b> {index/keywords} - play an item from the list returned by <i>!ytquery</i>, or add the
|
||||
first search result of {keywords} into the playlist.</li>
|
||||
<li> <b>!<u>ys</u>earch </b> {keywords} - query youtube. Use <i>!ytquery -n</i> to turn the page. </li>
|
||||
<li> <b>!<u>yp</u>lay </b> {keywords} - add the first search result of {keywords} into the playlist.</li>
|
||||
</ul>
|
||||
<b>Music Library</b>
|
||||
<ul>
|
||||
|
@ -29,8 +29,9 @@ class MusicCache(dict):
|
||||
self.log.debug("library: music found in database: %s" % item.format_debug_string())
|
||||
return item
|
||||
else:
|
||||
print(id)
|
||||
raise KeyError("Unable to fetch item from the database! Please try to refresh the cache by !recache.")
|
||||
return None
|
||||
#print(id)
|
||||
#raise KeyError("Unable to fetch item from the database! Please try to refresh the cache by !recache.")
|
||||
|
||||
|
||||
def get_item(self, bot, **kwargs):
|
||||
@ -80,8 +81,8 @@ class MusicCache(dict):
|
||||
self.db.insert_music(self[id].to_dict())
|
||||
|
||||
def delete(self, id):
|
||||
try:
|
||||
item = self.get_item_by_id(None, id)
|
||||
if item:
|
||||
self.log.debug("library: DELETE item from the database: %s" % item.format_debug_string())
|
||||
|
||||
if item.type == 'file' and item.path in self.file_id_lookup:
|
||||
@ -93,8 +94,6 @@ class MusicCache(dict):
|
||||
if item.id in self:
|
||||
del self[item.id]
|
||||
self.db.delete_music(id=item.id)
|
||||
except KeyError:
|
||||
return
|
||||
|
||||
def free(self, id):
|
||||
if id in self:
|
||||
@ -113,12 +112,14 @@ class MusicCache(dict):
|
||||
files = util.get_recursive_file_list_sorted(var.music_folder)
|
||||
self.dir = util.Dir(var.music_folder)
|
||||
for file in files:
|
||||
item = self.get_item(bot, type='file', path=file)
|
||||
if item.validate():
|
||||
self.dir.add_file(file)
|
||||
self.files.append(file)
|
||||
item = self.fetch(bot, item_id_generators['file'](path=file))
|
||||
if not item:
|
||||
item = item_builders['file'](bot, path=file)
|
||||
self.log.debug("library: music save into database: %s" % item.format_debug_string())
|
||||
self.db.insert_music(item.to_dict())
|
||||
|
||||
self.dir.add_file(file)
|
||||
self.files.append(file)
|
||||
self.file_id_lookup[file] = item.id
|
||||
|
||||
self.save_dir_cache()
|
||||
|
@ -354,9 +354,6 @@ class OneshotPlaylist(BasePlaylist):
|
||||
return self
|
||||
|
||||
def next(self):
|
||||
if len(self) == 0:
|
||||
return False
|
||||
|
||||
self.version += 1
|
||||
|
||||
if len(self) > 0:
|
||||
@ -366,10 +363,10 @@ class OneshotPlaylist(BasePlaylist):
|
||||
return False
|
||||
else:
|
||||
self.current_index = 0
|
||||
return self[0]
|
||||
|
||||
return self[0]
|
||||
else:
|
||||
self.clear()
|
||||
self.current_index = -1
|
||||
return False
|
||||
|
||||
def next_index(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user