Sign inSign up

giof71/yt-helper

By giof71

Updated over 2 years ago

YouTube Helper

Image
0

2.9K

giof71/yt-helper repository overview

yt-helper

Welcome to yt-helper, a simple YouTube helper tool for downloading from playlists and channels.
The main purpose is make the videos I want to watch available to network shares, media servers, etc, as seamlessly as possible.

DESCRIPTIONLINK
Source CodeGitHub Repo
Docker ImagesDocker Hub

References

This project relies on the following projects:

PROJECTLINK
yt-dlpGitHub Repo
pytubeGitHub Repo
python-slugifyGitHub Repo

Description

This is a simple video downloader, it will rely on pytube and yt-dlp (see References for details).
By defaults, it will monitor the provided playlists and try to download new videos every 300 seconds.
Already downloaded videos will not be downloaded again.

Installation

The preferred way to install the application is via docker. See the Examples section.
Of course, you can start the python application yt-helper.py directly, and/or create a systemd service if you prefer to do so.

Configuration

At the current stage of development, the configuration is done using environment variables and volumes using Docker.

Environment Variables
VARIABLEDESCRIPTION
OUTPUT_PATHOutput directory, it is set to /downloads if you use docker. Otherwise, be sure to set to an appropriate path
DB_FILEDatabase location, it is set to /db/yt.db if you use docker. Otherwise, be sure to set to an appropriate path
PUIDUser id of the user which will run the application, defaults to 1000
PGIDGroup id of the user which will run the application, defaults to 1000
PLAYLIST_LISTComma separated list of the ids of the playlists (which must be public) to be monitored
CHANNEL_NAME_LISTComma separated list of the names of the channels to be monitored
MAX_RESOLUTIONMax resolution used for download, defaults to 1080
FILE_NAME_TEMPLATEVideo file name naming template, defaults to %(uploader)s - %(upload_date>%Y-%m-%d)s - %(title)s [%(id)s].%(ext)s
ENABLE_LOOPEnable loop instead of exiting after the first cycle, defaults to 1
LOOP_WAIT_SECLoop wait time between iterations, in seconds, defaults to 300
OUTPUT_FORMATOutput format of the downloaded file, defaults to mkv (can be overriden at playlist or channel level)
SLUGIFYTransforms the file name to slugified version, defaults to 0
PRINTABLEProcess the filename in order to strip some special characters and reduce potential issues with file name restrictions
DIRECTORY_PER_CHANNELIf set to 1, a directory will be created with the name of channel/uploader, defaults to 0
FULL_DATE_FORMATIf set to 1, the date format in metadata will be yyyy-mm-dd instead of yyyy, defaults to 1

Channels do not currently work (at least before the latest pytube update, which I have not tried yet), because the application always gets an empty list when trying to retrieve the list of video urls.

Playlist format

A playlist can be provided as is (just the id), or along with a colon followed by a date (YYYY-mm-dd format) which will be used as the lower limit for the upload date of the videos.
Example:

PLAYLIST_LIST=PL12345,PL23456

or

PLAYLIST_LIST=PL12345:2023-08-01,PL23456

When a date is specified, only videos published after, and including, the specified date (August 1st 2023 in the example) will be processed for the playlist with id PL12345.
Alternatively, we can use a list of dictionaries, using the separator ";" between playlist property pairs and the separator "=" as the assignment operator. The previous example would become:

PLAYLIST_LIST=id=PL12345;subscription_start=2023-08-01,id=PL23456

This adds the flexibility to specify different properties for each playlist, for future use.

Playlist field keys:
KEYDESCRIPTION
idPlaylist id (mandatory)
subscription_startThe minimum date for download (optional)
output_formatThe desired output format for the playlist (optional)
Channel name format

The considerations made for Playlist Format apply, just replace the playlist id with the channel name.

Channel by name field keys:
KEYDESCRIPTION
nameChannel name (mandatory)
subscription_startThe minimum date for download (optional)
Volumes
VOLUMEDESCRIPTION
/dbLocation for the sqlite database (will be named yt.db)
/downloadsLocation for the downloaded files
Examples

Here is a simple docker compose file. The commented variables are optional.
You will need to replace PLxx1, PLxx2, PLxx3 as well as the channel name(s) with your playlists and/or channel names.

---
version: '3'

services:
  yt-helper:
    container_name: yt-helper
    image: giof71/yt-helper:latest
    volumes:
      - ./db:/db
      - ./downloads:/downloads
    environment:
      - TZ=Europe/Rome
      #- PUID=1000
      #- PGID=1000
      #- LOOP_WAIT_SEC=300
      #- FILE_NAME_TEMPLATE=%(uploader)s - %(upload_date>%Y-%m-%d)s - %(title)s [%(id)s].%(ext)s
      #- DIRECTORY_PER_CHANNEL=0
      - PLAYLIST_LIST=PLxx1,PLxx2,PLxx3
      - CHANNEL_NAME_LIST=ANiceChannel:2023-07-27
    restart: unless-stopped

Tag summary

Content type

Image

Digest

sha256:d8c5f3e2b

Size

253.2 MB

Last updated

over 2 years ago

docker pull giof71/yt-helper