|
|
@ -101,12 +101,16 @@ class Commands(object):
|
|
|
|
|
|
|
|
|
|
|
|
def query_youtube(self, query):
|
|
|
|
def query_youtube(self, query):
|
|
|
|
api_key = self.config['Youtube'].get('api_key')
|
|
|
|
api_key = self.config['Youtube'].get('api_key')
|
|
|
|
channel_id = self.config['Youtube'].get('channel_id')
|
|
|
|
channel_ids = self.config['Youtube'].get('channel_ids').split(',')
|
|
|
|
yt = Youtube(api_key)
|
|
|
|
yt = Youtube(api_key)
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
results = yt.search(channel_id, query, playlists=True, limit=1)
|
|
|
|
for channel_id in channel_ids:
|
|
|
|
if not results:
|
|
|
|
results = yt.search(channel_id, query, playlists=True, limit=1)
|
|
|
|
|
|
|
|
if results:
|
|
|
|
|
|
|
|
break
|
|
|
|
results = yt.search(channel_id, query, playlists=False, limit=1)
|
|
|
|
results = yt.search(channel_id, query, playlists=False, limit=1)
|
|
|
|
|
|
|
|
if results:
|
|
|
|
|
|
|
|
break
|
|
|
|
result = results.pop(0)
|
|
|
|
result = results.pop(0)
|
|
|
|
except (YoutubeError, IndexError):
|
|
|
|
except (YoutubeError, IndexError):
|
|
|
|
raise CommandError('couldn\'t find anything on Youtube')
|
|
|
|
raise CommandError('couldn\'t find anything on Youtube')
|
|
|
|