easy-playlist
A library to easily manage yours playlists in python
Getting started
Installation
This library will work with python 3.6+
PyPi : pip install easy-playlist
GitHub : Github
Usages
This library will work with any files, it use ffmpeg to get the lenght It's was desinged to work with bots in general
Code example
Simple tasks
from easy_playlist import Playlists
pls = Playlists()
pl = pls.add_playlist("test")
# pl = pls.get_playlist("test")
# 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 easy_playlist import Playlists
# any bot library
bot = Bot()
pls = Playlists()
pl = pls.add_playlist("test")
# pl = pls.get_playlist("test")
# 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.on_music_over()
(async) 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)
An other code to explain
pl = Playlists()
pl1 = pl.add_playlist(name="test1", playlist=["music/bip1.mp3", "music/bip2.mp3"])
pl2 = pl.add_playlist(name="test2", playlist=["music/bip1.mp3", "music/bip2.mp3"])
pl.add_music("test1", "music/bip3.mp3")
# pl1 = pl.get_playlist("test1")
# pl2 = pl.get_playlist("test2")
pl1.play()
pl2.play()
print("starting...")
@pl.on_music_over()
def music_over(data):
print(f"[{data.playlist.name}] {data.music.name} is over, next song now!")
if data.playlist.is_over():
print(f"Playlist {data.playlist.name} is over")
data.playlist.clear()
return
data.playlist.next()
Metadata
Release files for easy-playlist 1.9.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| easy_playlist-1.9.1.tar.gz | 7.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| easy_playlist-1.9.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.7 kB
Release files / easy_playlist-1.9.1.tar.gz
| Download URL | easy_playlist-1.9.1.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d6203c651e3d0f6491b14027c3ba313e6ef7b1ace8bef05461827bef04c66092
|
|
BLAKE2b-256 checksum How to use checksums |
6dfabd13d5302bfc87744dd85906ef0ae704c1449c201932fc333151f20899a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.11
|
Release files / easy_playlist-1.9.1-py3-none-any.whl
| Download URL | easy_playlist-1.9.1-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3b683bac219ffae0ca571f0a255cd1cb24bcb13f57425e3d04303136d1deac00
|
|
BLAKE2b-256 checksum How to use checksums |
0f02e54e51f3a9f68288ba88f96106f48c880dd6ae5e5a5f4adc96a16d7cfbfa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.11
|