Skip to main content

A library to easily manage your playlists in python

Project description

easy-playlist

A library to easily manage yours playlists in python

Getting started

  1. Installation
  2. Usages
  3. Code example
  4. Documentation

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()
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()

Project details


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.8.4.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

easy_playlist-1.8.4-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file easy_playlist-1.8.4.tar.gz.

File metadata

  • Download URL: easy_playlist-1.8.4.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for easy_playlist-1.8.4.tar.gz
Algorithm Hash digest
SHA256 2ec0946a8de512a9405ce6be88a5975b8b68e6bc2249bff180639de3b9c4c2f8
MD5 e7b76ccaa2f86adf4bbfae89ea0bcd87
BLAKE2b-256 de8db90e14bca7b8ba673e30719b8df8223a7d0fb8db0559ad567a9766da3dd2

See more details on using hashes here.

File details

Details for the file easy_playlist-1.8.4-py3-none-any.whl.

File metadata

  • Download URL: easy_playlist-1.8.4-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for easy_playlist-1.8.4-py3-none-any.whl
Algorithm Hash digest
SHA256 326384250ceb2f72a3efc4b35d19529b56f9b8264011bbf2621a59fd9b3f0f80
MD5 9572cc31ab75015f08606fdfefd1e04c
BLAKE2b-256 8cc68b9d4d02891678f176b0f4b67018a0a8434ecdaeb834a60371ced90c577a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page