Skip to main content
Open In ColabOpen on GitHub

YoutubeLoaderDL

Loader for Youtube leveraging the yt-dlp library.

This package implements a document loader for Youtube. In contrast to the YoutubeLoader of langchain-community, which relies on pytube, YoutubeLoaderDL is able to fetch YouTube metadata. langchain-yt-dlp leverages the robust yt-dlp library, providing a more reliable and feature-rich YouTube document loader.

Overview

Integration details

ClassPackageLocalSerializableJS Support
YoutubeLoaderlangchain-yt-dlp

Setup

Installation

pip install langchain-yt-dlp

Initialization

from langchain_yt_dlp.youtube_loader import YoutubeLoaderDL

# Basic transcript loading
loader = YoutubeLoaderDL.from_youtube_url(
"https://www.youtube.com/watch?v=dQw4w9WgXcQ", add_video_info=True
)

Load

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 \n\nLyrics:\nWe’re no strangers to love\nYou know the rules and so do I\nA full commitment’s what I’m thinking of\nYou wouldn’t get this from any other guy\n\nI just wanna tell you how I’m feeling\nGotta make you understand\n\nNever gonna give you up\nNever gonna let you down\nNever gonna run around and desert you\nNever gonna make you cry\nNever gonna say goodbye\nNever gonna tell a lie and hurt you\n\nWe’ve known each other for so long\nYour heart’s been aching but you’re too shy to say it\nInside we both know what’s been going on\nWe know the game and we’re gonna play it\n\nAnd if you ask me how I’m feeling\nDon’t tell me you’re too blind to see\n\nNever gonna give you up\nNever gonna let you down\nNever gonna run around and desert you\nNever gonna make you cry\nNever gonna say goodbye\nNever gonna tell a lie and hurt you\n\n#RickAstley #NeverGonnaGiveYouUp #WheneverYouNeedSomebody #OfficialMusicVideo',
'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'}

Lazy Load

  • No lazy loading is implemented

API reference:


Was this page helpful?