{"id":22165243,"url":"https://github.com/hexer10/youtube_explode_dart","last_synced_at":"2025-05-15T03:05:28.084Z","repository":{"id":36987872,"uuid":"241964664","full_name":"Hexer10/youtube_explode_dart","owner":"Hexer10","description":"Dart library to interact with many Youtube APIs","archived":false,"fork":false,"pushed_at":"2025-04-08T10:22:43.000Z","size":1263,"stargazers_count":351,"open_issues_count":37,"forks_count":151,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-05-12T05:50:06.341Z","etag":null,"topics":["api","audio","closed-captions","dart","download","muxed-streams","playlists","video","video-metadata","youtube","youtubeexplode"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/youtube_explode_dart","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Hexer10.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"Hexer10","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2020-02-20T18:54:30.000Z","updated_at":"2025-05-11T20:04:09.000Z","dependencies_parsed_at":"2023-01-17T12:30:42.422Z","dependency_job_id":"98edd6a4-1563-427f-a71d-9bd2d21bf9ac","html_url":"https://github.com/Hexer10/youtube_explode_dart","commit_stats":{"total_commits":401,"total_committers":18,"mean_commits":22.27777777777778,"dds":"0.33665835411471323","last_synced_commit":"699208f1383b547f661fb495e1b3970ecf290634"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hexer10%2Fyoutube_explode_dart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hexer10%2Fyoutube_explode_dart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hexer10%2Fyoutube_explode_dart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hexer10%2Fyoutube_explode_dart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Hexer10","download_url":"https://codeload.github.com/Hexer10/youtube_explode_dart/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254264765,"owners_count":22041793,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","audio","closed-captions","dart","download","muxed-streams","playlists","video","video-metadata","youtube","youtubeexplode"],"created_at":"2024-12-02T05:14:15.016Z","updated_at":"2025-05-15T03:05:28.032Z","avatar_url":"https://github.com/Hexer10.png","language":"Dart","funding_links":["https://github.com/sponsors/Hexer10"],"categories":[],"sub_categories":[],"readme":"# YoutubeExplodeDart\nThis is a port of the [YoutubeExplode] library from C#, most of the functions, doc comments, readme information, is taken from YoutubeExplode repository.\n\n![Pub Version](https://img.shields.io/pub/v/youtube_explode_dart)\n![License](https://img.shields.io/github/license/Hexer10/youtube_explode_dart)\n![Lint](https://img.shields.io/badge/style-lint-4BC0F5.svg)\n\nIt used to build [Youtube Downloader Flutter](https://github.com/Hexer10/youtube_downloader_flutter) (A cross-platform application to download video streams from youtube using this library \u0026 flutter)\n\n---\n\nYoutubeExplode is a library that provides an interface to query metadata of YouTube videos, playlists and channels, as well as to resolve and download video streams and closed caption tracks. Behind a layer of abstraction, the library parses raw page content and uses reverse-engineered AJAX requests to retrieve information. As it doesn't use the official API, there's also no need for an API key and there are no usage quotas.\n\n## Features\n\n- Retrieve metadata on videos, playlists, channels, streams, and closed captions\n- Execute search queries and get resulting videos.\n- Get or download video streams.\n- Get closed captions.\n- Get video comments.\n\n## Usage\n- [Install](#install)\n- [Downloading a video stream](#downloading-a-video-stream)\n- [Working with playlists](#working-with-playlists)\n- [Extracting closed captions](#extracting-closed-captions)\n- [Getting comments](#get-comments)\n- [Cleanup](#cleanup)\n- [Before reporting an issue](#troubleshooting)\n\n### Install\n\nAdd the dependency to the pubspec.yaml (Check for the latest version)\n```yaml\nyoutube_explode_dart: ^2.3.4\n```\n\nImport the library\n```dart\nimport 'package:youtube_explode_dart/youtube_explode_dart.dart';\n```\n\n### Getting metadata of a video\n The following example shows how you can extract various metadata from a YouTube video:\n\n```dart\n// You can provide either a video ID or URL as String or an instance of `VideoId`.\nvar video = yt.videos.get('https://youtube.com/watch?v=Dpp1sIL1m5Q'); // Returns a Video instance.\n\nvar title = video.title; // \"Scamazon Prime\"\nvar author = video.author; // \"Jim Browning\"\nvar duration = video.duration; // Instance of Duration - 0:19:48.00000\n```\n\n### Downloading a video stream\nEvery YouTube video has a number of streams available. These streams may have different containers, video quality, bitrate, etc.\n\nOn top of that, depending on the content of the stream, the streams are further divided into 3 categories:\n- Muxed streams -- contain both video and audio (available only in 360p)\n- Audio-only streams -- contain only audio\n- Video-only streams -- contain only video\n\nYou can request the stream manifest to get available streams for a particular video:\n\n\n```dart\nvar yt = YoutubeExplode();\n\nvar manifest = yt.videos.streams.getManifest('Dpp1sIL1m5Q');\n\nprint(manifest); // Prints the list of streams available for the video.\n\n// If you want to specify which youtube clients to use to get the manifest you can do so:\nvar manifest = yt.videos.streams.getManifest(videoId, ytClients: [\n  YoutubeApiClient.safari,\n  YoutubeApiClient.androidVr  \n]); // The streams provided by both clients will be merged.\n```\n\nOnce you get the manifest, you can filter through the streams and choose the one you're interested in downloading:\n\n```dart\n// highest bitrate audio-only stream\nvar streamInfo = streamManifest.audioOnly.withHigestBitrate();\n\n// MP4 video-only stream\nvar streamInfo.videoOnly.where((e) =\u003e e.container == Container);\n\n// Muxed (audio + video) stream with the highest video quality. NOTE: Don't rely on this, muxed streams are limited to 360p30.\nvar streamInfo = streamManifest.muxed.withHigestVideoQuality();\n\n// HLS (m3u8) streams are also supported\nvar streamInfo = streamManifest.hls;\n```\n\nFinally, you can get the actual `Stream` object represented by the metadata:\n\n```dart\n// Get the actual byte stream\nvar stream = yt.video.streams.get(streamInfo);\n\n// Open a file for writing.\nvar file = File(filePath);\nvar fileStream = file.openWrite();\n\n// Pipe all the content of the stream into the file.\nawait stream.pipe(fileStream);\n\n// Close the file.\nawait fileStream.flush();\nawait fileStream.close();\n```\n\nWhile it may be tempting to just always use muxed streams, it's important to note that they are limited in quality. **Muxed streams don't go beyond 360p30.**\n\nIf you want to download the video in maximum quality, you need to download the audio-only and video-only streams separately and then mux them together on your own. There are tools like FFmpeg that let you do that.\n\n### Working with playlists\nAmong other things, YoutubeExplode also supports playlists:\n```dart\nvar yt = YoutubeExplode();\n\n// Get playlist metadata.\nvar playlist = await yt.playlists.get('xxxxx');\n\nvar title = playlist.title;\nvar author = playlist.author;\n\n  await for (var video in yt.playlists.getVideos(playlist.id)) {\n    var videoTitle = video.title;\n    var videoAuthor = video.author;\n  }\n\nvar playlistVideos = await yt.playlists.getVideos(playlist.id);\n\n// Get first 20 playlist videos.\nvar somePlaylistVideos = await yt.playlists.getVideos(playlist.id).take(20);\n```\n\n### Extracting closed captions\nSimilarly, to streams, you can extract closed captions by getting the manifest and choosing the track you're interested in:\n\n```dart\n  var yt = YoutubeExplode();\n\n  var trackManifest = await yt.videos.closedCaptions.getManifest('_QdPW8JrYzQ')\n\n  var trackInfo = manifest.getByLanguage('en'); // Get english caption.\n  \n  if (trackInfo != null)\n  {\n     // Get the actual closed caption track.\n     var track = await youtube.videos.closedCaptions.get(trackInfo);\n      \n    // Get the caption displayed at 1:01\n    var caption = track.getByTime(Duration(seconds: 61));\n    var text = caption?.text; // \"And the game was afoot.\"\n  }\n```\n\n#### Get a list of related videos\n```dart\nvar video = yt.videos.get('https://youtube.com/watch?v=Dpp1sIL1m5Q');\nvar relatedVideos = await yt.videos.getRelatedVideos(video); // video must be a Video instance.\nprint(relatedVideos); //prints the list of related videos\n\n// to get the next page of related videos\nrelatedVideos = await relatedVideos.nextPage();\n```\n\nIf no related video is found `getRelatedVideos` or `nextPage` will return null.\n\n\n### Get comments\nYou can easily get the video comments of a given video, the return value of `comments.getComments(video)` is a list-like object which behaves exactly like a `List` but has an additional method `nextPage()` which is used in order to get the next comments, it returns null when there are no comments to be fetched anymore.\n\n```dart\nvar comments = await yt.videos.comments.getComments(video);\n\nvar replies = await yt.videos.comments.getReplies(comment); // Fetch the comment replies \n```\n\n\n### Cleanup\nYou need to close `YoutubeExplode`'s http client, when done otherwise this could halt the dart process.\n\n\n```dart\nyt.close();\n```\n\n### Troubleshooting\nIf you encounter any issues, please check that it has not been reported already in the [issues section](Issue).\n\nWhen reporting a new issue, make sure to follow the issue template and report the logs after having enabled the logging:\n```dart\nimport 'package:logging/logging.dart';\n\n...\n\n// Before any YoutubeExplode code\nLogger.root.level = Level.FINER;\nLogger.root.onRecord.listen((e)  {\n  print(e);\n  if (e.error != null) {\n   print(e.error);\n   print(e.stackTrace);\n  }\n});\n```\n\nTo the very minimum the video id causing the issue (if applicable) and the code snippet that is causing the issue must be provided.\n\n### Examples:\n\nMore examples available on [GitHub][Examples].\n\n---\n\n\nCheck the [api documentation][API] for additional information.\nYou can find how most APIs can be used in the files inside the test/ folder. \n\n### Credits\n\n- [Tyrrrz] for creating [YoutubeExplode] in C#\n- [Hexer10] (me) who ported the library over to Dart.\n- [EnsembleUI] for the jsparser project.\n- [yt-dlp] for documentation and reverse engineering about the YouTube apis.\n- All the [Contributors] of this repository.\n\n[YoutubeExplode]: https://github.com/Tyrrrz/YoutubeExplode/\n[API]: https://pub.dev/documentation/youtube_explode_dart/latest/youtube_explode/youtube_explode-library.html\n[Examples]: https://github.com/Hexer10/youtube_explode_dart/tree/master/example\n[Tyrrrz]: https://github.com/Tyrrrz/\n[Hexer10]: https://github.com/Hexer10/\n[Contributors]: https://github.com/Hexer10/youtube_explode_dart/graphs/contributors\n[EnsembleUI]: https://github.com/EnsembleUI\n[Issue]: https://github.com/Hexer10/youtube_explode_dart/issues\n[yt-dlp]: https://github.com/yt-dlp/yt-dlp\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhexer10%2Fyoutube_explode_dart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhexer10%2Fyoutube_explode_dart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhexer10%2Fyoutube_explode_dart/lists"}