Skip to content

6. Modifying Your Config for Your Media Player

Jesse Bannon edited this page Aug 4, 2022 · 46 revisions

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.

Displaying Videos as TV Shows

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.

TV Show Structure

Most TV shows follow the same structure, where you have

  1. The TV show itself
  2. Seasons
  3. 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.

Naming TV Show Episode Files

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: "{channel}"
      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: "{tv_show_name_sanitized}/Season {season}/{episode_file_name}"

We 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 to test this out in a dry run.

config.yaml

configuration:
  working_directory: '/tmp/ytdl-sub-downloads'
  dl_aliases:
    video: "--preset yt_video"
    video-url: "--youtube.video_url"
    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:
      output_directory: "/config/first_config/output_videos"
      file_name: "{episode_path}.{ext}"
      thumbnail_name: "{episode_path}-thumb.{thumbnail_ext}"

    overrides:
      tv_show_name: "{channel}"
      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: "{tv_show_name_sanitized}/Season {season}/{episode_file_name}"

  yt_playlist:
    preset: "yt_video"
    youtube:
      download_strategy: "playlist"

  yt_channel:
    preset: "yt_playlist"
    youtube:
      download_strategy: "channel"

  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:
    tv_show_name: "Music Videos"
rick_a_channel:
  preset: "yt_channel_recent"
  youtube:
    channel_url: "https://www.youtube.com/channel/UCuAXFkgsw1L7xaCfnd5JJOw"

Understanding Kodi NFOs

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.