Videodl APIs
This document describes the main public APIs for working with video parsing and downloading in videodl.
It focuses on three parts:
VideoClient: the main high-level entry point.BaseVideoClient: the base class used by site-specific clients.VideoInfo: the result object returned by parsing and downloading methods.
VideoClient
VideoClient is the main class for external use.
It manages multiple video backends, chooses the right parser for a URL, and dispatches downloads to the correct client automatically.
Module path:
videodl.videodl.VideoClient
Constructor:
VideoClient(
allowed_video_sources: list | None = None,
init_video_clients_cfg: dict | None = None,
clients_threadings: dict | None = None,
requests_overrides: dict | None = None,
apply_common_video_clients_only: bool = False,
)
Arguments:
allowed_video_sourcesA list of enabled client names.
If this is
Noneor empty,VideoClientenables all registered clients.Each item should be a client name such as
"AcFunVideoClient".
Example:
allowed_video_sources = ["AcFunVideoClient"]
init_video_clients_cfgPer-client initialization settings.
The key is the client name.
The value is a dictionary of constructor arguments passed to that client.
This is useful when different sources need different work directories, cookies, retry settings, or proxy behavior.
Common options include:
work_dirauto_set_proxiesrandom_update_uamax_retriesmaintain_sessiondisable_printfreeproxy_settingsdefault_search_cookiesdefault_download_cookiesdefault_parse_cookies
Advanced options supported by
BaseVideoClientcan also be passed here, for example:enable_parse_curl_cffienable_search_curl_cffienable_download_curl_cffi
Example:
init_video_clients_cfg = { "SohuVideoClient": { "work_dir": "downloads/sohu", "max_retries": 3, "maintain_session": True, } }
clients_threadingsPer-client download thread counts.
The key is the client name.
The value is the number of download threads for that source.
If a source is not included,
5is used by default.
Example:
clients_threadings = { "XinpianchangVideoClient": 3, }
requests_overridesPer-client request settings used during parsing and downloading.
Typical fields are:
headerscookiesproxies
Example:
requests_overrides = { "TencentVideoClient": { "headers": {"User-Agent": "Mozilla/5.0"}, "cookies": {"sessionid": "example"} } }
apply_common_video_clients_onlyWhether to use only the generic parsers.
False: try platform-specific clients first, then generic parsers if needed.True: skip platform-specific clients and use only common parsers.
This can be useful when the target URL is not from a built-in supported site.
VideoClient.parsefromurl()
Parse a video URL and return one or more VideoInfo objects.
VideoClient.parsefromurl(url: str) -> list[VideoInfo]
Parsing behavior:
When VideoClient.parsefromurl() is called, VideoClient uses the following strategy:
Check whether the URL looks like a direct media link.
If not, try platform-specific clients, unless
apply_common_video_clients_only=True.If still no valid result is found, try generic parsers.
If needed, fall back to the web media grabber.
This logic is internal. In normal use, only a URL needs to be provided.
A single URL may return:
one item for a normal video,
multiple items for multi-part content,
or an empty result if parsing fails.
Example:
from videodl.videodl import VideoClient
client = VideoClient(
allowed_video_sources=["AcFunVideoClient"],
requests_overrides={
"AcFunVideoClient": {
"headers": {"User-Agent": "Mozilla/5.0"}
}
}
)
video_infos = client.parsefromurl("https://www.acfun.cn/v/ac123456")
for info in video_infos:
print(info.title)
print(info.source)
print(info.download_url)
print(info.save_path)
VideoClient.download()
Download parsed videos.
VideoClient.download(video_infos: list[VideoInfo]) -> list[VideoInfo]
VideoClient automatically groups items by source and sends them to the correct underlying client.
Notes:
video_infosshould usually be the output ofVideoClient.parsefromurl().Thread counts come from
clients_threadings.Request settings come from
requests_overrides.
Example:
video_infos = client.parsefromurl("https://www.acfun.cn/v/ac123456")
client.download(video_infos)
VideoClient.startparseurlcmdui()
Start the interactive terminal UI.
VideoClient.startparseurlcmdui() -> None
In this mode, the program repeatedly asks for a video URL, parses it, and downloads the result.
Special inputs:
q: quitr: restart
This is mainly for command-line use.
BaseVideoClient
BaseVideoClient is the base class for all site-specific clients.
Module path:
videodl.modules.sources.BaseVideoClient
Examples of subclasses include clients such as,
videodl.modules.sources.ABCVideoClientvideodl.modules.sources.AcFunVideoClientvideodl.modules.sources.ArteTVVideoClientvideodl.modules.sources.BaiduTiebaVideoClientvideodl.modules.sources.BeaconVideoClientvideodl.modules.sources.BilibiliVideoClientvideodl.modules.sources.C56VideoClientvideodl.modules.sources.CCCVideoClientvideodl.modules.sources.CCTVVideoClientvideodl.modules.sources.CCtalkVideoClientvideodl.modules.sources.DongchediVideoClientvideodl.modules.sources.DouyinVideoClientvideodl.modules.sources.DuxiaoshiVideoClientvideodl.modules.sources.EyepetizerVideoClientvideodl.modules.sources.FoxNewsVideoClientvideodl.modules.sources.GeniusVideoClientvideodl.modules.sources.HaokanVideoClientvideodl.modules.sources.HuyaVideoClientvideodl.modules.sources.IQiyiVideoClientvideodl.modules.sources.KakaoVideoClientvideodl.modules.sources.KanKanNewsVideoClientvideodl.modules.sources.Ku6VideoClientvideodl.modules.sources.KuaishouVideoClientvideodl.modules.sources.KugouMVVideoClientvideodl.modules.sources.LeshiVideoClientvideodl.modules.sources.M1905VideoClientvideodl.modules.sources.MGTVVideoClientvideodl.modules.sources.MeipaiVideoClientvideodl.modules.sources.OasisVideoClientvideodl.modules.sources.Open163VideoClientvideodl.modules.sources.PearVideoClientvideodl.modules.sources.PipigaoxiaoVideoClientvideodl.modules.sources.PipixVideoClientvideodl.modules.sources.PlayerPLVideoClientvideodl.modules.sources.PlusFIFAVideoClientvideodl.modules.sources.RedditVideoClientvideodl.modules.sources.RednoteVideoClientvideodl.modules.sources.SinaVideoClientvideodl.modules.sources.SixRoomVideoClientvideodl.modules.sources.SohuVideoClientvideodl.modules.sources.TBNUKVideoClientvideodl.modules.sources.TedVideoClientvideodl.modules.sources.TencentVideoClientvideodl.modules.sources.UnityVideoClientvideodl.modules.sources.WWEVideoClientvideodl.modules.sources.WeSingVideoClientvideodl.modules.sources.WeiboVideoClientvideodl.modules.sources.WeishiVideoClientvideodl.modules.sources.WittyTVVideoClientvideodl.modules.sources.XiguaVideoClientvideodl.modules.sources.XinpianchangVideoClientvideodl.modules.sources.XuexiCNVideoClientvideodl.modules.sources.YinyuetaiVideoClientvideodl.modules.sources.YoukuVideoClientvideodl.modules.sources.YouTubeVideoClientvideodl.modules.sources.ZhihuVideoClientvideodl.modules.sources.ZuiyouVideoClient…
videodl.modules.common.AnyFetcherVideoClientvideodl.modules.common.BVVideoClientvideodl.modules.common.BugPkVideoClientvideodl.modules.common.GVVIPVideoClientvideodl.modules.common.GVVideoClientvideodl.modules.common.IIILabVideoClientvideodl.modules.common.IM1907VideoClientvideodl.modules.common.JXM3U8VideoClientvideodl.modules.common.KIT9VideoClientvideodl.modules.common.KedouVideoClientvideodl.modules.common.KuKuToolVideoClientvideodl.modules.common.LongZhuVideoClientvideodl.modules.common.LvlongVideoClientvideodl.modules.common.MiZhiVideoClientvideodl.modules.common.NoLogoVideoClientvideodl.modules.common.ODwonVideoClientvideodl.modules.common.PVVideoClientvideodl.modules.common.QZXDPToolsVideoClientvideodl.modules.common.QingtingVideoClientvideodl.modules.common.QwkunsVideoClientvideodl.modules.common.RayVideoClientvideodl.modules.common.SENJiexiVideoClientvideodl.modules.common.SnapAnyVideoClientvideodl.modules.common.SnapWCVideoClientvideodl.modules.common.SpapiVideoClientvideodl.modules.common.VgetVideoClientvideodl.modules.common.VideoFKVideoClientvideodl.modules.common.WoofVideoClientvideodl.modules.common.XCVTSVideoClientvideodl.modules.common.XMFlvVideoClientvideodl.modules.common.XZDXVideoClientvideodl.modules.common.XiaolvfangVideoClientvideodl.modules.common.XiazaitoolVideoClientvideodl.modules.common.ZanqianbaVideoClient…
In most cases, external users do not create BaseVideoClient directly. Instead, they either:
use
VideoClient, oruse a concrete subclass built on top of
BaseVideoClient.
Constructor:
BaseVideoClient(
auto_set_proxies: bool = False,
random_update_ua: bool = False,
enable_parse_curl_cffi: bool = False,
enable_search_curl_cffi: bool = False,
enable_download_curl_cffi: bool = False,
max_retries: int = 5,
maintain_session: bool = False,
logger_handle = None,
disable_print: bool = False,
work_dir: str = "videodl_outputs",
freeproxy_settings: dict | None = None,
default_search_cookies: dict | None = None,
default_download_cookies: dict | None = None,
default_parse_cookies: dict | None = None,
)
Arguments:
auto_set_proxiesAutomatically fetch and apply proxies for requests. Use this when a source frequently blocks direct requests.
random_update_uaRandomly refresh the
User-Agentwhen a new session is created. This can help reduce repeated identical requests.enable_parse_curl_cffiUse
curl_cffisessions instead of normalrequestssessions for parsing. This option is useful for some sites with stricter request checks.enable_search_curl_cffiUse
curl_cffisessions instead of normalrequestssessions for searching. This option is useful for some sites with stricter request checks.enable_download_curl_cffiUse
curl_cffisessions instead of normalrequestssessions for downloading. This option is useful for some sites with stricter request checks.max_retriesMaximum number of retries for HTTP requests.
maintain_sessionWhether to reuse the same HTTP session across requests.
False: recreate the session more often.True: keep cookies and session state between requests.
logger_handleOptional logger instance. If not provided, a default logger is created.
disable_printWhether to suppress console output.
work_dirRoot directory for outputs.
freeproxy_settingsOptional settings for the proxy client used when
auto_set_proxies=True.default_search_cookiesDefault cookies used for search. This is helpful for sites that require login cookies or other session information.
default_download_cookiesDefault cookies used for download. This is helpful for sites that require login cookies or other session information.
default_parse_cookiesDefault cookies used for parse. This is helpful for sites that require login cookies or other session information.
BaseVideoClient.parsefromurl()
Parse a URL and return VideoInfo objects.
BaseVideoClient.parsefromurl(url: str, request_overrides: dict | None = None) -> list[VideoInfo]
This method is defined by subclasses. BaseVideoClient itself only provides the interface.
request_overrides usually contains request-related fields such as:
headerscookiesproxies
Each returned VideoInfo should normally include at least:
sourcedownload_urlsave_path
A typical subclass may also fill fields such as:
titleidentifiercover_urlraw_dataerr_msg
Example:
video_infos = some_client.parsefromurl(
"https://example.com/video/123",
request_overrides={
"headers": {"User-Agent": "Mozilla/5.0"},
"cookies": {"sessionid": "example"},
},
)
BaseVideoClient.download()
Download one or more videos.
BaseVideoClient.download(
video_infos: list[VideoInfo],
num_threadings: int = 5,
request_overrides: dict | None = None,
) -> list[VideoInfo]
This method handles concurrency and chooses the actual download strategy automatically.
Depending on the data in each VideoInfo, the downloader may use:
normal HTTP download,
ffmpeg,N_m3u8DL-RE,aria2c,separate video/audio download followed by merge.
Returns:
a list of successfully downloaded
VideoInfoobjects.
Example:
downloaded = some_client.download(video_infos, num_threadings=3)
for item in downloaded:
print(item.save_path)
BaseVideoClient.belongto()
Check whether a URL belongs to a given source.
BaseVideoClient.belongto(url: str, valid_domains: list[str] | set[str] | None = None) -> bool
This is mainly a helper for client implementations, but it can also be useful when building custom routing logic.
Example:
BaseVideoClient.belongto(
"https://www.acfun.cn/v/ac123456",
valid_domains={"acfun.cn"},
)
# True
Request helpers for subclass implementations
BaseVideoClient also provides retry-enabled request helpers:
get(url, **kwargs)post(url, **kwargs)
These methods are mainly intended for subclass authors, not for normal end users.
VideoInfo
VideoInfo is the core data object returned by parsing methods and consumed by download methods.
It behaves like both:
an object, for example
info.title,and a dictionary, for example
info["title"].
Common fields:
source: client name, such as"AcFunVideoClient"title: video titlecover_url: cover image URL if availableraw_data: original parsed dataerr_msg: error message if parsing failedidentifier: unique ID for the videodownload_url: main video download URL or local intermediate filesave_path: output file pathext: output file extensiondefault_download_headers: optional per-item headersdefault_download_cookies: optional per-item cookiesaudio_download_urlaudio_save_pathaudio_extdefault_audio_download_headersdefault_audio_download_cookiesdownload_with_ffmpegenable_nm3u8dlredownload_with_aria2cffmpeg_settingsnm3u8dlre_settingsaria2c_settings
Useful properties:
with_valid_download_url:Returns
Truewhen the main download URL is valid.with_valid_audio_download_urlReturns
Truewhen the audio download URL is valid.
Example:
{
"source": "AcFunVideoClient",
"title": "Example Video",
"download_url": "https://example.com/video.m3u8",
"save_path": "videodl_outputs/AcFunVideoClient/Example Video.mp4",
"ext": "mp4",
"identifier": "ac123456"
}