jmbannon / ytdl-sub

Lightweight tool to automate downloading and metadata generation with yt-dlp
https://ytdl-sub.readthedocs.io
GNU General Public License v3.0
1.58k stars 60 forks source link

how to access metedata that is written to info.json #984

Closed alan-cugler closed 1 month ago

alan-cugler commented 1 month ago

I am trying to parse data from the metadata to use in file naming. For example the default file name for info.json when downloading from youtube is the playlist or video ids. These are great to add to the filename so as to further pull metadata with other programs.

As an example https://github.com/ZeroQI/YouTube-Agent.bundle?tab=readme-ov-file can be used on Plex and saving the ids in the file name like such[youtube-#########] is what it needs.

so ideally I would like to know how to access this meta information for dynamically affecting the directory and file naming conventions

example config samples I am trying to develop. The episode_id: "info_json.id" is really where I am stuck at the moment.

presets:
  youtube_to_plex_tv:
    output_options:
      output_directory: "/media/content/show/{show}/Season {season}"

      # This is the preferred naming convention for plex
      file_name: "{show} - s{season}e{episode} - {title} [youtube-{episode_id}].mp4"
      info_json_name: "{output_directory}/{show} - s{season}e{episode} - {title_sanitized_plex}.info.json"

    overrides:
      show: "{playlist_title} [playlist_uid]"
      season: "{upload_year}"
      episode: "{release_day_of_year_padded}"
      episode_id: "info_json.id"

currently getting this error, but I dont think this isnt directly related to my problem.

$ ytdl-sub sub -l debug
[ytdl-sub] Validating subscriptions...
[ytdl-sub] static formatters must contain variables that have no dependency to entry variables
jmbannon commented 1 month ago

Output directory must be static. Put show and season into the file name vars instead of output directory

jmbannon commented 1 month ago

For accessing info json values, see https://ytdl-sub.readthedocs.io/en/latest/config_reference/scripting/index.html#accessing-info-json-fields

jmbannon commented 1 month ago

Going to close this but still happy to help