Skip to main content
基于 yt-dlp 库的 YouTube 加载器。 本包为 YouTube 实现了一个文档加载器。与依赖 pytubelangchain-community 中的 YoutubeLoader 相比,YoutubeLoaderDL 能够获取 YouTube 元数据。langchain-yt-dlp 利用强大的 yt-dlp 库,提供更稳定、功能更丰富的 YouTube 文档加载器。

概述

集成详情

本地支持可序列化JS 支持
YoutubeLoaderlangchain-yt-dlp

安装

安装依赖

pip install langchain-yt-dlp

初始化

from langchain_yt_dlp.youtube_loader import YoutubeLoaderDL

# 基本字幕加载
loader = YoutubeLoaderDL.from_youtube_url(
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ", add_video_info=True
)

加载

documents = loader.load()
documents[0].metadata
{'source': 'dQw4w9WgXcQ',
 'title': 'Rick Astley - Never Gonna Give You Up (Official Music Video)',
 'description': 'The official video for "Never Gonna Give You Up" by Rick Astley. \n\nNever: The Autobiography 📚 OUT NOW! \nFollow this link to get your copy and listen to Rick's 'Never' playlist ❤️ #RickAstleyNever\nhttps://linktr.ee/rickastleynever\n\n"Never Gonna Give You Up" was a global smash on its release in July 1987, topping the charts in 25 countries including Rick's native UK and the US Billboard Hot 100.  It also won the Brit Award for Best single in 1988. Stock Aitken and Waterman wrote and produced the track which was the lead-off single and lead track from Rick's debut LP "Whenever You Need Somebody".  The album was itself a UK number one and would go on to sell over 15 million copies worldwide.\n\nThe legendary video was directed by Simon West – who later went on to make Hollywood blockbusters such as Con Air, Lara Croft – Tomb Raider and The Expendables 2.  The video passed the 1bn YouTube views milestone on 28 July 2021.\n\nSubscribe to the official Rick Astley YouTube channel: https://RickAstley.lnk.to/YTSubID\n\nFollow Rick Astley:\nFacebook: https://RickAstley.lnk.to/FBFollowID \nTwitter: https://RickAstley.lnk.to/TwitterID \nInstagram: https://RickAstley.lnk.to/InstagramID \nWebsite: https://RickAstley.lnk.to/storeID \nTikTok: https://RickAstley.lnk.to/TikTokID\n\nListen to Rick Astley:\nSpotify: https://RickAstley.lnk.to/SpotifyID \nApple Music: https://RickAstley.lnk.to/AppleMusicID \nAmazon Music: https://RickAstley.lnk.to/AmazonMusicID \nDeezer: https://RickAstley.lnk.to/DeezerID ',
 'view_count': 1603360806,
 'publish_date': datetime.datetime(2009, 10, 25, 0, 0),
 'length': 212,
 'author': 'Rick Astley',
 'channel_id': 'UCuAXFkgsw1L7xaCfnd5JJOw',
 'webpage_url': 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'}

懒加载

  • 未实现懒加载

API 参考