-
Notifications
You must be signed in to change notification settings - Fork 76
6. Modifying Your Config for Your Media Player
At this point in the walk-through, we have ytdl-sub
configured to download videos, playlists, or channels, and can place the video and thumbnail files into a desired folder. We can watch them via navigating the file system and opening them in VLC or other desktop video players.
ytdl-sub
was written to support this use-case as well as format videos to watch them in
Kodi,
Jellyfin,
Plex,
Emby,
or any other media player/server.
We have tested Kodi, Jellyfin, and Emby. We do not use Plex, and are unsure how it scrapes custom videos. If you use Plex,
any help would be appreciated
to contribute and test ytdl-sub
to make it work.
Going forward, we will show how to make YouTube videos display as TV shows in Kodi, Jellyfin, and Emby. For simplicity, we will just say Kodi because both Jellyfin and Emby adopted Kodi's NFO metadata structure, and scrape videos in the same manner.
Having YouTube videos display as TV Shows in Kodi is the perfect way to organize them. We can
- Have channels be their own TV show
- Have playlists be their own TV show
- Assign single videos, playlists, or channels to a TV show name we come up with
Our current subscription saves videos to Music Videos/
and Rick's channel's name, Rick Astley/
. Let's make these show as separate TV shows with their respective names.
Most TV shows follow the same structure, where you have
- The TV show itself
- Seasons
- Episodes
We want Music Videos
and Rick Astley
to be their own TV shows. We need to decide how to represent seasons and episodes. What we have found to work well is setting the season to be the year of when the video was uploaded, and the episode to be the month and day combined. Let's create additional override variables in our yt_video
preset to show this in practice.
overrides:
video_name: "{upload_date_standardized}.{title_sanitized}"
video_type: "{channel}"
video_path: "{video_type_sanitized}/{video_name}"
season: "{upload_year}"
episode: "{upload_month}{upload_day_padded}"
We set the season to be {upload_year}
and episode to be {upload_month}{upload_day_padded}
. Why pad the day? Without it, episodes will be out of order. Suppose we have two videos uploaded on 2021-10-04
and 2021-05-23
.
Episodes formatted as {upload_month}{upload_day}
would be
- 104 (October 4th)
- 523 (May 23rd)
The numbers do not have the same ordering as the date - October 4th's episode number should be greater than May 23rd's.
Episodes formatted as {upload_month}{upload_day_padded}
would be
- 1004 (October 4th)
- 523 (May 23rd)
October 4th's episode number is now greater than May 23rd's.
Kodi's TV show file structure is relatively straight forward, it looks like:
TV Shows/
Breaking Bad/
Season 1/
s01e01.Pilot.mp4
Season 2/
...
We need our config to save videos in this format. Let's modify our override variables in the yt_video
preset to have more representative names, and place files in this structure.
overrides:
tv_show_name: "OVERRIDE IN SUBSCRIPTION"
season: "{upload_year}"
episode: "{upload_month}{upload_day_padded}"
episode_padded: "{upload_month_padded}{upload_day_padded}"
episode_file_name: "s{season}e{episode_padded}.{title_sanitized}"
episode_path: "Season {season}/{episode_file_name}"
We created the variable tv_show_name
and set it to an obnoxious capitalized string. We did this for numerous reasons:
- If we had set it to
{channel}
, downloading a playlist containing videos from multiple channels would create many new TV show folders - Channel names are often usernames that are not ideal for TV Show names, like
videogamedunkey
vs explicitly settingDunkey
- When override variables contain source variables within them, they cannot be used in OverridesStringFormatValidators. We will touch on this later.
We also created a new variable called episode_padded
. This is used in episode_file_name
to better order episode files when viewing them in the file system. episode_path
contains our full path for saving the video with the appropriate TV show, season, and episode.
Let's update our config and subscriptions with our new override variable names. We are also going to add a few lines to download channel artwork, and format it so it shows in Kodi. Changed/added lines from our prior config are denoted with a comment above them.
config.yaml
configuration:
working_directory: '/tmp/ytdl-sub-downloads'
dl_aliases:
video: "--preset yt_video"
video-url: "--youtube.video_url"
# changed from video-type: "--overrides.video_type"
tv-show-name: "--overrides.tv_show_name"
single-music-video: "--preset yt_video --overrides.tv_show_name 'Music Video' --youtube.video_url"
presets:
yt_video:
youtube:
download_strategy: "video"
output_options:
# changed from "/config/first_config/output_videos"
output_directory: "/config/first_config/output_videos/{tv_show_name_sanitized}"
# changed from "{video_path}.{ext}"
file_name: "{episode_path}.{ext}"
# changed from "{video_path}.{thumbnail_ext}"
thumbnail_name: "{episode_path}-thumb.{thumbnail_ext}"
overrides:
tv_show_name: "OVERRIDE IN SUBSCRIPTION"
season: "{upload_year}"
episode: "{upload_month}{upload_day_padded}"
episode_padded: "{upload_month_padded}{upload_day_padded}"
episode_file_name: "s{season}e{episode_padded}.{title_sanitized}"
episode_path: "Season {season}/{episode_file_name}"
yt_playlist:
preset: "yt_video"
youtube:
download_strategy: "playlist"
output_options:
maintain_download_archive: True
yt_channel:
preset: "yt_playlist"
youtube:
download_strategy: "channel"
# added: downloads channel avatar and banner to the output directory
channel_avatar_path: "poster.jpg"
channel_banner_path: "fanart.jpg"
yt_channel_recent:
preset: "yt_channel"
youtube:
after: "now-6months"
output_options:
keep_files_after: "now-6months"
subscription.yaml
rick_a_music_video_playlist:
preset: "yt_playlist"
youtube:
playlist_url: "https://www.youtube.com/playlist?list=PLlaN88a7y2_plecYoJxvRFTLHVbIVAOoc"
overrides:
# changed from video_type: "Music Videos"
tv_show_name: "Music Videos"
rick_a_channel:
preset: "yt_channel_recent"
youtube:
channel_url: "https://www.youtube.com/channel/UCuAXFkgsw1L7xaCfnd5JJOw"
# added explicit tv_show_name override
overrides:
tv_show_name: "Rick Astley"
We now use {tv_show_name_sanitized}
in the output_options.output_directory
. This makes it so all file paths within the config are relative to this directory. In addition, any download archive JSON files will now reside in the TV show's respective directory.
If we had set tv_show_name
as {channel}
, our config would raise a validation error. This is because {channel}
is a source variable and output_options.output_directory
cannot use source variables because it needs to be a static string with respect to the subscription. In our docs, any field denoted as a
OverridesStringFormatterValidator
must meet this condition.
We also changed output_options.thumbnail_name
to have -thumb
at the end of the file name. This a Kodi convention for naming thumbnails.
Since we already downloaded our subscriptions and they are maintained by a download archive, we unfortunately have to delete what we have and redownload. Let's do that with
rm -rf /config/first_config/output_videos
Now let's dry run to make sure our config is working as expected.
ytdl-sub --dry-run sub
NFO files
are used to populate the music and video library using locally stored information. For every video we download, we need to create an NFO file to represent it as an episode. ytdl-sub
offers an
NFO plugin
to generate NFOs for each entry.