Skip to main content

mkpl make_playlist: Playlist maker

mkpl is a command line tool to create playlist files (M3U format), automatically.

Table of Contents

Installation

To install mkpl, choose one of the following methods:

To install with pip:

# Install make_playlist package (deprecated)
pip install make_playlist
# Use user-space
pip install --user make_playlist

Use external tools like pipx and/or uv (they create virtual environments for you); upgrading is done via a specific subcommand

pipx install make_playlist && pipx upgrade-all || uv pip install make_playlist --upgrade

Deactivate the externally managed file, temporarily or permanently

pip install make_playlist --break-system-packages || python3 -m pip config set global.break-system-packages true

Option 2: From Source

$ git clone https://github.com/MatteoGuadrini/mkpl.git
$ cd mkpl
$ pip install .

Command Arguments

mkpl supports numerous command-line arguments for flexible playlist creation. Below is a comprehensive reference:

Basic Options

Short Long Description Arguments
-d --directories Directories containing multimedia files Path of directories
-e --exclude-dirs Exclude specific directory paths Path of directories
-r --recursive Recursively search directories —

File Format Options

Short Long Description Arguments
-f --format Select only a specific file format Format (e.g., mp3, mkv)
-i --include Include additional file formats Format list (e.g., mp3 mp4)
-p --pattern Include files matching regex pattern Regular expression list
-P --exclude-pattern Exclude files matching regex pattern Regular expression list

File Size, BPM & Duration Filters

Short Long Description Arguments
-z --size Minimum file size Bytes, kb, mb, gb (e.g., 2mb)
-A --max-size Maximum file size Bytes, kb, mb, gb (e.g., 4mb)
-M --length Minimum track length Seconds
-X --max-length Maximum track length Seconds
-b --bpm Minimum beats per minute BPM
-B --max-bpm Maximum beats per minute BPM

Playlist Configuration

Short Long Description Arguments
-t --title Set playlist title Title string
-g --encoding Set text encoding UTF-8, ASCII, UNICODE
-I --image Set playlist cover image Image file path
-m --max-tracks Limit number of tracks Number

File Management

Short Long Description Arguments
-F --file Add additional files File paths
-Q --audio Include only audio files
-W --video Include only video files
-l --link Add remote file links HTTP/HTTPS URLs
-j --join Join other playlist files Playlist file paths
-k --other-playlists Include other playlists Playlist file paths

Sorting & Ordering

Short Long Description
-o --orderby-name Sort by filename
-O --orderby-date Sort by creation date
-T --orderby-track Sort by track number
-y --orderby-year Sort by year metadata
-Z --orderby-size Sort by file size
-L --orderby-length Sort by track duration
-G --orderby-bpm Sort by BPM (beat per minute)
-H --orderby-publisher Sort by publisher
-s --shuffle Randomize track order
-D --descending Reverse sort order

Output & Processing

