Skip to main content

A Python script for recursively creating audio playlists

Project description

Introduction

genpl is a Python 3 script for recursively generating playlists (M3U8, PLS, etc.) for audio files.

Some music devices (e.g., the author’s OEM automotobile head unit) do not support a library of audio files, but only a simple single-folder or playlist play modes, that harken back to the early days of software audio players. Given a typical filesystem layout that places releases in independent folders beneath an artist folder, the only way to play an entire artist is to build a playlist containing all releases for the artist. genpl solves the problem by recursively building “chained” playlists containing audio files for the containing folder or below. That is, suppose the following folder structure:

/Music/Popular/Releases/Rush/2112

Provide the path /Music to genpl, and it can create a playlist at evey level of the path. A playlist in folder ‘2112’ will contain tracks from the album 2112; a playlist in folder ‘Rush’ will contain all releases for the artist Rush; a playlist in folder ‘Releases’ will contain releases for all popular artists; a playlist in folder ‘Popular’ will contain music for all popular artists; finally, a playlist in folder ‘Music’ will contain all music.

Usage

By default, genpl needs only a root path to generate chained m3u8 playlists for all subfolders containing audio files with extensions ‘ogg’, ‘flac’, ‘mp3’, ‘aac’, ‘m4a’, ‘oga’, ‘mka’, and ‘shn’:

genpl /Music

Or on Windows:

genpl F:\Music

Other generation modes are available to create a single playlist in the root containing all music below the root, --single-playlist, or to create playlists only in folders containing audio files and excluding files from subfolders, --unchained-playlists. Playlists are named the same as the parent folder, e.g., in the example above, folder ‘2112’ would contain a playlist named ‘2112.m3u8’. Use the --parent argument to create the playlists one folder higher, instead; e.g., in the example above the folder ‘Rush’ would contain a playlist for each release, rather than a playlist in each subfolder. A fixed playlist filename can be provided to the --filename argument; however, in --parent mode, the filename only applies to the playlist created in the root. Other playlist types than ‘m3u8’ are available through the --type argument.

By default, genpl will use the path conventions for the platform where it is run (for example ‘/’ path separators on Linux vs. ‘' path separators on Windows). In cases where the files may be moved to another platform, it may be useful to force a certain convention with --posix or --windows. Note, however, that the author’s experience suggests that POSIX conventions work with most platforms and software, including Windows; your milage may vary.

By default, genpl creates playlists using paths relative to the playlist location. For example, given the folder structure above, a playlist in the ‘Relases’ folder would have entries:

Rush/2112/01 - 2112.ogg
Rush/2112/02 - A Passage to Bangkok.ogg

In almost all use cases, this is preferred as playlists stay correct if the root is moved, say, to another device or accessed remotely from another device. For specialized cases, --absolute-paths provides an absolute path mode; --base provides a quasi-absolute mode which substitues the root path with a provided path (absolute root path on a destination device). For example, these options on a Linux system:

genpl --base "M:\Music" --windows /Music

Could create a playlist with these entries:

M:\Music\Popular\Releases\Rush\2112\01 - 2112.ogg
M:\Music\Popular\Releases\Rush\2112\02 - A Passage to Bangkok.ogg

Since absolute paths are incompatible with cross-platform support, the path convention options are not valid with --absolute-paths.

Installation

Warning

Some Linux distributions discourage installation of system-level python packages using pip or setup.py install, due to collisions with the system package manager. In those cases, dependencies should be installed through the package manager, if possible, or choose a user folder installation method.

Installing with pip

If your system has pip installed, and you have access to install software in the system packages, then kantag kan be installed as administrator from PyPI:

# pip install genpl

If you do not have access to install system packages, or do not wish to install in the system location, it can be installed in a user folder:

$ pip install --user genpl

Installing from source

Either download a release tarball from the Releases page, and unpack:

$ tar zxvf genpl-1.1.0.tar.gz

Or get the latest source from the git repository:

$ git clone https://github.com/dgasaway/genpl.git

If you have access to install software in the system packages, then it can be installed as administrator:

# python setup.py install

If you do not have access to install system packages, or do not wish to install in the system location, it can be installed in a user folder:

$ python setup.py install --user

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

genpl-1.1.1.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

genpl-1.1.1-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file genpl-1.1.1.tar.gz.

File metadata

  • Download URL: genpl-1.1.1.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.55.2 CPython/3.7.9

File hashes

Hashes for genpl-1.1.1.tar.gz
Algorithm Hash digest
SHA256 429fb872b3d05352f25244fe3208583e56c69afd09e5b7dc38399690ebd7d207
MD5 301062ddf323d07a307efec5173e62d4
BLAKE2b-256 06cad9312ac20f07d2d050fb893fb67245e2f888ea17d45f98a3733144f1dc04

See more details on using hashes here.

File details

Details for the file genpl-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: genpl-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 14.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.55.2 CPython/3.7.9

File hashes

Hashes for genpl-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 40f3c7f6d08cf203a44e01620e8cf407cd0ec49826444026c1e9929775d2fbc9
MD5 0d4c5834c7a9a01376df24abfc6b887b
BLAKE2b-256 6696ca6fe98f0e8f7f194f1d63f39e2222196e399b1f2f20a85215ce40b7cf86

See more details on using hashes here.

Supported by

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