YouTube Media Library Server aims to make downloading and updating media libraries easy.
- Download of channels, playlists and videos in mp3 or mp4
- Download of processed files either individually or entire channels and playlists as a .zip
- Update of channels and playlists from the library
- Ingesting folders manually added to downloads folder
- Watching videos via an embed
- Listening to song via an embed
- Search function in library
Currently supported is YouTube but its possible to expand since the download itself is handled by yt-dlp.
To deploy this app, you need a production-ready WSGI server like Waitress. Do not use the Flask built-in development server.
The following works in a 13.2 base jail:
$ git clone https://github.com/maxweigner/yt-mls.git
$ cd yt-mls
$ pkg install python39 py39-pip py39-sqlite3 ffmpeg
$ pip install -r requirements.txt
$ pip install supervisord
$ python -m venv venv
$ source venv/bin/activate.csh
$ pip install -r requirements.txt
$ touch supervisord.conf
Put the following into supervisord.conf
[supervisord]
[program:ytmls]
command=/usr/local/bin/python /root/yt-mls/server.py ;
directory=/root/yt-mls ;
autostart=true ;
autorestart=true ;
Run crontab -e
and add the following line
@reboot /usr/local/bin/supervisord -c /root/yt-mls/supervisord.conf
Restart the jail and you're done.
In server.py
you can change:
PORT
MAX_VIDEO_DOWNLOAD_LENGTH_MINUTES
With the default settings, the server will be up and running on port 5000
and will not download videos longer than 10
minutes.
Having the same video in mp3 and mp4 is not possible with how the download process and database work. This includes channels and playlists. The chosen type on initial download dictates what you have.
Downloading as well as updating large playlists or channels can take hours but does not take up a lot of bandwidth. Updating could be sped up but involves either making an own extractor / crawler or an elaborate construct around the existing one provided by yt-dlp. Currently every item gets crawled even if only a handful of new videos got added.