Advertisement
TChilderhose

Lidarr -> Beets

Jun 21st, 2019 (edited)
4,623
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. Note: These are based on Linuxserver.io images
  2.  
  3. 1. We need to create a 90-config file that will download a docker binary so that lidarr can call commands in a different container
  4.  
  5. -----------------------------90-config----------------------------------
  6. #!/usr/bin/with-contenv bash
  7.  
  8. DOCKERVERSION=20.10.9
  9. curl -fsSLO https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKERVERSION}.tgz \
  10. && tar xzvf docker-${DOCKERVERSION}.tgz --strip 1 \
  11. -C /usr/local/bin docker/docker \
  12. && rm docker-${DOCKERVERSION}.tgz
  13. ------------------------------------------------------------------------
  14.  
  15. 2. Then we need to add two volumes to lidarr server in docker-compose. The 90-config for the docker binary and the docker socket.
  16. - /some/path/to/config/90-config:/etc/cont-init.d/90-config
  17. - /var/run/docker.sock:/var/run/docker.sock
  18.  
  19. Also /music is both the root volume for my music in both beets and lidarr. It can be whatever you want but for this to work they both need to have the same path in their respective containers so that when lidarr calls beets, its the same path structure.
  20.  
  21. 3. Add this in the lidarr container somehow (I just have mine in the config folder). This will trigger beet import and tell lidarr to run an update. Note: You may need to change the lidarr port if you have changed it.
  22.  
  23. -----------------------------beet_import.sh----------------------------------
  24. #!/bin/bash
  25.  
  26. #Get Destination Folder
  27. lidarr_first_track=$(echo "$lidarr_addedtrackpaths" | cut -d '|' -f1)
  28. lidarr_album_path=$(dirname "$lidarr_first_track")
  29.  
  30. #Trigger Beets
  31. docker --config "/config/.docker" exec -u abc beets /bin/bash -c "beet update" && sleep 3
  32. docker --config "/config/.docker" exec -u abc beets /bin/bash -c "beet import -q '$lidarr_album_path'"
  33.  
  34. #Update Lidarr
  35. FILE=/config/config.xml
  36. until test -f $FILE; do sleep 1; done
  37. API=`grep -oP '(?<=<ApiKey>)(.*)(?=<\/ApiKey>)' /config/config.xml`
  38. curl -s "http://localhost:8686/music/api/v1/command?apikey=$API" -X POST -d "{'name': 'ReScanArtist', 'artistID': $lidarr_artist_id}" > /dev/null
  39. ------------------------------------------------------------------------
  40.  
  41. 4. In lidarr, go to Settings > Connect > Add > Custom Script. Select On Release Import. Point the path to beet_import.sh
  42.  
  43.  
  44. Optional:
  45. 1. I have Beets convert the music and rename so I have lidarr renaming tracks with an additional underscore in the track name
  46.  
  47. {track:00}_{Track Title}
  48.  
  49. so that when it gets to beets, it doesn't accidentally remove the wrong file. I think it might be overkill since beets converts to temp folder and then copies. Then in beets config I have the naming structure to
  50.  
  51. $track - $title
  52.  
  53. 2. I was having issues with the docker socket permissions in a container. Looked online and people said that this was one of the better ways to handle it. I added this to my host's cronjob
  54.  
  55. @reboot setfacl -m user:MY_USER_THAT_RUNS_DOCKERS:rw /var/run/docker.sock
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement