mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
Merge fix.
This commit is contained in:
parent
2f46605bf6
commit
0d92adf055
@ -21,6 +21,12 @@ __version__ = "0.0.1"
|
|||||||
log = logging.getLogger("red.audio")
|
log = logging.getLogger("red.audio")
|
||||||
log.setLevel(logging.DEBUG)
|
log.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
|
__author__ = "tekulvw"
|
||||||
|
__version__ = "0.0.1"
|
||||||
|
|
||||||
|
log = logging.getLogger("red.audio")
|
||||||
|
log.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import youtube_dl
|
import youtube_dl
|
||||||
except:
|
except:
|
||||||
@ -184,12 +190,10 @@ class Downloader(threading.Thread):
|
|||||||
video = self._yt.extract_info(self.url, download=False,
|
video = self._yt.extract_info(self.url, download=False,
|
||||||
process=False)
|
process=False)
|
||||||
else:
|
else:
|
||||||
self.url = self.url[9:]
|
|
||||||
yt_id = self._yt.extract_info(self.url,
|
|
||||||
download=False)["entries"][0]["id"] # Should handle errors here.
|
|
||||||
self.url = "https://youtube.com/watch?v={}".format(yt_id)
|
|
||||||
video = self._yt.extract_info(self.url, download=False,
|
video = self._yt.extract_info(self.url, download=False,
|
||||||
process=False)
|
process=False)
|
||||||
|
self.url = "https://youtube.com/watch?v={}".format(
|
||||||
|
video["entries"][0]["id"])
|
||||||
|
|
||||||
self.song = Song(**video)
|
self.song = Song(**video)
|
||||||
|
|
||||||
@ -447,6 +451,14 @@ class Audio:
|
|||||||
|
|
||||||
return song
|
return song
|
||||||
|
|
||||||
|
def _list_local_playlists(self):
|
||||||
|
ret = []
|
||||||
|
for thing in os.listdir(self.local_playlist_path):
|
||||||
|
if os.path.isdir(os.path.join(self.local_playlist_path, thing)):
|
||||||
|
ret.append(thing)
|
||||||
|
log.debug("local playlists:\n\t{}".format(ret))
|
||||||
|
return ret
|
||||||
|
|
||||||
def _is_queue_playlist(self, server):
|
def _is_queue_playlist(self, server):
|
||||||
if server.id not in self.queue:
|
if server.id not in self.queue:
|
||||||
return False
|
return False
|
||||||
@ -475,9 +487,11 @@ class Audio:
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
path = "data/audio/playlists"
|
path = "data/audio/playlists"
|
||||||
old_playlists = [f[:-4] for f in os.listdir(path) if f.endswith(".txt")]
|
old_playlists = [f[:-4] for f in os.listdir(path)
|
||||||
|
if f.endswith(".txt")]
|
||||||
path = os.path.join(path, server)
|
path = os.path.join(path, server)
|
||||||
new_playlists = [f[:-4] for f in os.listdir(path) if f.endswith(".txt")]
|
new_playlists = [f[:-4] for f in os.listdir(path)
|
||||||
|
if f.endswith(".txt")]
|
||||||
return list(set(old_playlists + new_playlists))
|
return list(set(old_playlists + new_playlists))
|
||||||
|
|
||||||
def _list_local_playlists(self):
|
def _list_local_playlists(self):
|
||||||
@ -608,7 +622,7 @@ class Audio:
|
|||||||
assert type(server) is discord.Server
|
assert type(server) is discord.Server
|
||||||
log.debug('starting to play on "{}"'.format(server.name))
|
log.debug('starting to play on "{}"'.format(server.name))
|
||||||
|
|
||||||
if self._valid_playable_url(url) or "[SEARCH:]" in url:
|
if self._valid_playable_url(url):
|
||||||
song = await self._guarantee_downloaded(server, url)
|
song = await self._guarantee_downloaded(server, url)
|
||||||
local = False
|
local = False
|
||||||
else: # Assume local
|
else: # Assume local
|
||||||
@ -1025,6 +1039,12 @@ class Audio:
|
|||||||
author = ctx.message.author
|
author = ctx.message.author
|
||||||
voice_channel = author.voice_channel
|
voice_channel = author.voice_channel
|
||||||
|
|
||||||
|
# Checking if playing in current server
|
||||||
|
|
||||||
|
if self.is_playing(server):
|
||||||
|
await self.bot.say("I'm already playing a song on this server!")
|
||||||
|
return # TODO: Possibly execute queue?
|
||||||
|
|
||||||
# Checking already connected, will join if not
|
# Checking already connected, will join if not
|
||||||
|
|
||||||
caller = inspect.currentframe().f_back.f_code.co_name
|
caller = inspect.currentframe().f_back.f_code.co_name
|
||||||
@ -1046,12 +1066,6 @@ class Audio:
|
|||||||
await self._stop_and_disconnect(server)
|
await self._stop_and_disconnect(server)
|
||||||
await self._join_voice_channel(voice_channel)
|
await self._join_voice_channel(voice_channel)
|
||||||
|
|
||||||
# Checking if playing in current server
|
|
||||||
|
|
||||||
if self.is_playing(server):
|
|
||||||
await self.bot.say("I'm already playing a song on this server!")
|
|
||||||
return # TODO: Possibly execute queue?
|
|
||||||
|
|
||||||
# If not playing, spawn a downloader if it doesn't exist and begin
|
# If not playing, spawn a downloader if it doesn't exist and begin
|
||||||
# downloading the next song
|
# downloading the next song
|
||||||
|
|
||||||
@ -1108,7 +1122,7 @@ class Audio:
|
|||||||
await self.play.callback(self, ctx, url)
|
await self.play.callback(self, ctx, url)
|
||||||
|
|
||||||
@commands.command(name="yt", pass_context=True, no_pm=True)
|
@commands.command(name="yt", pass_context=True, no_pm=True)
|
||||||
async def yt_search(self, ctx, *, search_terms : str):
|
async def yt_search(self, ctx, *, search_terms: str):
|
||||||
"""Searches and plays a video from YouTube"""
|
"""Searches and plays a video from YouTube"""
|
||||||
await self.play.callback(self, ctx, search_terms)
|
await self.play.callback(self, ctx, search_terms)
|
||||||
|
|
||||||
@ -1229,6 +1243,7 @@ class Audio:
|
|||||||
server, name))
|
server, name))
|
||||||
if caller == "playlist_start_mix":
|
if caller == "playlist_start_mix":
|
||||||
shuffle(playlist.playlist)
|
shuffle(playlist.playlist)
|
||||||
|
|
||||||
self._play_playlist(server, playlist)
|
self._play_playlist(server, playlist)
|
||||||
await self.bot.say("Playlist queued.")
|
await self.bot.say("Playlist queued.")
|
||||||
else:
|
else:
|
||||||
@ -1358,8 +1373,9 @@ class Audio:
|
|||||||
song = self.queue[server.id]["NOW_PLAYING"]
|
song = self.queue[server.id]["NOW_PLAYING"]
|
||||||
if song:
|
if song:
|
||||||
msg = ("\n**Title:** {}\n**Author:** {}\n**Uploader:** {}\n"
|
msg = ("\n**Title:** {}\n**Author:** {}\n**Uploader:** {}\n"
|
||||||
"**Views:** {}\n\n<{}>".format(song.title, song.creator,
|
"**Views:** {}\n\n<{}>".format(
|
||||||
song.uploader, song.view_count, song.webpage_url))
|
song.title, song.creator, song.view_count,
|
||||||
|
song.webpage_url))
|
||||||
await self.bot.say(msg.replace("**Author:** None\n", ""))
|
await self.bot.say(msg.replace("**Author:** None\n", ""))
|
||||||
else:
|
else:
|
||||||
await self.bot.say("I don't know what this song is either.")
|
await self.bot.say("I don't know what this song is either.")
|
||||||
@ -1452,8 +1468,8 @@ class Audio:
|
|||||||
ret[setting] = self.settings[setting]
|
ret[setting] = self.settings[setting]
|
||||||
if setting.lower() == "volume" and ret[setting] <= 1:
|
if setting.lower() == "volume" and ret[setting] <= 1:
|
||||||
ret[setting] *= 100
|
ret[setting] *= 100
|
||||||
#^This will make it so that only users with an outdated config will
|
# ^This will make it so that only users with an outdated config will
|
||||||
#have their volume set * 100. In theory.
|
# have their volume set * 100. In theory.
|
||||||
self.save_settings()
|
self.save_settings()
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|||||||
@ -6,6 +6,7 @@ from __main__ import send_cmd_help, settings
|
|||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|
||||||
class Mod:
|
class Mod:
|
||||||
"""Moderation tools."""
|
"""Moderation tools."""
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user