From c925bf936001cf8ccaca6eb2b77f250104bf2e09 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Thu, 21 Nov 2019 19:58:48 +0100 Subject: [PATCH] yes yes yes --- royalnet/backpack/events/play.py | 1 + royalnet/bard/ytdlfile.py | 17 ++++++++++++++--- royalnet/bard/ytdlinfo.py | 7 +++++++ .../packs/__pycache__/__init__.cpython-37.pyc | Bin 193 -> 0 bytes .../common/__pycache__/__init__.cpython-37.pyc | Bin 448 -> 0 bytes .../__pycache__/__init__.cpython-37.pyc | Bin 418 -> 0 bytes .../commands/__pycache__/ping.cpython-37.pyc | Bin 670 -> 0 bytes .../__pycache__/version.cpython-37.pyc | Bin 814 -> 0 bytes .../stars/__pycache__/__init__.cpython-37.pyc | Bin 428 -> 0 bytes .../api_royalnet_version.cpython-37.pyc | Bin 745 -> 0 bytes .../tables/__pycache__/__init__.cpython-37.pyc | Bin 444 -> 0 bytes .../tables/__pycache__/discord.cpython-37.pyc | Bin 1894 -> 0 bytes .../tables/__pycache__/telegram.cpython-37.pyc | Bin 1955 -> 0 bytes .../tables/__pycache__/users.cpython-37.pyc | Bin 1604 -> 0 bytes .../__pycache__/__init__.cpython-37.pyc | Bin 440 -> 0 bytes .../__pycache__/__init__.cpython-37.pyc | Bin 410 -> 0 bytes .../commands/__pycache__/ping.cpython-37.pyc | Bin 662 -> 0 bytes .../__pycache__/version.cpython-37.pyc | Bin 806 -> 0 bytes .../stars/__pycache__/__init__.cpython-37.pyc | Bin 420 -> 0 bytes .../api_royalnet_version.cpython-37.pyc | Bin 737 -> 0 bytes .../tables/__pycache__/__init__.cpython-37.pyc | Bin 436 -> 0 bytes .../tables/__pycache__/discord.cpython-37.pyc | Bin 1886 -> 0 bytes .../tables/__pycache__/telegram.cpython-37.pyc | Bin 1947 -> 0 bytes .../tables/__pycache__/users.cpython-37.pyc | Bin 1596 -> 0 bytes .../serf/discord/discordbard/discordbard.py | 2 +- .../serf/discord/discordbard/ytdldiscord.py | 8 ++++++++ royalnet/utils/multilock.py | 17 +++++++++++++++++ 27 files changed, 48 insertions(+), 4 deletions(-) delete mode 100644 royalnet/packs/__pycache__/__init__.cpython-37.pyc delete mode 100644 royalnet/packs/common/__pycache__/__init__.cpython-37.pyc delete mode 100644 royalnet/packs/common/commands/__pycache__/__init__.cpython-37.pyc delete mode 100644 royalnet/packs/common/commands/__pycache__/ping.cpython-37.pyc delete mode 100644 royalnet/packs/common/commands/__pycache__/version.cpython-37.pyc delete mode 100644 royalnet/packs/common/stars/__pycache__/__init__.cpython-37.pyc delete mode 100644 royalnet/packs/common/stars/__pycache__/api_royalnet_version.cpython-37.pyc delete mode 100644 royalnet/packs/common/tables/__pycache__/__init__.cpython-37.pyc delete mode 100644 royalnet/packs/common/tables/__pycache__/discord.cpython-37.pyc delete mode 100644 royalnet/packs/common/tables/__pycache__/telegram.cpython-37.pyc delete mode 100644 royalnet/packs/common/tables/__pycache__/users.cpython-37.pyc delete mode 100644 royalnet/packs/default/__pycache__/__init__.cpython-37.pyc delete mode 100644 royalnet/packs/default/commands/__pycache__/__init__.cpython-37.pyc delete mode 100644 royalnet/packs/default/commands/__pycache__/ping.cpython-37.pyc delete mode 100644 royalnet/packs/default/commands/__pycache__/version.cpython-37.pyc delete mode 100644 royalnet/packs/default/stars/__pycache__/__init__.cpython-37.pyc delete mode 100644 royalnet/packs/default/stars/__pycache__/api_royalnet_version.cpython-37.pyc delete mode 100644 royalnet/packs/default/tables/__pycache__/__init__.cpython-37.pyc delete mode 100644 royalnet/packs/default/tables/__pycache__/discord.cpython-37.pyc delete mode 100644 royalnet/packs/default/tables/__pycache__/telegram.cpython-37.pyc delete mode 100644 royalnet/packs/default/tables/__pycache__/users.cpython-37.pyc diff --git a/royalnet/backpack/events/play.py b/royalnet/backpack/events/play.py index 6d3eddb4..bc77bae6 100644 --- a/royalnet/backpack/events/play.py +++ b/royalnet/backpack/events/play.py @@ -34,6 +34,7 @@ class PlayEvent(Event): break if guild is None: raise InvalidInputError("No guild_id or guild_name specified.") + log.debug(f"Selected guild: {guild}") # Find the bard bard: Optional[DiscordBard] = self.serf.bards.get(guild) if bard is None: diff --git a/royalnet/bard/ytdlfile.py b/royalnet/bard/ytdlfile.py index 9b63872c..c59feab5 100644 --- a/royalnet/bard/ytdlfile.py +++ b/royalnet/bard/ytdlfile.py @@ -1,4 +1,5 @@ import os +import logging from contextlib import asynccontextmanager from typing import Optional, List, Dict, Any from royalnet.utils import asyncify, MultiLock @@ -12,6 +13,9 @@ except ImportError: youtube_dl = None +log = logging.getLogger(__name__) + + class YtdlFile: """A representation of a file download with :mod:`youtube_dl`.""" @@ -71,11 +75,13 @@ class YtdlFile: """Download function block to be asyncified.""" with YoutubeDL(self.ytdl_args) as ytdl: filename = ytdl.prepare_filename(self.info.__dict__) + with YoutubeDL({**self.ytdl_args, "outtmpl": filename}) as ytdl: ytdl.download([self.info.webpage_url]) self.filename = filename await self.retrieve_info() async with self.lock.exclusive(): + log.debug(f"Downloading with youtube-dl: {self}") await asyncify(download, loop=self._loop) @asynccontextmanager @@ -91,14 +97,19 @@ class YtdlFile: """ await self.download_file() async with self.lock.normal(): + log.debug(f"File opened: {self.filename}") with open(self.filename, "rb") as file: yield file + log.debug(f"File closed: {self.filename}") async def delete_asap(self): """As soon as nothing is using the file, delete it.""" - async with self.lock.exclusive(): - os.remove(self.filename) - self.filename = None + log.debug(f"Trying to delete: {self.filename}") + if self.filename is not None: + async with self.lock.exclusive(): + os.remove(self.filename) + log.debug(f"Deleted: {self.filename}") + self.filename = None @classmethod async def from_url(cls, url: str, **ytdl_args) -> List["YtdlFile"]: diff --git a/royalnet/bard/ytdlinfo.py b/royalnet/bard/ytdlinfo.py index c954e48c..f4b38254 100644 --- a/royalnet/bard/ytdlinfo.py +++ b/royalnet/bard/ytdlinfo.py @@ -2,6 +2,7 @@ from asyncio import AbstractEventLoop, get_event_loop from typing import Optional, Dict, List, Any from datetime import datetime, timedelta import dateparser +import logging from royalnet.utils import ytdldateformat, asyncify try: @@ -10,6 +11,9 @@ except ImportError: YoutubeDL = None +log = logging.getLogger(__name__) + + class YtdlInfo: """A wrapper around youtube_dl extracted info.""" @@ -95,6 +99,7 @@ class YtdlInfo: if loop is None: loop: AbstractEventLoop = get_event_loop() # So many redundant options! + log.debug(f"Fetching info: {url}") with YoutubeDL({**cls._default_ytdl_args, **ytdl_args}) as ytdl: first_info = await asyncify(ytdl.extract_info, loop=loop, url=url, download=False) # No video was found @@ -102,12 +107,14 @@ class YtdlInfo: return [] # If it is a playlist, create multiple videos! if "entries" in first_info and first_info["entries"][0] is not None: + log.debug(f"Found a playlist: {url}") second_info_list = [] for second_info in first_info["entries"]: if second_info is None: continue second_info_list.append(YtdlInfo(second_info)) return second_info_list + log.debug(f"Found a single video: {url}") return [YtdlInfo(first_info)] def __repr__(self): diff --git a/royalnet/packs/__pycache__/__init__.cpython-37.pyc b/royalnet/packs/__pycache__/__init__.cpython-37.pyc deleted file mode 100644 index 25559b9d815a8deaf8fbdee47ff2a2f166a05e7d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 193 zcmZ?b<>g`kf?T&6Q*Yy%aWAC32Ul4%rl$@-L!Bsr&E^v-UD7h?$=U{BFsU(ULeXcRNFFjF7~d16PCeb1?Gm*^#uG83<$j d(0j%%#zUyK+K3k=FVhcQ6VbqR^bJOE_CJvIZjAr{ diff --git a/royalnet/packs/common/commands/__pycache__/__init__.cpython-37.pyc b/royalnet/packs/common/commands/__pycache__/__init__.cpython-37.pyc deleted file mode 100644 index a875b094f3abf4af706e07a960d6f700e085dc5f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 418 zcmYLE%}N7749?6>x3#u{eT%(x#hXxySiOo+@UT#Zu`{i!^Rw=(g+e{q7w|EB3m-%F z>d9B=$w^yjAjy}IeED+K?Y1G<_vzQwL6-IHM(3gIGuU9zyV4V# ztecD7PbEH3_ryZvT0CgQ_u72j3>=ND0=lqpPU3SUcMAwnW0G*P5La}rvuZr8@*Zui)|D;&|0J_Rk} zQBv?L_!rw!(IL@MF>~19k>;^Gd*96W-IK{=NWeb$uP=T<{*H&82`CBiT3nM^@&jIw8IANofz{6bAv}Z|LvpG~&YlBO&W$jMW(&Z{dtEIS z#Pm(76Wx2ybzi5qA|L1k&rj?PUpRnywp)zq5+Ihc7I zX%h;+uA8;9mopxP@~aSqR*i~1Z<^NIf^T=kjQ$Ng96@-)KEZ;Y=~JM5K`2C6fnBz! z)6b80@1|EU>^^W!ys66#!Ut0>eINQhh46*=F{Ixo*-KZMEHq}hblIuXCi8BiN^6?` zMXicgAuE8Ivt0s)Aw!1qdK0;C?EtU>gFxub!JZCt=*@;Pl@gVZG7hDzoNi03$5Os- zVN}=g349!RXnZ`7Qd#R7h0+8meGglst+Xd7)9!EvYWaK6?%3>w3ErV(_;&*W4C$DS nS$79==Z8C*bL54DVt+fKd$WgyLU{y?>EiG5k0_!d-<1CWbX}?A diff --git a/royalnet/packs/common/commands/__pycache__/version.cpython-37.pyc b/royalnet/packs/common/commands/__pycache__/version.cpython-37.pyc deleted file mode 100644 index b59c80cd59f04c0ecf0ac5e9ddae7f912987d9d5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 814 zcmY+Dzi-qq6vyq@`El1PZJ8O4tzoz@0hLaO{*VgG4g4A+AuEdCwWsFCVJAp;x=!5A z#=;N5$iNOW|Aj}GnAn+k&gI(T$S=>&_WSyMoE&U!b_uqR>g$WQl#pL`ux=ck2iWy4 z8c8J0$W!}vGMYQFL&-6bO!6g>9N23XbLl=Iq4yhClaLyE3r(OQPl{@irZ&267n$#2 z1V~IJiJfPt5HsN5N@s|fW3Tb~kbnF%bV-;Xbb?k(ngVxCjd?9KJ z$A6Ea(=vxhS1=xz(P1eeQf;Z1&NNBSbd(~hvS?mNOh;=H)0ttaF6`H!tq`F-8sIa( z{y*aZE(*IQ5W*rB!gPhmOIc^u?+Nj;M#9aE@-T~Gx>9CKh@>dWDzTWg5X!ex8|}62 zTjcA(5t3IsINels#aM94UV)2U+uU8+b9zn_8-;GXvo3jHYqZ6g?Tb)b=8CJ|3O8G? XNLZH2>X=}-s_8!d6GU6pfcDrwoxIhN diff --git a/royalnet/packs/common/stars/__pycache__/__init__.cpython-37.pyc b/royalnet/packs/common/stars/__pycache__/__init__.cpython-37.pyc deleted file mode 100644 index a24087a143769cbcce2068f2c2891f205a5f16f3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 428 zcmYL^%}T>S5P)YlNn45qks|mA0cm`IQndB#!GecC8P;SQS2x+X8;gZ{(iiX`K7+5} zBY4c!ldsT|yZs>p^RqLv-^`4Ay)IbEe!gd)1mM>__Tt&#+^RXXCWVwp$Vp5HaFUUj zW)OQRO}#hZlzSia5?)E{r~VYe;LoxkB=zw{DX!I$$%0omTpOW^X~lHn%1)?NH)dkh z99fgW3TE9GvLg5JP9H7o%W*o01TkYk_WCcNGS4pOpglP+V+} z(XOfPvjr29-Aaxn%Q$Y>^+}WE&j~Lpd;G4{Mr2YVHWzH8mZNosxk{fTA33&hse_>9 G`@ugUqHnSQ diff --git a/royalnet/packs/common/stars/__pycache__/api_royalnet_version.cpython-37.pyc b/royalnet/packs/common/stars/__pycache__/api_royalnet_version.cpython-37.pyc deleted file mode 100644 index fbbcfd65f9142b7f07f5009000d0357fac3444a1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 745 zcmZuvy>1jS5VpO)ggcPJPeVhy6t^!Bp%98lDHe2xC@djsSO4_936?g$& z1D=7#Efudo#mw!kxPn>DH#0ldH$V2te15=CPJe!X_k}a|i-Ji)bdFK&5rSr#H%yWh z4R3`Mocy2(-jEHOu#IHI*(uYJj>cA-V}WT6`5c(BW-}>=ClZ{_%^UUiMdI(}8;n#@2mD zoY#-?a;S5&%jBQNR3?04#x{Ixz->%d2`ofHmgfF}Y9AsvoLdXWFT_Pq^P1n#JVD`; z9hpxpv}Nb&DhvJWZ1t*Gf*tzKf={QyCPgB12LVfm7Mit*G5E&J9L=91Kkr+}t%LQt z&tLW${!j8OnE4_f3n2f z#aJFv`wch;i`_NYEvbC4pBR^D3$}+KA0(M;N6sb~K!38)5x8N8kTUK15 zD?BNvW6ksP@68)u4F)~%@pbw+za#+PxcHC2lM9~?L4Y6%G${x{P8HQb5p+CIp^l1( zfFv@I(K0Av5sK&yWITmeQY0dtL6-b@eaJ`~-a2XhoZd(!mzHbKlWFBjV?~K~FsM(g zKk@0#JS<@g^WF>Dk_ULFPvHzcP%LGv=2|kA(UuO++o<7pO4`W3=wLU=?~RtZYvf{K z@`({Lw`RjtEt>;b@$%8-rP12dd8goV#;Uq%7#prOyWU7uuJPxq@i7`gcQIJ}y6Y@$ zqqXnIS=?>Y=C3P@_S;148?zy}73976uZ zN&DEKJcWPt3kXg)&55Kjl~!y?JGP}0JJO9^iZ(0nNiX({Zs)%2$9>Qp?&g6U!~;rx zB)rGHYr?&?6^Gn^PKN!D@Ln=>b?>~)m$J~_Pem9FmB?nr z&tf&CI#eQ0>Z~lPdA5Lg#6_AXN^q9cwfac$#Z)`LRYIkR(mq?C7O)~nOgV`yPGeg* z+~W2%S<~1B9he)v2fE=6>mKMn@0)cW^neeH-UmJ8klbY7RZB5q}oV6yG{Ux|ljg}c7+RB10 z3f)mX5a?_r^65WB;n|zB@w}8`T-9PaEyw327h_eflDrW0PFW=Bt7@Es`*zP)RPvqW50#DEzl;v zm|bq0{5lhbokXDl679W&+EQW)VfM_*-u$|zh#qwqL@fhjxrL3jZnAm=3a2%>g3J02 zTF;-hsjtiaJ+DVztjU14^d$4cWyuSFoi8Z4M1Q`Rp^FK9V>KpKi~Fkvtu%hbWpv{lRTXZ zx#~1WtXPFD#&~CrrLkp#N`Qg O@(R6w=!P`3Li-aJCy&_x diff --git a/royalnet/packs/common/tables/__pycache__/telegram.cpython-37.pyc b/royalnet/packs/common/tables/__pycache__/telegram.cpython-37.pyc deleted file mode 100644 index 711a911daf1d84e246562106088247ad39e56efb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1955 zcmb_d&x_ke6rPb}Tb5<-W;aP`8fc)0;6iQau`D5Ep`{dj=%yEiWl%h0ueut^c^Ze> z?9F@aUyugcV-LOdkI}WK`~`(Q^}VrWYr)%7WHkCbPcz^5e$3O0ZZ}|f{rlJ7=gkIV z|InZ6auGboyZ8|Y$s|vi<`LIUsUHBlct?4Rj~! zaP}ROP1(9;vbA!eQ2J-A-~NF6vVNm%p62OXXJzaA%&4h?vUz48$);uSBAHfm!M8c6 zWSae;7JXiZpwieRc~)E`GyLC`YMjQPq==1y51cmUrT0^zU`#C4we{&O&L|df$s$Mc z$W@+nqgiL)Dc> zzj1ji?_YaSPd-4uAC~@0m8vPky7bKkjY%?H^z`sP#k=U?V3^?sHLm!|!PU-a*`A|Y z#bBPuz6%b%0^}AnaUiD)l}`R-Kx=PKhZnh4!@{V^Bp;sUQVk(r#A&9?4$R{5WicG* zTIbo&#II9T3@crO*`oCA5|PLQ+_E4-<}B}3J`5`BeiuS~n_Q4wI=_+w?&u||?93q1 zF)YL-=F?ewfdz;TKo=iY{dyqMvSFske~hr=?``?5=@vOjwDI#15c!HDF&|Y#6yH0D zf=L2}5m~I&CpEU?E!)oiu_)VVykY#T#(1=4+?qcYp-=Tg9)4cq+vT&e-lE%<v?|4+ab`H@-7<8!k)%HJ%# zSHtl+#X_r$n$#UiT0)>qA-=2$IjkHRY>c=~6O@@lwqMZ+F1}(vV-vn?!$Zjlzhm$5 zq#?rghO=KIa!4)BpbdjYGiSKQhVO()OzcD$=j;F6@_s2Ry|4 z$XV``Z@eD$4@wL+6`BxbAcW54JS7|o@n()qXl>~VVVlnSFVL9 J$U`S|{{!ZQC7VB|HZAYqp5^E(zTok&Gr>pOpkAxLPA}UG5B#k`9 zC6nGcIipbxbS`U7_d)k%-RX7E1KDtT0D4oloZgUa**PasQ_jhG7+Z2dF2dNBOTd2F z^0x-K)ueTR6>yNU*@krU$P!CdYPJB?~kZA_{ zHM#=Ma-)*{??ks@dbQa-%v04hh1%cGyW6=`U7e5PBvZwWGK~8lOt+t>X`Xe9_G z*O6Nrj;%Ku$QJy{AO>Nl0g_*X#eXt~@HytZx3>cv8*tnP*(ga6p(4#;HKZC59OF`S z++O66#i^QySq0xI;U|_E4oJ{NF8~FjcSa#@v{yl4bnk*1#>RZiwOsxSsZseJ_B=Ieh*>y zXL5v{LTAuDNxyRNkM%;Xu{`wxiX{{nv^!RB&n!POdG-`e8B7&noMJmIy+_;av{qoR zL_$F83p^1>4My)9J_@{dMc1$Bvn#q0dbS}1+<0Szux%lZM^N!lNJ2Q)cNGDc)lduZ z9GSUtr>AATRhAiEcw=1=_@E%GvfAi<7Hk1H)x)X{e|WLI|iSptFK3ld)D2b{xe4u}9(T%Z&VK=J$-pb5#^e6zuc&{ow;6^c9nXu@GE_2wh{h)2 z$rMvfOv=+KPBb+c&kW-%b{{OzMQpQZk3o`@W->NUK`bqt?l+#0|~cI_y{ aNx$>?xv}u9)kXZ7D+5Zr4!)rT&;AFn?rll{ diff --git a/royalnet/packs/default/commands/__pycache__/__init__.cpython-37.pyc b/royalnet/packs/default/commands/__pycache__/__init__.cpython-37.pyc deleted file mode 100644 index 1be736b944ba611b4d440dc67abed0fd0b3ac3db..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 410 zcmYLE!Ab)$5S?Vx-CA1@{foU6@ut)wwr3Fv9+oX3ZbFG>v+Jf73iYHv;Ai+5{zi^^ z@)wE+Gi{{XTwe-LSB;4V%l!MLw>iE>zxBD`Bi! z96&9KN0;MLWw$BFayjSP>ILV6dbQ~cjdqJLQIEPP29?Fo9EEg~#-7#Tp9Y&gS?+#m tP`K}lrO-y)8^!mUoKH9x#&CX6w?l1QXb;OuJ{vVcGKZ}$=`u=U_6P5KWp@Ao diff --git a/royalnet/packs/default/commands/__pycache__/ping.cpython-37.pyc b/royalnet/packs/default/commands/__pycache__/ping.cpython-37.pyc deleted file mode 100644 index 0a4735ef5234b2d741da1bf4dc010958b8bfb686..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 662 zcmYjOJ8u&~5Z>3>=ND0=loX~kg=;_-f+SK%6GZ}=lhJB*vsf1Ay<_*TaFmYpD56Co zDI@VO_!rw!(IL@MF>~19k>;^Gd*96W-Qj4|XK0t#U*G(~{GAS4Q&>Dh5BD(u175IK z?1X^;dBs3l{y}B})Jrx=e&7o>;gLVgsoL5hj&gDu|rF7|zj;g0zsrr(c`pUjU+Smt)_%e5(-t^XI5$=`)} zj+9E*CS(@o#B5rvqx6mIAx01w7{A!t;XlRRq#skQNdc{6U+Yx~O+ocg>-P2s22dpJgw{5@>9EOx?(?no;7tAPOed?<#Zy+fI^ i{VmNY@ghR8yP43w*})=#JORdZ_ILTGoKT5xD*pgO_@~YQ diff --git a/royalnet/packs/default/commands/__pycache__/version.cpython-37.pyc b/royalnet/packs/default/commands/__pycache__/version.cpython-37.pyc deleted file mode 100644 index e0641bf1644e7d268ed4770aba5b47c80816c29e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 806 zcmY+Dzi-qq6vyq@`Elu$w#*F2)-ary_@xt~v{GTYfnP&($ckc9PR)$&AclB>nlLsbo`muisKTC1WOJSyi&RzR@bH?$j4nN&|_6=WGl%<@DZ8Ovo-CDzlb zs&$dF_S$%B^nXA%*TG0yk@vvkBRgf1E!nZBuPlMcO>)YX&L_HLpXoy&_JB~Zz{VZd z+i>pZ>ieH>Z_aOHX&5^C*)Js=p6Is3b7z*M$7YfOqOxcPAY~>Uf!W+LT^INj7!)A1PXl-sm;Yxw zgiTRs10fKt5H=JdFJ+yf-xuOl4P=`Y?LijHOr`CX5J^##Rf2ep5ZcG3jrMizA?j{& z0L1kUEH@QhFbGT|dKbFE+#&5deW!_yBRAgZN*-d3Se)HH3$S5P)YlNn45qks|mA0V$qKDQbK6V8KI38P@C)RyWC-jm1Je*%#{NyTZ5p&`=nF&Ad%1g8HB-~WkE>l^BXPiizQRJs2)UVWRcG*Rwgd(gj#iDCRWXv zH7TrM-hC%4@&p_DVqxEo(?QHxCJ;kf)4^5b8%rr&=gw@0(_uU*xJ*P`9>z6}X34XO zlOoHCJa&yHMwGd%5C?j>?T(Z*l}+pMsawPC)Pk~YpSv)K`b`@8SEETw8*B4Dxyd^?c_UJ>ZjmVTjY&PF}El2B&vVy-VF?MX@LMK7X_k(|8L~Tj{ diff --git a/royalnet/packs/default/stars/__pycache__/api_royalnet_version.cpython-37.pyc b/royalnet/packs/default/stars/__pycache__/api_royalnet_version.cpython-37.pyc deleted file mode 100644 index 9563ff793ddd3a045fad864e13399128eab70cb3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 737 zcmZuvy^a$x5VpPEAC3eh{u&zErAT^oLdTClq6jEK6xJeZSr4$s{+;cB?%GSoEARq5 z2RwyaDqew#nItPxFsu1yobi4$^KBkar$-EJQ~Z4Ul{5B>4x>p-PSD*kf?gK zZ-o+^@~DYkQqU zY?mObV zxIHh2dT#fX`R83J7a_H~F+yU&uWeTeY(z$p_WptHZXtNw+X&B3#c5RYnqSgB(ITXK zvXD7w%g)zTF2m%->g8eyZsyu_V7RgYuH&D?OUP%_qXa;Hg?dwBI+VIXP>-XeVX|=GzcpgtnSJYM(_y&!7 z$Nm%V?$pBqHZbqKkPUf&cls30-~)>#oL9mq&Qsdb;aSTXaj%tSKBI%(#q>O%)Uqs8 zZtJzsm1+)TDT+sz7qu~Um3Nsg=e(@ShV$Waz3Yv1=^B5(93P_)R26~6FS|*TmaY6G z&f;mCG=I}rl-iOq$tvM?HB=)01c2spaN0uMi2yX(4Z)wL(^Os84HH9mf7&3EUBO} ze3P#^^js83jsg0McgpStD)Xn-~A9V}t)XN6pfU}nj zdf;3#aF#~sgZqjN`(N?BY-rcL<074BdF}j?S8^&<-FsE3B%jva^JLntc|R9QCe!>^ zxft@=S2B&Nq{z#&WQOwqWSmAyf{3b0edY9GUR$qAsbWHDpS4djT#+o~z(NCfXi5tV zFfZAXhc@cST-7-+qZx(|WYJ=lTWOBN1b4}QSWhkZD}F@Rg> z@nP+}NXocSP&?2lF;S(5M$7;^#(%kkqGA=VklT_k4Loa%&--(9ryR`_7@Eq!EsESx zJrv|@Dbv$0Owrk^qZdb$;{uXcPE@go(p**>WfsNn%1K;gS&>hw=xr*?$%@Wswy0fw zLL{(@Zz>6g8RvT|;-l8Mow$#ii8ydDJ`!zn{5x_R%v6#^Y9ZcX_Kb$Rja!FY1vqHV zjUde0Td_e72RLsz?6({?=4&j7st%uv3b9ynWWdKQB8B$`M3+LFN143c!CU*>8ow7> zKn`F;l02#kb+-d~*mZHe<9p!_q7P9ODRCB+XFqmO4_efY{Tk-FFq`~RcEQy7wZ@7% zh#~_f+Ifq$rQ|7w+0iRo^K0uOdeC7Iv<$T68aCCq&gvd2z$JEu}B&hZ~x1V~Kq86YAD5$1Na>M18;ai)ZYr3Z1F&+lBSH4f9G(MBrqSF+qVimO* z-5%?m&8AVIGF_bYoz9~Cvl=zu5d5rsklKsd)(y8Qa3ZvgY3)8~;_{R_cuC&hvwiLx GzWEJ}Z;dAa diff --git a/royalnet/packs/default/tables/__pycache__/telegram.cpython-37.pyc b/royalnet/packs/default/tables/__pycache__/telegram.cpython-37.pyc deleted file mode 100644 index d101eaed92e4a4881de33ef22787a128f6ed4a11..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1947 zcmb_dO>f&q5Z&d6NKusR*hz|{0UDr(LItVhXPk3!b6q^Mk)B zKjgPBooK-Cz`pNR{xgw@sfuOg>orPHGG6#};68@C9Dvb8Qw-!c`w0Ms;nFv~u+n_zwX#{DTd@aa|)vi6(A703=^gAg1Gn2;+JKQE-;3QnNgk z;Jsm3$DqP4wYnk0K4VJE6k}g)*lDYp8}I)KxFGMyd(svVK2J{d`UpQ-I?umNPB9iz zy*| z(4eAL!@!28uxqFu7%a;Y_vBN@3Z3oGw|(2ZF&_4-pnR3ZS@KfIMXQry(JSmqrl(ee z?MtIVNmJj|{nnuPLyzhY5PXwf3$vBVHC?(sBPeK>(#k)ogYy{Meu*J?;D$7`Li;1Q C(w3J1 diff --git a/royalnet/packs/default/tables/__pycache__/users.cpython-37.pyc b/royalnet/packs/default/tables/__pycache__/users.cpython-37.pyc deleted file mode 100644 index 0a89796cc48a7bd6f752d4861c86e2bc3d935165..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1596 zcmbtU%We}f6tz9hWb&df1f?ushlWL#2%)M%Eh<7n*|cm%LDmqPl6D@cJt?GO*KYd- zzz6Uje1*5H`U_oguP4(cqAd%?^7XZ^J?Gqqz1itB34EvhU+>R7LVn|<`e068LO0Jq zNFr%MQX0{eMJ)9qFXa)ZxXzMV>PJ2$uZi>|KP8f%u&6F;J0$ea;VcQc^|$h5oMyKE zCM(pQ($?Q8^f24At+%n>Q=7vq){~Ihj#Psr)=G-FDD(hNSKlQc2`h?3RFa5E8hMIK zCcRT~LZce!T-KcKgYL_^)9auIvf=aq^rmb%y&>DOb4sG7ydxK2Y{^Br1Y=t+1N#-r z-x=Uq8-p|hI%R@m4f+;za|c903M#R&GY^h=z1@&mf1C{u$I7-wdYFQ9;y_J8rWx$l z=n6Q?jY>ZLB)SdLi|4Oi^tW<39H_p|CvlRg;z}9Cg9FnaFZi8%`B#2Ov<**u3jR=luDLQU1a>(LT zEx@dT@09RU%Nz$J=%N;Yf>Ar65HH%RpfIX8L5*T#KIdAl`~_86=Ae+ZgTmlW6U5G# zOV2i7Ama-577w}36Lo(Evf;eL)j7ET@XU{o;v&`$XFysGq+Fkaxh%VTu=^|7$4;R$ z=$@qCIrztVA=g-zdJ)Ak3Jlr}tJi0i@0&b(1g8w9iZD*G9hcst?Rr|Puva1>p!E%& z2BZd~_X8gT-n*dd7xeK3-3UF~5CU$xF+$k35Qk%^cqk+x9P68k0L*Hng?NI@T)ETZ zvfe7o951}7t_XZkkX2c2^frvT5T*c#r!x?3myfBT7j|qQM9J1Rg-CNbPLTNnIAS|O zxC=V<29am7v4qphl<2!ST|1u? z3_huJa`nh)ENzWdW7n?iUG=5tmJe-Q43Cs{BoXL31~ynPJ>0->8vNrbZ+m|Ld&D%* diff --git a/royalnet/serf/discord/discordbard/discordbard.py b/royalnet/serf/discord/discordbard/discordbard.py index f9621e64..85bf3e94 100644 --- a/royalnet/serf/discord/discordbard/discordbard.py +++ b/royalnet/serf/discord/discordbard/discordbard.py @@ -50,7 +50,7 @@ class DiscordBard: """Get the next :class:`FileAudioSource` that should be played, and change :attr:`.now_playing`. Args and kwargs can be passed to the generator to select differently.""" - fas: Optional[FileAudioSource] = await self.generator.asend((args, kwargs)) + fas: Optional[FileAudioSource] = await self.generator.asend((args, kwargs,)) self.now_playing = fas return fas diff --git a/royalnet/serf/discord/discordbard/ytdldiscord.py b/royalnet/serf/discord/discordbard/ytdldiscord.py index 5e9ac5b1..f0fc1292 100644 --- a/royalnet/serf/discord/discordbard/ytdldiscord.py +++ b/royalnet/serf/discord/discordbard/ytdldiscord.py @@ -1,6 +1,7 @@ import typing import re import os +import logging from contextlib import asynccontextmanager from royalnet.utils import asyncify, MultiLock from royalnet.bard import YtdlInfo, YtdlFile @@ -16,6 +17,9 @@ except ImportError: ffmpeg = None +log = logging.getLogger(__name__) + + class YtdlDiscord: """A representation of a YtdlFile conversion to the :mod:`discord` PCM format.""" def __init__(self, ytdl_file: YtdlFile): @@ -37,6 +41,7 @@ class YtdlDiscord: async with self.ytdl_file.lock.normal(): destination_filename = re.sub(r"\.[^.]+$", ".pcm", self.ytdl_file.filename) async with self.lock.exclusive(): + log.debug(f"Converting to PCM: {self.ytdl_file.filename}") await asyncify( ffmpeg.input(self.ytdl_file.filename) .output(destination_filename, format="s16le", ac=2, ar="48000") @@ -47,9 +52,11 @@ class YtdlDiscord: async def delete_asap(self) -> None: """Delete the mp3 file.""" + log.debug(f"Trying to delete: {self}") if self.is_converted: async with self.lock.exclusive(): os.remove(self.pcm_filename) + log.debug(f"Deleted: {self.pcm_filename}") self.pcm_filename = None @classmethod @@ -69,6 +76,7 @@ class YtdlDiscord: @asynccontextmanager async def spawn_audiosource(self): + log.debug(f"Spawning audio_source for: {self}") if FileAudioSource is None: raise ImportError("'discord' extra is not installed") await self.convert_to_pcm() diff --git a/royalnet/utils/multilock.py b/royalnet/utils/multilock.py index 5d3eea85..57919864 100644 --- a/royalnet/utils/multilock.py +++ b/royalnet/utils/multilock.py @@ -1,5 +1,9 @@ from asyncio import Event from contextlib import asynccontextmanager +import logging + + +log = logging.getLogger(__name__) class MultiLock: @@ -8,6 +12,7 @@ class MultiLock: self._counter: int = 0 self._normal_event: Event = Event() self._exclusive_event: Event = Event() + self._normal_event.set() self._exclusive_event.set() def _check_event(self): @@ -19,23 +24,35 @@ class MultiLock: @asynccontextmanager async def normal(self): """Acquire the lock for simultaneous access.""" + log.debug(f"Waiting for exclusive lock end: {self}") await self._exclusive_event.wait() + log.debug(f"Acquiring normal lock: {self}") self._counter += 1 self._check_event() try: yield finally: + log.debug(f"Releasing normal lock: {self}") self._counter -= 1 self._check_event() @asynccontextmanager async def exclusive(self): """Acquire the lock for exclusive access.""" + log.debug(f"Waiting for exclusive lock end: {self}") # TODO: check if this actually works await self._exclusive_event.wait() self._exclusive_event.clear() + log.debug(f"Waiting for normal lock end: {self}") await self._normal_event.wait() try: + log.debug("Acquiring exclusive lock: {self}") + self._exclusive_event.clear() yield finally: + log.debug("Releasing exclusive lock: {self}") self._exclusive_event.set() + + def __repr__(self): + return f""