Skip to content

Development technical

Thijs Takken edited this page Mar 20, 2024 · 11 revisions

Developer instructions πŸ‘©πŸ»β€πŸ’»πŸ‘¨πŸ»β€πŸ’»

System requirements: Have Docker (Desktop or Engine) installed on your system
Tech stack:

  1. Backend: Python

  2. Web framework: Flask

  3. Database: Flask-SQLAlchemy

  4. Docker

  5. Youtube-DLP

  6. WebDAV

  7. Using this for frontend Bootstrap v5.3

  8. For the icons, using Bootstrap Icons 1.11.2

  9. For the sheduler (schedules playlist downloads) Schedule

General things

  1. 🀠 Git clone the project with git clone https://github.com/thijstakken/MusicService.git
  2. πŸ› Pick a issue from the list or create a new issue and use that one
  3. 🐍 Start editing the code (Python)
  4. πŸ— To build your new image, open a command line in the project folder and run docker build -t musicservice:dev .
  5. πŸ§ͺ For testing with Nextcloud, just do docker run -d -p 8080:80 nextcloud to start a fresh Nextcloud environment. When started, go to http://localhost:8080/ in some cases you have to replace localhost 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
  1. πŸŽ‰ Create a branch and make your changes. 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"

  2. ⬆ Create a pull request

  3. πŸš€ Wait for it to be reviewed and merged!

  4. 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

Youtube-DLP

youtube-dlp documentation The most handy part of the documentation: developer instructions on youtube-dlp

All available command line options (yt-dl original): parameters and options

bitrate

YouTube does not currently have support for higher then 192kbps bitrate audio. This is way I've left out the explicit bitrate from the YT-DLP settings, this way, no conversion is being made to a higher pointless bitrate. It will just download the highest, original quality without making an extra conversion. Upscaling does not make a hearable difference, and could, because of the extra conversion, even make the quality slightly worse.

Why upscaling is pointless

thumbnails

Adding thumbnail to the MP3 files: StackOverflow how to After testing, I found that this adds on average about 0.1MB to each MP3 file.

audio quality

'format': 'bestaudio[asr<=44100]/best[asr<=44100]', de prio is links, de beste audio indien beschikbaar en anders de één na hoogste gaat ie downloaden op max 44100 hertz De ASR is belangrijk voor de sample rate, deze mag niet boven de 44100 komen, want dan laden ze niet meer lekker in op de Pioneer CDJ'sample

De 'preferredquality': '192' staat uitgecomment. Omdat het niet relevant is om een bitrate te forceren. Door dat los te laten gebruikt het de sample rate van de orignele audio. Daardoor blijft er meer kwaliteit overe omdat het weer een extra vrij nuttelose conversie scheelt. Het neemt nu gewoon de sample rate van de originele audio over. https://www.h3xed.com/web-and-internet/youtube-audio-quality-bitrate-240p-360p-480p-720p-1080p

test to run still

Er gaan fouten komen denk ik als ik een map zoals Soul|Funk etc... ga doen. want "|" tekens zijn niet beschikabaar op windows voor foldernamen

Environment variables

Om het voor elkaar te krijgen dat ik enviroment variabelen van het OS oppak en in Python code als variabele kan gebruiken. Hiervoor heb ik dit gevolgd: https://able.bio/rhett/how-to-set-and-get-environment-variables-in-python--274rgt5#:~:text=To%20set%20and%20get%20environment%20variables%20in%20Python%20you%20can,Get%20environment%20variables%20USER%20%3D%20os.

Docker

Docker

To get ffmpeg on the image, I installed it on the image directly: ffmpeg for linux ffmpeg source

Docker build and push task for DevOps pipeline: DevOps pipelines