Short Long Description
-a --absolute Use absolute file paths
-u --unique Remove duplicate files
-c --append Append to existing playlist
-w --windows Use Windows path separators
-x --unix Use Unix path separators
-U --url-chars Apply URL encoding to paths
-N --add-info Include file metadata (#EXTINF)
-K --add-info-interactive Include file metadata (#EXTINF), interactive

Interactive & Utility Options

Short Long Description
-R --interactive Confirm each file before adding
-C --count Count files when creating playlist
-S --split Split into separate playlists by directory
-Y --filter Filter by metadata (artist, album, etc.)
-n --cache Cache results (seconds)
-v --verbose Enable debug output
-E --explain-error Show detailed error traceback
-V --version Display version information

Examples

Basic Usage

  1. Create a playlist for one music album:

    cd myalbum
    mkpl myalbum.m3u
    # or use default naming
    mkpl
    

Directory & Format Filtering

  1. Create playlist from specific format:

    mkpl -d HarryPotter -f mkv HP_saga.m3u
    
  2. Create shuffled playlist with size filters:

    mkpl -d "my_mp3_collection" "my_mp4_collection" -rs -z 2mb -A 4mb "my music.m3u"
    
  3. Exclude specific directories:

    mkpl -d "my_mp3_collection" "my_mp4_collection" -r -s -e "my_mp3_collection/metallica" "my_mp3_collection/dk" -- "my music.m3u"
    

Advanced Filtering

  1. Limit by track count:

    mkpl -d "my_series/GOT" -m 15 "got_first_15.m3u"
    
  2. Filter by track number with regex:

    mkpl -d "my_mp3_collection" -r -p "^[12]|[012]{2}" "my music.m3u"
    
  3. Filter by duration range:

    mkpl -d "music_collection" -M 42 -X 300 "My new collection"
    
  4. Filter by BPM range:

    mkpl -d "music_collection" -r -b 120 -B 140 "upbeat_tracks.m3u"
    

File Management

  1. Add external files to playlist:

    cd myalbum_special
    mkpl myalbum_special.m3u -F music_video.mp4 other_stuff/song1.mp3 other_stuff/song2.mp3
    
  2. Add remote file links:

    mkpl -d "new_collection" -r "my music.m3u" -l http://192.168.1.123/mp3/song1.mp3 http://192.168.1.123/mp3/song2.mp4
    
  3. Merge playlists:

    mkpl -d "Rock'n'Roll" -- "RockNRoll.m3u"
    mkpl -d "Hard Rock" -j "RockNRoll.m3u" -- "Rock.m3u"
    

Metadata & Formatting

  1. Add playlist metadata:

    mkpl -d "new_collection" -r "my music.m3u" -t "My Collection" -g "UTF-8" -I "new_collection/cover.jpg"
    
  2. Include track information (#EXTINF), automatically or interactive:

    mkpl -d "HeavyMetal/Master of Puppets" -N "master"
    cat "master.m3u"
    #EXTM3U
    #EXTINF:516,Metallica - Master of Puppets
    HeavyMetal/Master Of Puppets/02 - Master Of Puppets.mp3
    
    mkpl -d "HeavyMetal/Master of Puppets" -NK "master"
    File: HeavyMetal/Master Of Puppets/02 - Master Of Puppets.mp3
    Enter artist name []: Metallica
    Enter title name: Master of Puppets
    File: HeavyMetal/Master Of Puppets/01 - Battery.mp3
    Enter artist name [Metallica]: 
    Enter title name: Battery
    File: HeavyMetal/Master Of Puppets/03 - The Thing That Should Not Be.mp3
    cat "master.m3u"
    #EXTM3U
    #EXTINF:516,Metallica - Master of Puppets
    HeavyMetal/Master Of Puppets/02 - Master Of Puppets.mp3
    

Sorting & Organization

  1. Sort by various criteria:

    mkpl -d "new_collection" -r "my music.m3u" -o        # by name
    mkpl -d "new_collection" -r "my music.m3u" -O        # by date
    mkpl -d "new_collection" -r "my music.m3u" -T        # by track
    mkpl -d "new_collection" -r "my music.m3u" -y        # by year
    mkpl -d "new_collection" -r "my music.m3u" -Z        # by size
    mkpl -d "new_collection" -r "my music.m3u" -G        # by bpm
    mkpl -d "new_collection" -r "my music.m3u" -H        # by publisher
    mkpl -d "new_collection" -r "my music.m3u" -L -D     # by length (descending)
    
  2. Split into multiple playlists:

    mkpl -d "folder1" "folder2" "folder3" -r "my_music.m3u" -S
    # Results in: my_music.m3u, folder1.m3u, folder2.m3u, folder3.m3u
    

Metadata Filtering

  1. Filter by artist and album:

    mkpl -d "HeavyMetal" -Y artist=Metallica -Y album="Master of Puppets" -- "MoP.m3u"
    

Interactive & Utility Operations

  1. Count files:

    mkpl -d "new_collection" -r -C
    # Output: 4023
    
  2. Interactive confirmation for each file:

    mkpl -d "new_collection" -r -R
    Add file new_collection/sample1.mp3 to playlist? [Y/n]: y
    
  3. Append to existing playlist without duplicates:

    mkpl -d "new_collection" -rsu "my music.m3u" -a
    
  4. Speed process with cache:

    mkpl -d "new_collection" -r -n 300 "my music.m3u" -a # for 5 minutes read the cache if playlist is same
    

List of filter tags

Name Supported
album mp3, mp4, flac, wma
artist mp3, mp4, flac, wma
genre mp3, mp4, flac, wma
title mp3, mp4, flac, wma
year mp3, mp4, flac, wma
track mp3, mp4, flac, wma
bpm mp3, mp4, flac, wma
comment mp3, mp4, flac, wma
publisher mp3, mp4, flac, wma

Use it like Python module

You can use mkpl programmatically in your Python projects to build and write playlists dynamically.

Quick Start

Import the main functions:

from make_playlist import make_playlist, write_playlist

Basic example — create and write a playlist:

from make_playlist import make_playlist, write_playlist, sort_playlist

# Generate playlist
playlist = make_playlist(
    directories=["/path/to/music"],
    extensions=["mp3", "flac"],
    recursive=True,
    filters=[("artist", "Metallica")],
    add_info=True
)

# Sort playlist
sort_playlist(playlist, sortby_name=True)

# Write to file
write_playlist(
    "output.m3u",
    "wt",
    playlist,
    title="Metallica Collection",
    encoding="utf-8"
)

Important Notes

  • make_playlist() returns a Playlist object containing PlaylistEntry items
  • You can iterate, filter, or convert results to a list before writing
  • Most CLI flags are exposed as keyword arguments (e.g., recursive, unique, add_info, encoding, title, image)
  • Use encoding='utf-8' parameter for UTF-8 encoded output
  • pathlib.Path objects are fully supported

Python Examples

Example 1: Write UTF-8 playlist with metadata

from pathlib import Path

plist = make_playlist(
    Path('/Music/collections'),
    ('mp3',),
    recursive=True
)

write_playlist(
    Path('/Music/AtoF.m3u'),
    'wt',
    plist,
    encoding='utf-8',
    title='A–F Collection',
    image=Path('/Music/cover.jpg')
)

Example 2: Inspect and filter results

results = make_playlist(
    '/Music/collections',
    ('mp3', 'flac'),
    recursive=True
)

for entry in results:
    print(f"File: {entry.file}")
    if entry.extinf:
        print(f"Info: {entry.extinf}")

Example 3: Advanced filtering with metadata

playlist = make_playlist(
    '/Music/HeavyMetal',
    ('mp3',),
    recursive=True,
    filters=[
        ('artist', 'Metallica'),
        ('album', 'Master of Puppets')
    ],
    add_info=True
)

write_playlist('/Music/MoP.m3u', 'wt', playlist)

API Reference

See function docstrings for complete parameter documentation:

from make_playlist import make_playlist, write_playlist, sort_playlist

help(make_playlist)
help(sort_playlist)
help(write_playlist)

Open source

mkpl is an open source project. Any contribute, It's welcome.

A great thanks.

For donations, press this

For me

paypal

For Telethon

The Telethon Foundation is a non-profit organization recognized by the Ministry of University and Scientific and Technological Research. They were born in 1990 to respond to the appeal of patients suffering from rare diseases. Come today, we are organized to dare to listen to them and answers, every day of the year.

Adopt the future

Acknowledgments

Special thanks to:

  • Mark Lutz — Learning Python and Programming Python books
  • Kenneth Reitz & Tanya Schlusser — The Hitchhiker's Guide to Python
  • Dane Hillard — Practices of the Python Pro
  • My family — For continuous support and inspiration

Thanks, Python!

Metadata

Release files for make-playlist 1.28.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for make-playlist 1.28.0
File Size Uploaded Provenance Actions
make_playlist-1.28.0.tar.gz 28.8 kB Without provenance Details for make_playlist-1.28.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for make-playlist 1.28.0
File Interpreter ABI Platform Actions
make_playlist-1.28.0-py3-none-any.whl Python 3 none any Details for make_playlist-1.28.0-py3-none-any.whl

Total release size: 57.6 kB

Release files / make_playlist-1.28.0.tar.gz

Download URL make_playlist-1.28.0.tar.gz
Size 28.8 kB
Tags Source
SHA-256 checksum
How to use checksums
710fc6a9012d9e5b081a9cde853f75dc7611dc38c56e4d4da5d7372a9592b206
BLAKE2b-256 checksum
How to use checksums
382581669bcd0847f8a048863f399f536e2bcb181919bf390167962b4b64c339
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.8

Release files / make_playlist-1.28.0-py3-none-any.whl

Download URL make_playlist-1.28.0-py3-none-any.whl
Size 28.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6c1c40359c3a6d60aa6c2a2d8b9f7e43ded1f05c1e6b3d52e263cc4ce28ba47f
BLAKE2b-256 checksum
How to use checksums
971492293681bfa6be0ce00e3ceea34240718ddc22f4ae8adfab322e069fae97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.8

Security for make-playlist 1.28.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.28.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page