keep a running M3U playlist of music shared in a channel
| base-config.yaml | ||
| Makefile | ||
| maubot.yaml | ||
| musiccollector.py | ||
| musiccollector_migrations.py | ||
| README.md | ||
| requirements.txt | ||
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)
- Uploads MP3 files to Nextcloud
- Generates and updates M3U playlists per Matrix room
- Provides shareable links for both individual tracks and playlists
Installation
-
Install the required dependencies:
pip install maubot yt-dlp aiohttp pyyaml -
Configure the plugin with your Nextcloud credentials in
base-config.yaml -
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 works in all rooms
# enabled_rooms:
# - "!roomid1:example.com"
# - "!roomid2:example.com"
# Optional: Command prefix for plugin commands (default: "!music")
# command_prefix: "!music"
How it works
- The plugin monitors Matrix room messages for music URLs
- 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 MEGA.co.nz
- 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
License
MIT