mirror of
https://github.com/myned/modufur.git
synced 2024-11-01 21:02:38 +00:00
WIP music cog
This commit is contained in:
parent
23c49f480a
commit
4c58a9e1a7
5 changed files with 70 additions and 4 deletions
57
src/cogs/music.py
Normal file
57
src/cogs/music.py
Normal file
|
@ -0,0 +1,57 @@
|
|||
import asyncio
|
||||
import json
|
||||
from datetime import datetime as dt
|
||||
from urllib import parse
|
||||
import re
|
||||
from pprint import pprint
|
||||
|
||||
import discord as d
|
||||
from discord import errors as err
|
||||
from discord.ext import commands as cmds
|
||||
from discord.ext.commands import errors as errext
|
||||
import gmusicapi as gpm
|
||||
import googleapiclient as gapic
|
||||
import apiclient as apic
|
||||
|
||||
from misc import exceptions as exc
|
||||
from misc import checks
|
||||
from utils import utils as u
|
||||
|
||||
|
||||
class Music:
|
||||
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
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')
|
||||
async def play(self, ctx):
|
||||
print(ctx.invoked_subcommand)
|
||||
|
||||
@play.command(name='youtube', aliases=['you', 'tube', 'yt', 'y'])
|
||||
async def _play_youtube(self, ctx, *videos):
|
||||
try:
|
||||
if not videos:
|
||||
raise exc.MissingArgument
|
||||
|
||||
vids = []
|
||||
|
||||
for video in videos:
|
||||
if 'http' in video and 'youtube' in video:
|
||||
vids.append(parse.parse_qs(parse.urlparse(video).query)['v'][0])
|
||||
else:
|
||||
vids.append(video)
|
||||
|
||||
print(vids)
|
||||
|
||||
response = self.yt_service.videos().list(part='snippet', id=','.join(vids)).execute()
|
||||
pprint(response)
|
||||
|
||||
except exc.MissingArgument:
|
||||
await ctx.send('**Invalid youtube url or ID**', delete_after=7)
|
||||
await ctx.message.add_reaction('\N{CROSS MARK}')
|
||||
|
||||
@play.command(name='googleplaymusic', aliases=['googleplay', 'googlemusic', 'playmusic', 'play', 'gpm'])
|
||||
async def _play_googleplaymusic(self, ctx, query):
|
||||
pass
|
|
@ -23,3 +23,11 @@ class Post:
|
|||
|
||||
async def _check_posts(self, user, channel):
|
||||
pass
|
||||
|
||||
@cmds.group(aliases=['update', 'up', 'u'])
|
||||
async def updates(self, ctx):
|
||||
pass
|
||||
|
||||
@updates.command(name='googleplaymusic', aliases=['googlemusic', 'playmusic', 'music', 'gpm'])
|
||||
async def _updates_googleplaymusic(self, ctx):
|
||||
pass
|
||||
|
|
|
@ -70,9 +70,11 @@ async def test(ctx):
|
|||
@bot.event
|
||||
async def on_ready():
|
||||
if not checks.ready:
|
||||
from cogs import booru, info, management, owner, tools
|
||||
# d.opus.load_opus('opuslib')
|
||||
|
||||
for cog in (tools.Utils(bot), owner.Bot(bot), owner.Tools(bot), management.Administration(bot), info.Info(bot), booru.MsG(bot)):
|
||||
from cogs import booru, info, management, music, owner, tools
|
||||
|
||||
for cog in (tools.Utils(bot), owner.Bot(bot), owner.Tools(bot), management.Administration(bot), music.Music(bot), info.Info(bot), booru.MsG(bot)):
|
||||
bot.add_cog(cog)
|
||||
print(f'COG : {type(cog).__name__}')
|
||||
|
||||
|
@ -183,8 +185,6 @@ async def on_guild_remove(guild):
|
|||
print(f'STOPPED : {task} in #{channel.id}')
|
||||
u.dump(u.tasks, 'cogs/tasks.pkl')
|
||||
|
||||
# d.opus.load_opus('opus')
|
||||
|
||||
|
||||
async def wait(voice):
|
||||
asyncio.sleep(5)
|
||||
|
|
0
src/temp/__init__.py
Normal file
0
src/temp/__init__.py
Normal file
|
@ -85,6 +85,7 @@ def dump(obj, filename, *, json=False):
|
|||
settings = setdefault('misc/settings.pkl', {'del_ctx': [], 'prefixes': {}})
|
||||
tasks = setdefault('cogs/tasks.pkl', {'auto_del': [], 'auto_rev': [], 'periodic_gpm': []})
|
||||
temp = setdefault('temp/temp.pkl', {'startup': ()})
|
||||
secrets = setdefault('secrets.json', {'client_secrets': {'client_id': '', 'client_secret': ''}}, json=True)
|
||||
|
||||
RATE_LIMIT = 2.2
|
||||
color = d.Color(0x1A1A1A)
|
||||
|
|
Loading…
Reference in a new issue