Skip to content

Tool for parsing and manipulation of foobar2000 playlist files

License

Notifications You must be signed in to change notification settings

AkaBlur/fpl-tool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fplTool

🐱 A Tool for parsing foobar2000 Playlist files 🐱

Features

  • Command-line tool
  • File input: .fpl
  • Check for Missing Files with -e
  • In-operation Replacement in Filepaths (manipulate paths from files) with regex options -r:a & -r:d
  • Custom Output Options with -o

This program is OS-aware when compiled.
Therefore the appropriate path separator will be used.
(\ on Windows and / on UNIX-like systems)

How-To-Use

The basic principle for this tool is to read in a foobar2000 playlist file and print all containing files to the output.
Inbetween input and output there are several options that can be used for parsing and manipulation.

For example you can use this tool to create a simple .m3u playlist file.

fpltool myplaylist.fpl > myM3Uplaylist.m3u


Basic usage:

fplTool myplaylist.fpl

This will read in all playlist files from the given myplaylist.fpl playlist and print them as output.



Check for missing files:

Enable with option -e
When this option is supplied all files are checked whether they exist or not.
Non-existing files are printed to stderr.
With this option only files that exist are output.



Apply patterns to filepaths

This options allows the user to supply a pattern that is used when filepaths are read in.
👆 These options will be applied before file-check with -e 👆

There are two options you can use:

fplTool -r:d <REGEX>

or

fplTool -r:d <REGEX> -r:a <STRING>


Use regex for deletion - r:d <REGEX>

When supplying this option the regular expression REGEX is applied to all filepaths from the playlist. Portions that get matched will be removed from the path.
This option is intended to be used when changing all paths from all playlist files.

Important

REGEX can only support basic 8-bit chars! (nothing above U+00FF)

Example
Remove drive letters from files

General playlist:

fplTool myplaylist.fpl

Q:/music/1.mp3
Q:/music/2.mp3
Q:/music/3.mp3
Q:/music/4.mp3
Q:/music/5.mp3

Removing all drive letters:

fplTool -r:d "Q:/" myplaylist.fpl

music/1.mp3
music/2.mp3
music/3.mp3
music/4.mp3
music/5.mp3



Use regex for replacement - r:d <REGEX> and r:a <STRING>

When supplying both options the first operation will still remove the matched <REGEX> string.
Following the deletion, all matched portions inside the filepaths will be replaced with <STRING>.
This string can be anything, but the format here is defined in the ECMAscript standard 262. This can be used to reference the removed portions of the path in the given string.

For a detailed overview check:


Example
Substiute filepaths (f.e. if you moved your library):

General playlist:

fplTool myplaylist.fpl

Q:/music/1.mp3
Q:/music/2.mp3
Q:/music/3.mp3
Q:/music/4.mp3

Substitute to accomodate new paths:

fplTool -r:d "/music/" -r:a "/music/newmix/" myplaylist.fpl

Q:/music/newmix/1.mp3
Q:/music/newmix/2.mp3
Q:/music/newmix/3.mp3
Q:/music/newmix/4.mp3
Q:/music/newmix/5.mp3

or if moved to a different disk:

fplTool -r:d "Q:" -r:a "Z:" myplaylist.fpl

Z:/music/1.mp3
Z:/music/2.mp3
Z:/music/3.mp3
Z:/music/4.mp3
Z:/music/5.mp3



Custom Output Options - -o <OPTION>

This option will produce an output that is formatted to a specific spec.

Currently implemented formats:

  • M3U
  • EXTM3U (extended M3U)

These options currently only output text-based playlists. They can be used to pipe the output to a file.

Building

Prerequisites

  • cmake (> 3.12)
  • a C++ toolchain (tested with gcc 11.4)


To build from source, first clone the repository.
Then build like an usual cmake project.

mkdir build
cmake -S . -B build
cmake --build build

If you want to build in debug mode, set the option: BUILD_DEBUG=1

mkdir build
cmake -S . -B build -DBUILD_DEBUG=1
cmake --build build

Installation

Just invoke cmake with install but select the target build directory.

Important

This may require sudo or system administrator privileges!

# if build with: cmake -S . -B build
cmake --install build

Development

Currently I'm working on this project to give a reliable option from transitioning from foobar2000 to VLC (and to Linux as there is no native foobar2000 version 🙃). For this I tend to use this as an option to save me some hassle and rebuild my complete playlist from scratch.
Therefore probably some features will be also implemented that accomodate updating existing playlist files or stuff like that.

At the moment the most limiting factor (besides time) is the distinct lack of information about the format of the .fpl-file format. I reverse-engineered some portions and I also found quite some forum posts about that format, but somehow nobody has a clear solution.

About

Tool for parsing and manipulation of foobar2000 playlist files

Resources

License

Stars

Watchers

Forks

Packages

No packages published