Support multiple channels in Youtube search

master
Nikola Forró 6 years ago
parent a89ac4375f
commit df4be019eb

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

@ -22,8 +22,8 @@ keywords = #bellameeze,bella,teeny,kitty,cat,😹,😻,🐱,🐈
[Youtube]
api_key = __GOOGLE_API_KEY__
# ladylilia
channel_id = UC5970RJMoEcRNZl0MNp8tlQ
# Lady Lilia, Lilia Live
channel_ids = UC5970RJMoEcRNZl0MNp8tlQ,UCHNjavmkFUf2n0uzWSgj16w
[Quotes]
api_url = https://ladylilia.com/quotes/api

Loading…
Cancel
Save