jmbannon / ytdl-sub

Lightweight tool to automate downloading and metadata generation with yt-dlp

Home Page:https://ytdl-sub.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to implement scripting functions

alan-cugler opened this issue · comments

Hello, I am looking to take a youtube playlist and use the date to break things up into seasons and episodes. I see its suggested to use year as season and months or days as episodes. This works but I would like to make a python script to make standard seasons and episodes that are derived from those dates and cross referenced with the info.json file that is saved with other videos downloaded from the playlist for when the playlist gets updated the program can determine what the latest video should be labeled for season and episode.

example:
video: 2000, 01, 10 --> season: Season 01, Episode 01
video: 2000, 03, 12 --> season: Season 01, Episode 02
video: 2001, 01, 22 --> season: Season 02, Episode 01

I am just not sure how to mark to use a custom python script in the yaml file for dynamically determining a variable.

I use the salt program for managing infrastructure. This is written in python and uses yaml just as this project does. When using that program they use jinja2 for dynamically filling variables and you can reference python scripts to run in that jinja. I see scripting docs for this project were developed, but I wasnt able to translate them into a working example yet.

ytdl-sub scripting does not support arbitrary python. It's a simple custom-built language solely for variable manipulation: https://ytdl-sub.readthedocs.io/en/latest/config_reference/scripting/index.html

You could have a python script that runs after ytdl-sub to do post processing

With your desired example, it'd be hard to achieve solely in ytdl-sub since it requires a bit of state (year to index, ep indexing per year).

The ytdl-sub date presets try to be as stateless as possible to be able to download any slice of time with deterministic season/ep numbers. I highly recommend using those to save some headache