1
0
Fork 0
mirror of https://github.com/myned/modufur.git synced 2024-12-24 14:27:27 +00:00

Temporary fix for gapi errors

This commit is contained in:
Myned 2017-12-31 22:11:37 -05:00
parent 797d68b296
commit ea4457fc73

View file

@ -9,9 +9,9 @@ import discord as d
from discord import errors as err from discord import errors as err
from discord.ext import commands as cmds from discord.ext import commands as cmds
from discord.ext.commands import errors as errext from discord.ext.commands import errors as errext
import gmusicapi as gpm # import gmusicapi as gpm
import googleapiclient as gapic # import googleapiclient as gapic
import apiclient as apic # import apiclient as apic
from misc import exceptions as exc from misc import exceptions as exc
from misc import checks from misc import checks
@ -20,37 +20,37 @@ from utils import utils as u
class Music: class Music:
def __init__(self, bot): # def __init__(self, bot):
self.bot = bot # self.bot = bot
#
self.yt_service = apic.discovery.build('youtube', 'v3', developerKey=u.secrets['client_secrets']['client_secret']) # self.yt_service = apic.discovery.build('youtube', 'v3', developerKey=u.secrets['client_secrets']['client_secret'])
#
@cmds.group(aliases=['pl'], brief='(G) Play music', description='Play music from YouTube, Soundcloud, or Google Play Music') # @cmds.group(aliases=['pl'], brief='(G) Play music', description='Play music from YouTube, Soundcloud, or Google Play Music')
async def play(self, ctx): # async def play(self, ctx):
print(ctx.invoked_subcommand) # print(ctx.invoked_subcommand)
#
@play.command(name='youtube', aliases=['you', 'tube', 'yt', 'y']) # @play.command(name='youtube', aliases=['you', 'tube', 'yt', 'y'])
async def _play_youtube(self, ctx, *videos): # async def _play_youtube(self, ctx, *videos):
try: # try:
if not videos: # if not videos:
raise exc.MissingArgument # raise exc.MissingArgument
#
vids = [] # vids = []
#
for video in videos: # for video in videos:
if 'http' in video and 'youtube' in video: # if 'http' in video and 'youtube' in video:
vids.append(parse.parse_qs(parse.urlparse(video).query)['v'][0]) # vids.append(parse.parse_qs(parse.urlparse(video).query)['v'][0])
else: # else:
vids.append(video) # vids.append(video)
#
print(vids) # print(vids)
#
response = self.yt_service.videos().list(part='snippet', id=','.join(vids)).execute() # response = self.yt_service.videos().list(part='snippet', id=','.join(vids)).execute()
pprint(response) # pprint(response)
#
except exc.MissingArgument: # except exc.MissingArgument:
await ctx.send('**Invalid youtube url or ID**', delete_after=7) # await ctx.send('**Invalid youtube url or ID**', delete_after=7)
await ctx.message.add_reaction('\N{CROSS MARK}') # await ctx.message.add_reaction('\N{CROSS MARK}')
@play.command(name='googleplaymusic', aliases=['googleplay', 'googlemusic', 'playmusic', 'play', 'gpm']) @play.command(name='googleplaymusic', aliases=['googleplay', 'googlemusic', 'playmusic', 'play', 'gpm'])
async def _play_googleplaymusic(self, ctx, query): async def _play_googleplaymusic(self, ctx, query):