diff --git a/configuration.default.ini b/configuration.default.ini
index 3697784..ca3d863 100644
--- a/configuration.default.ini
+++ b/configuration.default.ini
@@ -275,9 +275,8 @@ help =
Commands
!listfile [{pattern}] - display list of available files (that match the regex pattern if {pattern} is given)
!rbquery {keyword} - query http://www.radio-browser.info for a radio station
!rbplay {id} - play a radio station with {id} (eg. !rbplay 96746)
- !ysearch {keyword} - query youtube. Use !ytquery -n to turn the page.
- !yplay {index/keywords} - play an item from the list returned by !ytquery, or add the
- first search result of {keywords} into the playlist.
+ !ysearch {keywords} - query youtube. Use !ytquery -n to turn the page.
+ !yplay {keywords} - add the first search result of {keywords} into the playlist.
Music Library
diff --git a/media/cache.py b/media/cache.py
index 956293a..6c2d349 100644
--- a/media/cache.py
+++ b/media/cache.py
@@ -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)
+ 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,13 +112,15 @@ 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.file_id_lookup[file] = item.id
+
+ self.dir.add_file(file)
+ self.files.append(file)
+ self.file_id_lookup[file] = item.id
self.save_dir_cache()
self.dir_lock.release()
diff --git a/media/playlist.py b/media/playlist.py
index aa79307..77f8a9c 100644
--- a/media/playlist.py
+++ b/media/playlist.py
@@ -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):