A tool that synchronizes your YouTube playlists and other music providers with your Cloud Storage like Nextcloud as MP3s.
- ๐ต Downloads your music from YouTube, SoundCloud and many more
- ๐ Automatically monitors your playlists for newly added music
- ๐ Converts video files to the highest quality MP3 possible
- โ Uploads your music as MP3 to your Cloud Storage account. Supports all Cloud providers with WebDAV compatibility: Nextcloud, ownCloud, pCloud, STACK and many more
- ๐ผ Adds coverart to your MP3s automatically
- ๐ It's aware of the songs that have already been downloaded. This saves a lot of time since they don't get redownloaded every time the application runs again.
The Music Service is a microservice application and runs as a Docker container. Because of using Docker, every installation runs the same, for everyone. This brings programming efficiency and improves reliability. Docker image release
โ ๏ธ You must have Docker installed: Either the Docker Desktop (with GUI) or Engine (no GUI) installed on your system.
โน๏ธ Tip: If you just want to test this application, luckily there is a good tool to use. Just do
docker run -d -p 8080:80 nextcloud
to start a fresh Nextcloud environment. When started, go tohttp://localhost:8080/
in some cases you have to replacelocalhost
with your computers IP. And you can continue to follow the steps below!
โน๏ธ Recommendation: For the best experience, install this container on a computer/server which runs 24/7, so you will always have your music in sync.
- Prepare the code (required):
- Option 1 Docker Compose (recommended): Copy the docker-compose file contents to your editor and follow the steps
- Option 2 (Docker run): Copy the code below to your favorite editor, Notepad, Word etc.
docker run -d \
--name musicservice \
--restart=always \
-v config:/config \
-v musiccache:/music \
-e URL=https://demo2.nextcloud.com/remote.php/dav/files/kA2kSpbk2tMwCPpB/ \
-e DIRECTORY=/some/01%20my%20music \
-e USERNAME=kA2kSpbk2tMwCPpB \
-e PASSWORD=demo \
-e INTERVAL=5 \
thijstakken/musicservice:latest
Before you can run the docker-compose or docker run command, you will first have to make a few changes.
-
Configure
URL
(required):- Go to your Nextcloud website
- Go to the "files" menu at the top
- Now in the lower left corner, select "Settings"
- Copy the whole WebDAV URL you see there
- And place it after the
URL=
-
Configure
DIRECTORY
(required):- Option 1: You can leave it empty like this
-e DIRECTORY= \
, then it will save the files to the root directory off your cloud storage. (not recommended)
- Option 2: Or you can specify a custom directory, like your music folder:
- Navigate to your music folder in Nextcloud
- In the URL you have to copy the path, everything between
dir=
and the&fileid=2274
- And then copy it to the DIRECTORY variable, example:
/some/01%20my%20music
- Option 1: You can leave it empty like this
- Configure
USERNAME
(required):
- Go to your Nextcloud webpage and and click on your user-icon in the top right
- Click "View profile"
- Copy and paste your username in the USERNAME variable
-
Configure
PASSWORD
(required):- Option 1: (account without 2FA multifactor)
- Copy your password into the PASSWORD variable
- Option 2: (account has 2FA multifactor protection)
- Go to the right top corner of your Nextcloud website and click the user-icon
- Click on
Settings
- In the left bar, go to "Security"
- Scroll down to the bottom where you will find
Devices & sessions
- Fill in an app name like
musicservice
- Click
Create new app password
- Copy the code that appears (53Xqg-...) into the PASSWORD variable
- Configure
INTERVAL
(optional):
By default it's set to 5 if you don't specify anything. This is true even if you leave the whole INTERVAL variable out of the command.
If you want to run the script more often or less often, you can just put in a number.
- It's in minutes, so a
10
will represent 10 minutes. The program will then run with intervals of 10 minutes. - If you only want to run the script one time. You can set the number to
0
and then the script will not run on shedule and just stop after one run.
- Open a terminal and run your command!
- If you did the steps with the docker-compose file, do
docker compose up -d
(make sure your command line interface is active in the same directory as where the docker-compose.yml file lives). - If you did the steps with the docker run command, paste it in your command line interface and run it.
- If you did the steps with the docker-compose file, do
8. That's all! If everything is correct, it will create the container, mount the volumes with the configuration and then do it's first run. Let it run for a minute or so. If everything works you should see a new folder and song in your cloud storage. If that happened everything is working fine.
But if this is not the case, the program crashed or it's taking longer then 5 minutes, then you should check out the logs.
- Check the logs (optional):
To check a crashed container or just have a peek at the logs, you can run this command on your terminaldocker logs musicservice
and it will display the logs for you. This is how you can do debugging, find out if everything is working like it should or if there are any errors.
โน๏ธ Tip: You can update the playlists file while the container is running. If you made any changes, they will be in effect the next time it checks for newly added music. Default
INTERVAL
is 5 minutes.
- You can update which playlists to download here:
/config/playlists
- On your machine open up a terminal.
- With
docker volume inspect config
you can see the directory location of the volume. - Go to that directory, go into the
_data
directory and there you will find theplaylists
file, - Edit the
playlists
file with your favorite editor like Nano :), and add every playlist/song that you want to add as a new line. Like this:
youtube.com/playlist1
youtube.com/playlist2
youtube.com/video3
- Save the file, and the next time the container runs or checks for newly added songs, it will look at the playlists file for any updates.
If you where already using youtube-dl with the archive function, you probably have an downloaded.txt or similar file with all the songs you have already downloaded.
-
โ ๏ธ Shut down the musicservice container first -
To migrate, just copy the contents of the old file over to the
/config/downloaded
file. You can find that file at the musicdatabase volume -
Run
docker volume inspect config
at your command line to find the location of that volume on your disk -
Open the file, paste the old information in and save it.
-
That's it!
Feel free to contribute, you can submit issues here and fix issues/bugs, improve the application!
System requirements: Have Docker (Desktop or Engine) installed on your system
Techniques: Python, Docker, YT-DLP and WebDAV
- ๐ค Git clone the project with
git clone https://github.com/thijstakken/MusicService.git
- ๐ Pick a issue from the list or create a new issue and use that one
- ๐ Start editing the code (Python)
- ๐ To build your new image, open a command line in the project folder and run
docker build -t musicservice:dev .
- ๐งช For testing with Nextcloud, just do
docker run -d -p 8080:80 nextcloud
to start a fresh Nextcloud environment. When started, go tohttp://localhost:8080/
in some cases you have to replacelocalhost
with your computers IP.
Use the docker compose file or use this Docker run command, and change it to your needs to get started:
docker run \
--name musicservice \
--restart=no \
-v config:/config \
-v musiccache:/music \
-e URL=https://demo1.nextcloud.com/remote.php/dav/files/wpS97kPjnDJo6gGQ/ \
-e DIRECTORY= \
-e USERNAME=wpS97kPjnDJo6gGQ \
-e PASSWORD=demo \
-e INTERVAL=0 \
musicservice:dev
-
๐ Use the develop branch and commit your feature to a new branch. When committing changes please use Gitmoji and close the corresponding issue with "fixed" and the number of the issue
git commit -m ":bug: fixed #21 Your commit message"
-
โฌ Create a pull request
-
๐ Wait for it to be reviewed and merged!
-
Cleaning up, or starting over with testing:
- Delete the container with:
docker rm musicservice
- Delete the config volume with:
docker volume rm config
- Delete the musiccache volume with:
docker volume rm musiccache
Use at your own risk, never trust the code of a random dude on the internet without first checking it yourself :)