An universal wrapper (and useful tool) to make event / commands in python
Project description
PyPlaylist
A library to easily manage yours playlists in python
Getting started
Installation
This library will work with python 3.6+
PyPi : pip install PyPlaylist
GitHub : Github
Usages
This library will work with any .mp3 files It's was desinged to work with bots in general
Code example
Simple tasks
from PyPlaylist import Playlist
pl = Playlist()
# add music to your playlist
pl.add_music("path_to_music.mp3")
pl.add_music(["path_to_music.mp3", "path_to_other_music.mp3"])
# trigger the timer
# this will take the first song of the playlist
pl.play()
# pause the timer
pl.pause()
# resume the timer
pl.resume()
# stop the current music and trigger the timer for the next one
pl.next()
# stop the current music and trigger the timer for the previous one
pl.previous()
# stop the timer and the music
pl.stop()
# IMPORTANT
# when you don't need to use the playlist anymore do this
# this library use a thread to calculate the time
pl.exit()
To make it work with a bot
from PyPlaylist import Playlist
# any bot library
bot = Bot()
pl = Playlist()
# code example
@bot.command()
def add_music(music):
pl.add_music(music)
@bot.command()
def pause():
pl.pause()
bot.pause_music()
@bot.command()
def resume():
pl.resume()
bot.resume_music()
@bot.command()
def play(music):
pl.play(music)
bot.play_music(music)
@pl.event("music_over")
def music_over(data):
print(f"{data.playlist.name} {data.music.name} is over, playing next now")
pl.next()
bot.play_music(pl.get_current().file)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
easy-playlist-1.0.0.tar.gz
(5.5 kB
view hashes)
Built Distribution
Close
Hashes for easy_playlist-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff5a824ce01bd8aac8364d759bc26c5c0d26050431efe4bed634ab3424795f42 |
|
MD5 | 4aac4b780fa56a1c51d9bd53ede70485 |
|
BLAKE2b-256 | 85b080c52419ad99fb7efc06f853284b2313069ce99153f564f40532401b2d52 |