Automatic Editing of MASS Playlists to Automatically Include New Songs #3308
homeauto-git
started this conversation in
Show and tell
Replies: 1 comment 3 replies
-
Not sure if this also achieves what you were after but if you are using the remote share provider you can create a playlist which is stored on that. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This guide outlines how to use Music Assistant and Home Assistant to edit a playlist. Using a custom Python script executed via a Shell Command for automatic inclusion of new songs.
Link to Yt-dlp Addon
Prerequisites
Step 1: Create a Playlist in Music Assistant
Open Music Assistant:
Add Tracks to Playlist:
Save Your Playlist:
My Favorite Tracks
.The playlist is now available in Music Assistant's library.
Step 2: Export Playlist to M3U Format
2.1 Enable Shell Command in Home Assistant
Open your
configuration.yaml
file.Add the following under
shell_command
:Restart Home Assistant to apply the changes.
2.2 Add the Python Script
Create a folder named
scripts
in the/config
directory of your Home Assistant setup.Create a file named
create_playlist.py
in the/config/scripts/
folder.Paste the following Python code into the file:
2.3 Configure Media Folder
Ensure your audio files are located in a media folder accessible by Home Assistant, e.g.,
/media/audio
. Update the paths in the Shell Command service accordingly.Step 3: Call the Shell Command
Go to Developer Tools > Services in Home Assistant.
Select
shell_command.create_playlist
.Call Service.
The script will generate an M3U file in the specified location. You can confirm the operation by checking the
/media/like.m3u
file.Step 4: Advanced Automation
4.1 Enable Folder Watcher Integration
Integrations Menu
to set up Folder Watcher:https://www.home-assistant.io/integrations/folder_watcher
/media/audio
.4.2 Create an Automation to Trigger the Shell Command
Go to Settings > Automations & Scenes and create a new automation.
Use the following YAML configuration:
Save the automation and enable it.
4.3 Test the Automation
/media/audio
folder./media/like.m3u
file to verify that the playlist has been updated.Additional Notes
.m3u
file and it worked. I wanted to keep it exactly how Music Assistant made it but I do not know a command to get out the length of the audio file in seconds like it does but setting to0
seems to workFeel free to share, customize, and expand this guide! 🚀
Disclaimer
This guide is provided for informational purposes only. Use it responsibly and ensure compliance with all applicable copyright laws. You are solely responsible for ensuring that any audio files used with this system are legally obtained and that you have the rights to download, store, and play them. The author of this guide is not responsible for any misuse or legal issues arising from its implementation.
Beta Was this translation helpful? Give feedback.
All reactions