ytdl2rss package

Module contents

Create podcast RSS from youtube-dl info JSON.

The info JSON produced by youtube-dl is not formally specified, although attempts have been made to do so, such as https://github.com/ytdl-org/youtube-dl/pull/21822 Functions in this module expect inputs to follow this proposed schema, although reasonable attempts will be made to accommodate files encountered in practice.

Values which are null or missing will be omitted from RSS output where possible.

class ytdl2rss.YtdlEntry[source]

Bases: YtdlFormat

Type of JSON produced by –write-info-json for a video.

Note: Only includes attributes used in this script.

acodec: NotRequired[str | None]
age_limit: int
description: str
duration: NotRequired[int | float]
ext: str
filesize: NotRequired[int]
formats: list[YtdlFormat]
fulltitle: str
id: str
thumbnail: str
title: str
upload_date: str
vcodec: NotRequired[str | None]
webpage_url: str
class ytdl2rss.YtdlFormat[source]

Bases: TypedDict

Type of formats in JSON produced by –write-info-json for a video.

Note: Only includes attributes used in this script.

acodec: NotRequired[str | None]
ext: str
filesize: NotRequired[int]
vcodec: NotRequired[str | None]
class ytdl2rss.YtdlPlaylist[source]

Bases: TypedDict

Type of JSON produced by –write-info-json for a playlist.

Note: Only includes attributes used in this script.

entries: list[YtdlEntry]
ytdl2rss.entries_to_playlist(entries: list[YtdlEntry]) YtdlPlaylist[source]

Combine youtube-dl entries into a playlist with common metadata.

Parameters:

entries – Entries to combine into a playlist.

Returns:

A playlist with entries from entries.

ytdl2rss.entry_to_rss(entry: YtdlEntry, write: Callable[[str], Any], rss_url: str | None = None, rss_path: str | None = None, indent: str | None = None) None[source]

Convert youtube-dl entry info object to podcast RSS.

Parameters:
  • entry – Entry for which to generate RSS.

  • write – Function called to write RSS data.

  • rss_url – URL of RSS file being written.

  • rss_path – Path to RSS file being written.

  • indent – Indent to apply to each nesting level of RSS.

ytdl2rss.get_entry_media_type(entry: YtdlFormat) str[source]

Get media type (i.e. MIME type) from youtube-dl JSON entry info.

Parameters:

entry – Entry or format for which to get a media type.

Returns:

Media type suitable for entry

ytdl2rss.main(argv: Sequence[str] = ['/home/docs/checkouts/readthedocs.org/user_builds/ytdl2rss/envs/stable/lib/python3.14/site-packages/sphinx/__main__.py', '-T', '-W', '--keep-going', '-j', 'auto', '-b', 'html', '-d', '_build/doctrees', '-D', 'language=en', '.', '/home/docs/checkouts/readthedocs.org/user_builds/ytdl2rss/checkouts/stable/_readthedocs//html']) int[source]

Entry point for command-line use.

Parameters:

argv – command-line arguments (usually sys.argv)

Returns:

exit code

ytdl2rss.playlist_to_rss(playlist: YtdlPlaylist, write: Callable[[str], Any], rss_url: str | None = None, rss_path: str | None = None, indent: str | None = None) None[source]

Convert youtube-dl playlist info object to podcast RSS.

Parameters:
  • playlist – Playlist for which to generate RSS.

  • write – Function called to write RSS data.

  • rss_url – URL of RSS file being written.

  • rss_path – Path to RSS file being written.

  • indent – Indent to apply to each nesting level of RSS.