From e897a595593c2d93db9751fc9f2eea1b7752e465 Mon Sep 17 00:00:00 2001 From: cloudwithax Date: Sun, 13 Nov 2022 21:42:41 -0500 Subject: [PATCH 01/12] Revert "Add Filters.has_global" This reverts commit 0e9399af3ffe464317fc8916fc16b42500b590e7. --- pomice/player.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pomice/player.py b/pomice/player.py index 22db950..774ec89 100644 --- a/pomice/player.py +++ b/pomice/player.py @@ -33,11 +33,6 @@ class Filters: """Property which checks if any applied filters were preloaded""" return any(f for f in self._filters if f.preload == True) - @property - def has_global(self): - """Property which checks if any applied filters are global""" - return any(f for f in self._filters if f.preload == False) - @property def empty(self): """Property which checks if the filter list is empty""" From 8dfdf9f2008ae41f4d7e3585cf16253be18888da Mon Sep 17 00:00:00 2001 From: cloudwithax Date: Sun, 13 Nov 2022 21:49:14 -0500 Subject: [PATCH 02/12] fixing local git --- pomice/player.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pomice/player.py b/pomice/player.py index 774ec89..22db950 100644 --- a/pomice/player.py +++ b/pomice/player.py @@ -33,6 +33,11 @@ class Filters: """Property which checks if any applied filters were preloaded""" return any(f for f in self._filters if f.preload == True) + @property + def has_global(self): + """Property which checks if any applied filters are global""" + return any(f for f in self._filters if f.preload == False) + @property def empty(self): """Property which checks if the filter list is empty""" From ec2f2d734fc92401ca23aae2628fa119d245d3a0 Mon Sep 17 00:00:00 2001 From: cloudwithax Date: Sun, 13 Nov 2022 22:01:15 -0500 Subject: [PATCH 03/12] make queue.remove take Track instead of int --- pomice/queue.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pomice/queue.py b/pomice/queue.py index a44a8aa..97d0cf7 100644 --- a/pomice/queue.py +++ b/pomice/queue.py @@ -118,15 +118,14 @@ class Queue(Iterable[Track]): def _index(self, item: Track) -> int: return self._queue.index(item) - def _put(self, item: Track) -> None: self._queue.append(item) def _insert(self, index: int, item: Track) -> None: self._queue.insert(index, item) - def _remove(self, index: int) -> None: - self._queue.remove(index) + def _remove(self, item: Track) -> None: + self._queue.remove(item) def _get_random_float(self) -> float: return random.random() @@ -233,7 +232,7 @@ class Queue(Iterable[Track]): Removes a item within the queue. Raises ValueError if item is not in queue. """ - return self._remove(self._index(self._check_track(item))) + return self._remove(self._check_track(item)) def find_position(self, item: Track) -> int: From 5bd523c0f83eaf83d1537aa2616bab89730de504 Mon Sep 17 00:00:00 2001 From: cloudwithax Date: Sat, 19 Nov 2022 12:02:27 -0500 Subject: [PATCH 04/12] change version number for hotfix --- pomice/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pomice/__init__.py b/pomice/__init__.py index cf09b08..a5f1602 100644 --- a/pomice/__init__.py +++ b/pomice/__init__.py @@ -18,7 +18,7 @@ if not discord.version_info.major >= 2: "using 'pip install discord.py'" ) -__version__ = "1.1.8a" +__version__ = "1.1.7.1" __title__ = "pomice" __author__ = "cloudwithax" From 70815d45fff066c28477f420d850a9ed4b62cb11 Mon Sep 17 00:00:00 2001 From: cloudwithax Date: Sat, 19 Nov 2022 12:12:39 -0500 Subject: [PATCH 05/12] revert version number for next release --- pomice/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pomice/__init__.py b/pomice/__init__.py index a5f1602..cf09b08 100644 --- a/pomice/__init__.py +++ b/pomice/__init__.py @@ -18,7 +18,7 @@ if not discord.version_info.major >= 2: "using 'pip install discord.py'" ) -__version__ = "1.1.7.1" +__version__ = "1.1.8a" __title__ = "pomice" __author__ = "cloudwithax" From 9fde02c2e08729aadb5f56475a0b13449bf851ae Mon Sep 17 00:00:00 2001 From: cloudwithax Date: Sat, 19 Nov 2022 14:28:15 -0500 Subject: [PATCH 06/12] update advanced.py cog --- examples/advanced.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/examples/advanced.py b/examples/advanced.py index 85350fe..88a364a 100644 --- a/examples/advanced.py +++ b/examples/advanced.py @@ -21,7 +21,7 @@ class Player(pomice.Player): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.queue = asyncio.Queue() + self.queue = pomice.Queue() self.controller: discord.Message = None # Set context here so we can send a now playing embed self.context: commands.Context = None @@ -49,8 +49,8 @@ class Player(pomice.Player): # Queue up the next track, else teardown the player try: - track: pomice.Track = self.queue.get_nowait() - except asyncio.queues.QueueEmpty: + track: pomice.Track = self.queue.get() + except pomice.QueueEmpty: return await self.teardown() await self.play(track) @@ -143,7 +143,7 @@ class Music(commands.Cog): async def on_pomice_track_exception(self, player: Player, track, _): await player.do_next() - @commands.command(aliases=['join', 'joi', 'j', 'summon', 'su', 'con']) + @commands.command(aliases=['joi', 'j', 'summon', 'su', 'con', 'connect']) async def join(self, ctx: commands.Context, *, channel: discord.VoiceChannel = None) -> None: if not channel: channel = getattr(ctx.author.voice, "channel", None) @@ -157,7 +157,7 @@ class Music(commands.Cog): player: Player = ctx.voice_client # Set the player context so we can use it so send messages - player.set_context(ctx=ctx) + await player.set_context(ctx=ctx) await ctx.send(f"Joined the voice channel `{channel.name}`") @commands.command(aliases=['disconnect', 'dc', 'disc', 'lv', 'fuckoff']) @@ -172,7 +172,9 @@ class Music(commands.Cog): async def play(self, ctx: commands.Context, *, search: str) -> None: # Checks if the player is in the channel before we play anything if not (player := ctx.voice_client): - await ctx.invoke(self.join) + await ctx.author.voice.channel.connect(cls=Player) + player: Player = ctx.voice_client + await player.set_context(ctx=ctx) # If you search a keyword, Pomice will automagically search the result using YouTube # You can pass in "search_type=" as an argument to change the search type @@ -187,10 +189,10 @@ class Music(commands.Cog): if isinstance(results, pomice.Playlist): for track in results.tracks: - await player.queue.put(track) + player.queue.put(track) else: track = results[0] - await player.queue.put(track) + player.queue.put(track) if not player.is_playing: await player.do_next() @@ -315,7 +317,7 @@ class Music(commands.Cog): if self.is_privileged(ctx): await ctx.send('An admin or DJ has shuffled the queue.', delete_after=10) player.shuffle_votes.clear() - return random.shuffle(player.queue._queue) + return player.queue.shuffle() required = self.required(ctx) player.shuffle_votes.add(ctx.author) @@ -323,7 +325,7 @@ class Music(commands.Cog): if len(player.shuffle_votes) >= required: await ctx.send('Vote to shuffle passed. Shuffling the queue.', delete_after=10) player.shuffle_votes.clear() - random.shuffle(player.queue._queue) + player.queue.shuffle() else: await ctx.send(f'{ctx.author.mention} has voted to shuffle the queue. Votes: {len(player.shuffle_votes)}/{required}', delete_after=15) @@ -348,7 +350,7 @@ class Music(commands.Cog): -def setup(bot: commands.Bot): - bot.add_cog(Music(bot)) +async def setup(bot: commands.Bot): + await bot.add_cog(Music(bot)) From 23fd49be1a731e922d110269b7da9caa5123011a Mon Sep 17 00:00:00 2001 From: cloudwithax Date: Sun, 11 Dec 2022 21:06:33 -0500 Subject: [PATCH 07/12] add playlist video correction and timestamp retrivial for qualifying videos --- pomice/objects.py | 4 +++- pomice/player.py | 1 - pomice/pool.py | 36 +++++++++++++++++++++++++++++++----- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/pomice/objects.py b/pomice/objects.py index d84478f..aac262e 100644 --- a/pomice/objects.py +++ b/pomice/objects.py @@ -25,12 +25,14 @@ class Track: spotify: bool = False, search_type: SearchType = SearchType.ytsearch, spotify_track = None, - filters: Optional[List[Filter]] = None + filters: Optional[List[Filter]] = None, + timestamp: Optional[float] = None ): self.track_id = track_id self.info = info self.spotify = spotify self.filters: List[Filter] = filters + self.timestamp: Optional[float] = None self.original: Optional[Track] = None if spotify else self self._search_type = search_type diff --git a/pomice/player.py b/pomice/player.py index 22db950..47b4f0b 100644 --- a/pomice/player.py +++ b/pomice/player.py @@ -21,7 +21,6 @@ from .exceptions import FilterInvalidArgument, FilterTagAlreadyInUse, FilterTagI from .filters import Filter from .objects import Track from .pool import Node, NodePool -from .queue import Queue class Filters: """Helper class for filters""" diff --git a/pomice/pool.py b/pomice/pool.py index 9eee0ed..1f39198 100644 --- a/pomice/pool.py +++ b/pomice/pool.py @@ -43,6 +43,14 @@ DISCORD_MP3_URL_REGEX = re.compile( r"(?P[0-9]+)/(?P[a-zA-Z0-9_.]+)+" ) +YOUTUBE_PLAYLIST_REGEX = re.compile( + r"(?P