Cleaned up the core logic and added some new quality-of-life features I've been spending some time with the library and wanted to contribute a few updates that make it feel a bit more modern and easier to use. The biggest addition is a new autoplay feature. I noticed a lot of people want the music to keep going even when the queue runs out, so I've integrated recommendation-based autoplay directly into the Player class.#72
Open
wizardoesmagic wants to merge 10 commits intocloudwithax:mainfrom
Open
Cleaned up the core logic and added some new quality-of-life features I've been spending some time with the library and wanted to contribute a few updates that make it feel a bit more modern and easier to use. The biggest addition is a new autoplay feature. I noticed a lot of people want the music to keep going even when the queue runs out, so I've integrated recommendation-based autoplay directly into the Player class.#72wizardoesmagic wants to merge 10 commits intocloudwithax:mainfrom
wizardoesmagic wants to merge 10 commits intocloudwithax:mainfrom
Conversation
- Fixed TypeError where next() was incorrectly called on a range object - Replaced flawed iterator manipulation with clean list-based slicing - Maintains same wave-based pagination functionality for efficiency - Ensures proper handling of large Spotify playlists with multiple pages
for more information, see https://pre-commit.ci
New Features: - Track History: Keep track of previously played songs with navigation and search - Queue Statistics: Detailed analytics about queue contents (duration, requesters, etc.) - Playlist Manager: Export/import playlists to JSON and M3U formats - Track Utilities: Advanced filtering, searching, and sorting capabilities Added Files: - pomice/history.py: Track history management system - pomice/queue_stats.py: Queue statistics and analytics - pomice/playlist_manager.py: Playlist export/import functionality - pomice/track_utils.py: Track filtering and search utilities - examples/advanced_features.py: Complete example bot demonstrating all features - ADVANCED_FEATURES.md: Comprehensive documentation - NEW_FEATURES_SUMMARY.md: Quick reference guide All features are fully documented with examples and type hints. No breaking changes to existing functionality.
for more information, see https://pre-commit.ci
- Merged ADVANCED_FEATURES.md and NEW_FEATURES_SUMMARY.md into FEATURES.md - Provides comprehensive guide for all advanced features - Easier to maintain and navigate - Includes all examples and quick reference sections
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Key changes: - Integrated autoplay support into the Player class. - Added new equalizer presets for Pop, Soft, and Light Bass. - Enhanced Queue with move and remove_duplicates functionality. - Updated exception messages and docstrings for better clarity. - Refreshed advanced example with interaction buttons and progress bars.
for more information, see https://pre-commit.ci
|
All you have to do is to get the recommendations when a track ends and add them to the queue. @commands.Cog.listener()
async def on_pomice_track_end(
self, player: Player, track: pomice.Track, _reason: object
) -> None:
if player.loop:
await player.play(track=track)
elif not player.queue.is_empty:
next_track = player.queue.get()
await player.play(track=next_track)
elif player.queue.is_empty:
recommendations = await player.get_recommendations(track=track)
if recommendations is None:
return
if isinstance(recommendations, pomice.Playlist):
recommendations = recommendations.tracks
# Get the first recommended track that is not the same as the current track
recommend_track = next(
iter([t for t in recommendations if t.identifier != track.identifier]), None
)
if recommend_track is None:
return
player.queue.put(recommend_track)
next_track = player.queue.get()
await player.play(track=next_track) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've been spending some time with the library and wanted to contribute a few updates that make it feel a bit more modern and easier to use.
The biggest addition is a new autoplay feature. I noticed a lot of people want the music to keep going even when the queue runs out, so I've integrated recommendation-based autoplay directly into the Player class.
I also added a few more handy tools to the Queue—specifically
moveandremove_duplicates— so it's much easier to manage playlists on the fly. For the audio side of things, I've added some new sound presets like Pop, Soft, and a lighter Bass Boost for when the default one is a bit too heavy.I spent a good chunk of time cleaning up the Advanced Example too. It now uses interaction buttons for things like skipping and looping, and I added a nice visual progress bar so users can see exactly where they are in a song.
Lastly, I've reworded the error messages throughout the library. Instead of throwing robotic technical errors, the bot will now say things like "Whoops! The queue is completely full right now," which I think makes for a much better user experience.
last time you said it was ai :)