Create a simple web page to listen to audio files in a directory
The package is available on PyPI and you can install it using pip/conda.
pip install earworm
This tool can generate a simple HTML page from a directory of music files. The tool can read metadata from files directly (currently only supports MP3 files and ID3 tags). But, if you have files which are not MP3, you can use a CSV file with the metadata.
The CSV file must have the following columns filename
and title
, and
any additional ones you may want. A template can be generated using the tool --
see step 3 below.
-
To get started create a sample config file:
earworm make-config -c config.yml
-
Change the value of
music_dir
to the directory where you have your music files. If you wish to use a CSV file for the metadata, add ametadata_csv
entry to the config.metadata_csv: "/path/to/metadata.csv"
-
You can generate a template for the
metadata.csv
from yourmusic_dir
by runningearworm
with theupdate-csv
sub-command. Once the CSV file is generated, add ametadata_csv
entry pointing to this file to your config. -
Run
earworm
to generate a directory calledoutput
with anindex.html
,music/
directory with all the music files that have "valid metadata", and acovers/
directory with the cover images for the albums. -
You can specify the
<title>
of the page by using thetitle
config var -
If the
base_url
parameter is specified, anog:image
tag is added to the page, using the latest song's cover image. -
Open the
index.html
in your browser to view the playlist locally. -
If you have access to a webserver, you can just sync the output directory to your webserver.
-
If you don't have access to a webserver you can use something like Google Drive or Dropbox to host this as a static website.
-
A new music file can be added to an existing music directory and site using the
add-audio
subcommand.earworm add-audio -c config.yml -i ~/Downloads/cover-image.jpg ~/Music/covers/song123.mp3
When working on the source (py/html/CSS/JS) of the site, you can automatically
generate the html each time you make any changes to the input files using
entr
.
ls /path/to/config-file $(git ls-files) | entr earworm --config /path/to/config-file
To change the JS files, you need to have rollup
installed and you can run the
rollup watcher (rollup -w -c rollup.config.js
) to build the bundle.js
.