Back to wiki
deluge-bytesized-plugin

The Bytesized Deluge Plugin

Name: deluge-bytesized-plugin

Last reviewed by: Clipper, April 2026


The Bytesized Deluge Plugin

Bytesized has developed a Deluge plugin to automate the Filebot workflow and Flex Disk storage. Once a torrent finishes downloading, the plugin can automatically run Filebot and copy files to your Flex Disk. This lets you remove torrents and their data whenever you want while keeping the content available for Plex.

The plugin supports both the Deluge web interface and the Thin Client GTK interface, and includes whitelist/blacklist label controls for granular automation.

Every new Deluge installation has the plugin enabled by default. If you want to add it to an existing installation, download it here and disable the existing Execute plugin.

Filebot

By default, Filebot is enabled in the plugin. The image below shows the main plugin options:

Imgur

Whitelist / Blacklist

The plugin provides two label-based filtering options:

Imgur

Adding labels (e.g. Series and Movies) to the Whitelist tells Filebot to process files with those labels after download. Adding a label (e.g. Music) to the Blacklist tells Filebot to skip files with that label.

Imgur

Note: In the example above, Whitelist: Series, Movies already implicitly excludes Music — so adding Blacklist: Music is redundant. In practice, use either a Whitelist or a Blacklist, not both, unless you have a specific edge case requiring both.

Flex Disk

Flex Disk is a feature available only on Appbox +Stream boxes. You can learn more here.

Enable Enable copying to Flex Disk under the Flex Disk section to have files automatically copied to your Flex Disk after download.

Imgur

⚠️ Important: The plugin performs a full copy of the torrent files — the original data in ~/torrents/data/ is not removed automatically. This means both locations will use disk space simultaneously until you manually remove the torrent. If your goal is to free up space on your main storage, use the Run after copying script below to automatically remove the torrent and its data once the copy is complete.

When enabled, your Flex Disk path is pre-filled. Two additional options become available:

Label Control

Works the same as the Filebot whitelist/blacklist — add labels such as TV Shows, Movies or Music to the Whitelist to copy them to Flex Disk, and labels such as Games to the Blacklist to exclude them.

Run after copying

Seeding from Flex Disk is not permitted by Bytesized.

By default, the plugin performs a full copy of the torrent data to Flex Disk but leaves the original torrent untouched and still seeding from ~/torrents/data/. This means you temporarily have duplicate data across both locations.

In most cases, you would move data to Flex Disk precisely when seeding is no longer needed — for example a public tracker release, a niche movie with zero leechers, or content you simply want to archive. In that case, keeping the torrent alive and duplicating the data serves no purpose.

To automatically remove the torrent and its original data once the copy completes, you can supply a custom script here that uses the Deluge API. The script receives the torrent ID, name, destination path and label as arguments, connects to the Deluge daemon locally, and calls core.remove_torrent with the delete-data flag.

Save the following script as ~/bin/deluge_remove_after_flexdisk.py, make it executable (chmod +x), and enter its full path in the Run after copying field.

The script is called after the copy has fully completed — the plugin emits the completion event only once all files have been successfully copied.

#!/home/HD/USERNAME/venvs/deluge/bin/python
# -*- coding: utf-8 -*-
#
# .SYNOPSIS
#   Removes a torrent and its data from Deluge after the Bytesized plugin
#   has successfully copied the files to Flex Disk.
#   Called by the Bytesized Deluge plugin "Run after copying" option.
#
# .PARAMETER sys.argv[1]   torrent_id
# .PARAMETER sys.argv[2]   torrent_name
# .PARAMETER sys.argv[3]   save_path  (flexdisk destination path after copy)
# .PARAMETER sys.argv[4]   label      (may be absent)
#
# .NOTES
#   - Only removes the torrent if save_path starts with the flexdisk directory.
#   - Deletes original torrent data from ~/torrents/data/ (not the flexdisk copy).
#   - Logs to ~/.config/deluge/flexdisk_remove.log
#

import sys
import re
import logging
from pathlib import Path

LOG_FILE = Path.home() / ".config/deluge/flexdisk_remove.log"
logging.basicConfig(
    filename=LOG_FILE,
    level=logging.INFO,
    format="%(asctime)s %(levelname)s %(message)s",
)

def read_auth():
    """Read first non-localclient credentials from ~/.config/deluge/auth."""
    auth_file = Path.home() / ".config/deluge/auth"
    for line in auth_file.read_text().splitlines():
        parts = line.strip().split(":")
        if len(parts) >= 2 and parts[0] != "localclient":
            return parts[0], parts[1]
    raise RuntimeError("No valid credentials found in auth file")

def read_daemon_port():
    """Read daemon_port from core.conf using regex (file has non-standard JSON format)."""
    core_conf = Path.home() / ".config/deluge/core.conf"
    content = core_conf.read_text()
    m = re.search(r'"daemon_port":\s*(\d+)', content)
    if not m:
        raise RuntimeError("daemon_port not found in core.conf")
    return int(m.group(1))

def main():
    if len(sys.argv) < 4:
        logging.error("Usage: deluge_remove_after_flexdisk.py <id> <name> <save_path> [label]")
        sys.exit(1)

    torrent_id   = sys.argv[1]
    torrent_name = sys.argv[2]
    save_path    = sys.argv[3]

    logging.info("Called for: %s (%s) save_path=%s", torrent_name, torrent_id, save_path)

    # Safety check: only proceed if save_path is on flexdisk
    flexdisk_path = str(Path.home() / "flexdisk")
    if not save_path.startswith(flexdisk_path):
        logging.warning("save_path %s is not on flexdisk — skipping removal", save_path)
        sys.exit(0)

    try:
        from deluge_client import DelugeRPCClient

        username, password = read_auth()
        port = read_daemon_port()

        client = DelugeRPCClient("127.0.0.1", port, username, password)
        client.connect()

        # Remove torrent and delete original data (True = delete data)
        client.call("core.remove_torrent", torrent_id, True)
        logging.info("Removed torrent %s (%s) with data", torrent_name, torrent_id)

    except Exception as e:
        logging.error("Failed to remove torrent %s: %s", torrent_id, str(e))
        sys.exit(1)

if __name__ == "__main__":
    main()

Note: Replace /home/HD/USERNAME/ in the shebang with your actual home path, found on your box dashboard.

Last Author
Clipper
Contributors
None
Versions
10
Last Update
Sun, 12 Apr 2026 10:13:19 +0200