Skip to main content

Import singles to Beets as soon as they are dropped in a folder

Project description

drop2beets

A Beets plug-in that imports singles as soon as they are dropped in a folder.

You can provide a function to set meta-data or custom attributes depending on the sub-folder in which the file has been dropped. The examples folder contains some examples of on_item functions you may adapt to your needs.

We use Beets' auto-tagger in quiet mode, and inotify to detect dropped files.

Get started

You'll need Python3 and an existing Beets library. Run:

pip install drop2beets

Enable and configure the plug-in by running beet config -e and set at least the path to the "dropbox" folder.

plugins: drop2beets
drop2beets:
    dropbox_path: ~/beets-dropbox

We advise you configure Beets to always move files out of the Dropbox, and set quiet_fallback:

import:
    move: yes
    copy: no
    quiet_fallback: asis

quiet_fallback tells Beets what to do when the auto-tagger is not sure about the song's identifiaction. Set it to skip to abort the importation in case of ambiguity, or asis to import using tags as they are in the incoming file. This will avoid surprises in case of ambiguous matches, because this script invokes Beet's auto-tagger in quiet mode (as beet import -q) after your custom function.

This function is on_item. It is written in Python, and lets you set some tags depending of which sub-folder the file is dropped in. If you want one, define it in the configuration from this template:

drop2beets:
    on_item: |
        def on_item(item, path):
            """
            Parameters:
                item: the beets Item that we're about to import
                path: its sub-folders path in our dropbox ; if the items has been dropped at the root, then it's empty.
            Returns:
                A dict of custom attributes (according to path, maybe) ; return None if you don't want to import the file right now.
            """
            return {}

Now you're ready to test by calling beet dropbox on the command line and dropping a few files in the folder. Note that drop2beets starts 10 seconds after the last event it received about a file, to ensure that the file has been copied or moved completely. Hit Ctrl+C to close the script.

For a longer-term installation, configure a log file path

drop2beets:
    log_path: ~/drop2beets/log.log

Linux users can install this as a user-lever systemd service by running beet install_dropbox (in a shell where the virtual environment is activated). Note that you'll have to restart the service when you update the on_item function.

Examples wanted !

I'd be happy to include your own variations of this script or the on_item function in the examples folder, feel free to post them in Issues or Pull Requests.

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

drop2beets-2.1.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

drop2beets-2.1.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file drop2beets-2.1.0.tar.gz.

File metadata

  • Download URL: drop2beets-2.1.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.9 Linux/6.17.7-200.fc42.x86_64

File hashes

Hashes for drop2beets-2.1.0.tar.gz
Algorithm Hash digest
SHA256 3cad14e1da001e5bf01c10f27fc33be82b0c428bfa5f91229bf5348efd7aa15d
MD5 b9fe35fba6f9e1c4c925390960095348
BLAKE2b-256 b298f0f56a9cadc5b3ef4f9100f60a58742dc3543838f57dae12b2ed51d818b7

See more details on using hashes here.

File details

Details for the file drop2beets-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: drop2beets-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.9 Linux/6.17.7-200.fc42.x86_64

File hashes

Hashes for drop2beets-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fbc9498a9bfabed872baf7b9eb297eb234f193cecd7c8cf1b666e5ea68fe1fe9
MD5 7afced9eb63876375c8477c16da1eae3
BLAKE2b-256 7b38348b36db28cf69fc26cac87a24b8fa0f7824023917dc6f8d65229b0efd88

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