keep a running M3U playlist of music shared in a channel
Find a file
2026-01-15 16:46:00 -05:00
base-config.yaml still trying to get file download working 2026-01-15 15:52:32 -05:00
Makefile trying unsuccessfully to get files downloaded from channel 2026-01-13 16:45:28 -05:00
maubot.yaml just message, not reply 2026-01-15 16:46:00 -05:00
musiccollector.py just message, not reply 2026-01-15 16:46:00 -05:00
musiccollector_migrations.py cleanup code, improve handling, hopefully simplify things a little 2025-11-26 11:02:57 -05:00
README.md removing the database logic. just use a config variable 2026-01-13 17:04:56 -05:00
requirements.txt remove spotdl entirely. Song.link to yt-dlp only. 2025-11-13 11:44:53 -05:00
test_filename.py add the artist name to the downloaded file 2025-12-08 21:49:36 -05:00
test_fix.py enabling playlists/albums 2025-11-26 14:23:51 -05:00
test_logic_only.py removing the database logic. just use a config variable 2026-01-13 17:04:56 -05:00
test_regex.py enabling playlists/albums 2025-11-26 14:23:51 -05:00
test_sanitize.py add the artist name to the downloaded file 2025-12-08 21:49:36 -05:00

Music Collector Maubot Plugin

A maubot plugin that collects music shared in Matrix channels and adds it to an M3U playlist.

Features

  • Detects Spotify, YouTube Music, album.link, and song.link URLs in Matrix messages
  • Resolves album.link/song.link to their source platforms using the Linktree API
  • Downloads audio using yt-dlp (handles both YouTube and Spotify through song.link API)
  • Accepts direct audio file uploads (MP3, OGG, FLAC, M4A, WAV, OPUS) to Matrix channels
  • Uploads MP3 files to Nextcloud
  • Generates and updates M3U playlists per Matrix room
  • Provides shareable links for both individual tracks and playlists

Installation

  1. Install the required dependencies:

    pip install maubot yt-dlp aiohttp pyyaml
    
  2. Configure the plugin with your Nextcloud credentials in base-config.yaml

  3. Build and deploy the plugin to your maubot instance

Configuration

The plugin requires the following configuration in base-config.yaml:

# Nextcloud credentials
nextcloud_url: "https://your-nextcloud-instance.com"
nextcloud_username: "your_username"
nextcloud_password: "your_password"
nextcloud_folder_path: "/MusicCollection"

# Playlist configuration
playlist_base_path: "/tmp/playlists"

# Optional: (spotdl has been removed, this configuration is no longer used)
# Spotify links are now resolved through the song.link API
# spotify_client_id: ""
# spotify_client_secret: ""

# Optional: List of room IDs where the plugin should be enabled
# If not specified or empty, the plugin is disabled in all rooms by default
# enabled_rooms:
#   - "!roomid1:example.com"
#   - "!roomid2:example.com"

# Optional: Command prefix for plugin commands (default: "!music")
# command_prefix: "!music"

Room Enabling

By default, the plugin is disabled in all rooms. You can enable it in specific rooms in two ways:

  1. Configuration-based: Add room IDs to the enabled_rooms list in the configuration file
  2. Command-based: Use !music enable in a room to enable the plugin temporarily (until restart)

Commands:

  • !music enable - Enable music collection in the current room (temporary)
  • !music disable - Disable music collection in the current room (temporary)
  • !music status - Check if music collection is enabled in the current room

## How it works

1. The plugin monitors Matrix room messages for music URLs and audio file uploads
2. When a URL is detected:
   - Spotify/Youtube links are processed directly
   - album.link/song.link URLs are resolved to their sources using the Linktree API
   - Audio is downloaded using yt-dlp (handles both YouTube and Spotify through song.link API)
   - MP3 files are uploaded to Nextcloud
   - M3U playlist for the room is updated with the new track
   - Shareable links are provided for both the track and the updated playlist
3. When an audio file is uploaded directly to the channel:
   - MP3, OGG, FLAC, M4A, WAV, or OPUS files are detected automatically
   - Files are uploaded to Nextcloud
   - M3U playlist for the room is updated with the new track
   - Shareable links are provided for both the track and the updated playlist

## Supported Sources

- Spotify (tracks, albums, playlists)
- YouTube Music (videos, playlists)
- album.link URLs
- song.link URLs
- Direct audio file uploads (MP3, OGG, FLAC, M4A, WAV, OPUS)

## License

MIT