updated wait syntax because it was not supported any longer in asyncClient, replaced youtube-dl with yt-dlp in Commands
This commit is contained in:
parent
cc56169ff9
commit
bc5f212265
@ -79,7 +79,7 @@ class AsyncClient():
|
|||||||
|
|
||||||
Data = json.dumps(obj, ensure_ascii = False, separators = (',', ':')).encode("UTF-8")
|
Data = json.dumps(obj, ensure_ascii = False, separators = (',', ':')).encode("UTF-8")
|
||||||
|
|
||||||
with (await self.SendLock):
|
async with self.SendLock:
|
||||||
if not self.Protocol:
|
if not self.Protocol:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ class URLFilter(BaseCommand):
|
|||||||
def __init__(self, torchlight):
|
def __init__(self, torchlight):
|
||||||
super().__init__(torchlight)
|
super().__init__(torchlight)
|
||||||
self.Triggers = [self.re.compile(r'''(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))''', self.re.IGNORECASE)]
|
self.Triggers = [self.re.compile(r'''(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))''', self.re.IGNORECASE)]
|
||||||
self.Level = 10
|
self.Level = -1
|
||||||
self.re_youtube = self.re.compile(r'.*?(?:youtube\.com\/\S*(?:(?:\/e(?:mbed))?\/|watch\?(?:\S*?&?v\=))|youtu\.be\/)([a-zA-Z0-9_-]{6,11}).*?')
|
self.re_youtube = self.re.compile(r'.*?(?:youtube\.com\/\S*(?:(?:\/e(?:mbed))?\/|watch\?(?:\S*?&?v\=))|youtu\.be\/)([a-zA-Z0-9_-]{6,11}).*?')
|
||||||
|
|
||||||
async def URLInfo(self, url, yt = False):
|
async def URLInfo(self, url, yt = False):
|
||||||
@ -65,7 +65,7 @@ class URLFilter(BaseCommand):
|
|||||||
if TimeStr:
|
if TimeStr:
|
||||||
Time = Utils.ParseTime(TimeStr)
|
Time = Utils.ParseTime(TimeStr)
|
||||||
|
|
||||||
Proc = await asyncio.create_subprocess_exec("youtube-dl", "--dump-json", "-g", url,
|
Proc = await asyncio.create_subprocess_exec("yt-dlp", "--dump-json", "-g", url,
|
||||||
stdout = asyncio.subprocess.PIPE)
|
stdout = asyncio.subprocess.PIPE)
|
||||||
Out, _ = await Proc.communicate()
|
Out, _ = await Proc.communicate()
|
||||||
|
|
||||||
@ -79,8 +79,8 @@ class URLFilter(BaseCommand):
|
|||||||
Info = self.json.loads(Info)
|
Info = self.json.loads(Info)
|
||||||
|
|
||||||
if Info["extractor_key"] == "Youtube":
|
if Info["extractor_key"] == "Youtube":
|
||||||
self.Torchlight().SayChat("\x07E52D27[YouTube]\x01 {0} | {1} | {2}/5.00 | {3:,}".format(
|
self.Torchlight().SayChat("\x07E52D27[YouTube]\x01 {0} | {1} | {2:,}".format(
|
||||||
Info["title"], str(self.datetime.timedelta(seconds = Info["duration"])), round(Info["average_rating"], 2), int(Info["view_count"])))
|
Info["title"], str(self.datetime.timedelta(seconds = Info["duration"])), int(Info["view_count"])))
|
||||||
else:
|
else:
|
||||||
match = None
|
match = None
|
||||||
|
|
||||||
@ -331,7 +331,7 @@ class OpenWeather(BaseCommand):
|
|||||||
import geoip2.database
|
import geoip2.database
|
||||||
def __init__(self, torchlight):
|
def __init__(self, torchlight):
|
||||||
super().__init__(torchlight)
|
super().__init__(torchlight)
|
||||||
self.GeoIP = self.geoip2.database.Reader("/usr/share/GeoIP/GeoLite2-City.mmdb")
|
self.GeoIP = self.geoip2.database.Reader("/var/lib/GeoIP/GeoLite2-City.mmdb")
|
||||||
self.Triggers = ["!w", "!vv"]
|
self.Triggers = ["!w", "!vv"]
|
||||||
self.Level = 10
|
self.Level = 10
|
||||||
|
|
||||||
@ -645,7 +645,7 @@ class YouTubeSearch(BaseCommand):
|
|||||||
Time = Utils.ParseTime(TimeStr)
|
Time = Utils.ParseTime(TimeStr)
|
||||||
message[1] = message[1][:Temp.value]
|
message[1] = message[1][:Temp.value]
|
||||||
|
|
||||||
Proc = await asyncio.create_subprocess_exec("youtube-dl", "--dump-json", "-xg", "ytsearch:" + message[1],
|
Proc = await asyncio.create_subprocess_exec("yt-dlp", "--dump-json", "-xg", "ytsearch:" + message[1],
|
||||||
stdout = asyncio.subprocess.PIPE)
|
stdout = asyncio.subprocess.PIPE)
|
||||||
Out, _ = await Proc.communicate()
|
Out, _ = await Proc.communicate()
|
||||||
|
|
||||||
@ -655,8 +655,8 @@ class YouTubeSearch(BaseCommand):
|
|||||||
Info = self.json.loads(Info)
|
Info = self.json.loads(Info)
|
||||||
|
|
||||||
if Info["extractor_key"] == "Youtube":
|
if Info["extractor_key"] == "Youtube":
|
||||||
self.Torchlight().SayChat("\x07E52D27[YouTube]\x01 {0} | {1} | {2}/5.00 | {3:,}".format(
|
self.Torchlight().SayChat("\x07E52D27[YouTube]\x01 {0} | {1} | {2:,}".format(
|
||||||
Info["title"], str(self.datetime.timedelta(seconds = Info["duration"])), round(Info["average_rating"] or 0, 2), int(Info["view_count"])))
|
Info["title"], str(self.datetime.timedelta(seconds = Info["duration"])), int(Info["view_count"])))
|
||||||
AudioClip = self.Torchlight().AudioManager.AudioClip(player, url)
|
AudioClip = self.Torchlight().AudioManager.AudioClip(player, url)
|
||||||
if not AudioClip:
|
if not AudioClip:
|
||||||
return 1
|
return 1
|
||||||
@ -711,13 +711,13 @@ class Say(BaseCommand):
|
|||||||
asyncio.ensure_future(self.Say(player, Language, message[1]))
|
asyncio.ensure_future(self.Say(player, Language, message[1]))
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
'''
|
|
||||||
class DECTalk(BaseCommand):
|
class DECTalk(BaseCommand):
|
||||||
import tempfile
|
import tempfile
|
||||||
def __init__(self, torchlight):
|
def __init__(self, torchlight):
|
||||||
super().__init__(torchlight)
|
super().__init__(torchlight)
|
||||||
self.Triggers = ["!dec"]
|
self.Triggers = ["!dec"]
|
||||||
self.Level = 0
|
self.Level = 2
|
||||||
|
|
||||||
async def Say(self, player, message):
|
async def Say(self, player, message):
|
||||||
message = "[:phoneme on]" + message
|
message = "[:phoneme on]" + message
|
||||||
@ -751,7 +751,7 @@ class DECTalk(BaseCommand):
|
|||||||
|
|
||||||
asyncio.ensure_future(self.Say(player, message[1]))
|
asyncio.ensure_future(self.Say(player, message[1]))
|
||||||
return 0
|
return 0
|
||||||
'''
|
|
||||||
|
|
||||||
class Stop(BaseCommand):
|
class Stop(BaseCommand):
|
||||||
def __init__(self, torchlight):
|
def __init__(self, torchlight):
|
||||||
|
@ -49,7 +49,7 @@ class URLFilter(BaseCommand):
|
|||||||
def __init__(self, torchlight):
|
def __init__(self, torchlight):
|
||||||
super().__init__(torchlight)
|
super().__init__(torchlight)
|
||||||
self.Triggers = [self.re.compile(r'''(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))''', self.re.IGNORECASE)]
|
self.Triggers = [self.re.compile(r'''(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))''', self.re.IGNORECASE)]
|
||||||
self.Level = 10
|
self.Level = -1
|
||||||
self.re_youtube = self.re.compile(r'.*?(?:youtube\.com\/\S*(?:(?:\/e(?:mbed))?\/|watch\?(?:\S*?&?v\=))|youtu\.be\/)([a-zA-Z0-9_-]{6,11}).*?')
|
self.re_youtube = self.re.compile(r'.*?(?:youtube\.com\/\S*(?:(?:\/e(?:mbed))?\/|watch\?(?:\S*?&?v\=))|youtu\.be\/)([a-zA-Z0-9_-]{6,11}).*?')
|
||||||
|
|
||||||
async def URLInfo(self, url, yt = False):
|
async def URLInfo(self, url, yt = False):
|
||||||
@ -65,7 +65,7 @@ class URLFilter(BaseCommand):
|
|||||||
if TimeStr:
|
if TimeStr:
|
||||||
Time = Utils.ParseTime(TimeStr)
|
Time = Utils.ParseTime(TimeStr)
|
||||||
|
|
||||||
Proc = await asyncio.create_subprocess_exec("youtube-dl", "--dump-json", "-g", url,
|
Proc = await asyncio.create_subprocess_exec("yt-dlp", "--dump-json", "-g", url,
|
||||||
stdout = asyncio.subprocess.PIPE)
|
stdout = asyncio.subprocess.PIPE)
|
||||||
Out, _ = await Proc.communicate()
|
Out, _ = await Proc.communicate()
|
||||||
|
|
||||||
@ -79,8 +79,8 @@ class URLFilter(BaseCommand):
|
|||||||
Info = self.json.loads(Info)
|
Info = self.json.loads(Info)
|
||||||
|
|
||||||
if Info["extractor_key"] == "Youtube":
|
if Info["extractor_key"] == "Youtube":
|
||||||
self.Torchlight().SayChat("\x07E52D27[YouTube]\x01 {0} | {1} | {2}/5.00 | {3:,}".format(
|
self.Torchlight().SayChat("\x07E52D27[YouTube]\x01 {0} | {1} | {2:,}".format(
|
||||||
Info["title"], str(self.datetime.timedelta(seconds = Info["duration"])), round(Info["average_rating"], 2), int(Info["view_count"])))
|
Info["title"], str(self.datetime.timedelta(seconds = Info["duration"])), int(Info["view_count"])))
|
||||||
else:
|
else:
|
||||||
match = None
|
match = None
|
||||||
|
|
||||||
@ -129,9 +129,8 @@ class URLFilter(BaseCommand):
|
|||||||
Url = "http://" + Url
|
Url = "http://" + Url
|
||||||
|
|
||||||
if line.startswith("!yt "):
|
if line.startswith("!yt "):
|
||||||
return
|
URL, _ = await self.URLInfo(Url, True)
|
||||||
#URL, _ = await self.URLInfo(Url, True)
|
return "!yt " + URL
|
||||||
#return "!yt " + URL
|
|
||||||
|
|
||||||
if line.startswith("!dec "):
|
if line.startswith("!dec "):
|
||||||
_, text = await self.URLInfo(Url, False)
|
_, text = await self.URLInfo(Url, False)
|
||||||
@ -332,7 +331,7 @@ class OpenWeather(BaseCommand):
|
|||||||
import geoip2.database
|
import geoip2.database
|
||||||
def __init__(self, torchlight):
|
def __init__(self, torchlight):
|
||||||
super().__init__(torchlight)
|
super().__init__(torchlight)
|
||||||
self.GeoIP = self.geoip2.database.Reader("/usr/share/GeoIP/GeoLite2-City.mmdb")
|
self.GeoIP = self.geoip2.database.Reader("/var/lib/GeoIP/GeoLite2-City.mmdb")
|
||||||
self.Triggers = ["!w", "!vv"]
|
self.Triggers = ["!w", "!vv"]
|
||||||
self.Level = 10
|
self.Level = 10
|
||||||
|
|
||||||
@ -632,7 +631,6 @@ class YouTubeSearch(BaseCommand):
|
|||||||
self.Level = 3
|
self.Level = 3
|
||||||
|
|
||||||
async def _func(self, message, player):
|
async def _func(self, message, player):
|
||||||
return -1
|
|
||||||
self.Logger.debug(sys._getframe().f_code.co_name + ' ' + str(message))
|
self.Logger.debug(sys._getframe().f_code.co_name + ' ' + str(message))
|
||||||
|
|
||||||
if self.check_disabled(player):
|
if self.check_disabled(player):
|
||||||
@ -647,7 +645,7 @@ class YouTubeSearch(BaseCommand):
|
|||||||
Time = Utils.ParseTime(TimeStr)
|
Time = Utils.ParseTime(TimeStr)
|
||||||
message[1] = message[1][:Temp.value]
|
message[1] = message[1][:Temp.value]
|
||||||
|
|
||||||
Proc = await asyncio.create_subprocess_exec("youtube-dl", "--dump-json", "-xg", "ytsearch:" + message[1],
|
Proc = await asyncio.create_subprocess_exec("yt-dlp", "--dump-json", "-xg", "ytsearch:" + message[1],
|
||||||
stdout = asyncio.subprocess.PIPE)
|
stdout = asyncio.subprocess.PIPE)
|
||||||
Out, _ = await Proc.communicate()
|
Out, _ = await Proc.communicate()
|
||||||
|
|
||||||
@ -657,8 +655,8 @@ class YouTubeSearch(BaseCommand):
|
|||||||
Info = self.json.loads(Info)
|
Info = self.json.loads(Info)
|
||||||
|
|
||||||
if Info["extractor_key"] == "Youtube":
|
if Info["extractor_key"] == "Youtube":
|
||||||
self.Torchlight().SayChat("\x07E52D27[YouTube]\x01 {0} | {1} | {2}/5.00 | {3:,}".format(
|
self.Torchlight().SayChat("\x07E52D27[YouTube]\x01 {0} | {1} | {2:,}".format(
|
||||||
Info["title"], str(self.datetime.timedelta(seconds = Info["duration"])), round(Info["average_rating"] or 0, 2), int(Info["view_count"])))
|
Info["title"], str(self.datetime.timedelta(seconds = Info["duration"])), int(Info["view_count"])))
|
||||||
AudioClip = self.Torchlight().AudioManager.AudioClip(player, url)
|
AudioClip = self.Torchlight().AudioManager.AudioClip(player, url)
|
||||||
if not AudioClip:
|
if not AudioClip:
|
||||||
return 1
|
return 1
|
||||||
@ -713,13 +711,13 @@ class Say(BaseCommand):
|
|||||||
asyncio.ensure_future(self.Say(player, Language, message[1]))
|
asyncio.ensure_future(self.Say(player, Language, message[1]))
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
'''
|
|
||||||
class DECTalk(BaseCommand):
|
class DECTalk(BaseCommand):
|
||||||
import tempfile
|
import tempfile
|
||||||
def __init__(self, torchlight):
|
def __init__(self, torchlight):
|
||||||
super().__init__(torchlight)
|
super().__init__(torchlight)
|
||||||
self.Triggers = ["!dec"]
|
self.Triggers = ["!dec"]
|
||||||
self.Level = 0
|
self.Level = 2
|
||||||
|
|
||||||
async def Say(self, player, message):
|
async def Say(self, player, message):
|
||||||
message = "[:phoneme on]" + message
|
message = "[:phoneme on]" + message
|
||||||
@ -753,7 +751,7 @@ class DECTalk(BaseCommand):
|
|||||||
|
|
||||||
asyncio.ensure_future(self.Say(player, message[1]))
|
asyncio.ensure_future(self.Say(player, message[1]))
|
||||||
return 0
|
return 0
|
||||||
'''
|
|
||||||
|
|
||||||
class Stop(BaseCommand):
|
class Stop(BaseCommand):
|
||||||
def __init__(self, torchlight):
|
def __init__(self, torchlight):
|
||||||
|
@ -21,3 +21,4 @@ urllib3
|
|||||||
yarl
|
yarl
|
||||||
cython
|
cython
|
||||||
geoip2
|
geoip2
|
||||||
|
yt-dlp @ git+https://github.com/yt-dlp/yt-dlp@master
|
||||||
|
Loading…
Reference in New Issue
Block a user