sorshion/youtube-downloader
Composer 安装命令:
composer require sorshion/youtube-downloader
包简介
PHP powered alternative for youtube-dl
README 文档
README
This project was inspired by a very popular youtube-dl python package:
https://github.com/ytdl-org/youtube-dl
Yes, there are multiple other PHP-based youtube downloaders on the Internet, but most of them haven't been updated in years, or they depend on youtube-dl itself.
Pure PHP-based youtube downloaders that work, and are kept-up-to date just do not exist.
This script uses no Javascript interpreters, no calls to shell... nothing but pure PHP with no heavy dependencies either.
That's all there is to it!
⚠️ Legal Disclaimer
This program is for personal use only. Downloading copyrighted material without permission is against YouTube's terms of services. By using this program, you are solely responsible for any copyright violations. We are not responsible for people who attempt to use this program in any way that breaks YouTube's terms of services.
Installation
Recommended way of installing this is via Composer:
composer require sorshion/youtube-downloader "^1.0"
Example usage
use Sorshion\YouTube\YouTubeDownloader; use Sorshion\YouTube\Exception\YouTubeException; $youtube = new YouTubeDownloader(); try { $downloadOptions = $youtube->getDownloadLinks("https://www.youtube.com/watch?v=aqz-KE-bpKQ"); if ($downloadOptions->getAllFormats()) { echo $downloadOptions->getFirstCombinedFormat()->url; } else { echo 'No links found'; } } catch (YouTubeException $e) { echo 'Something went wrong: ' . $e->getMessage(); }
getDownloadLinks method returns a DownloadOptions type object, which holds an array of stream links - some that are audio-only, and some that are both audio and video combined into one.
For typical usage, you are probably interested in dealing with combined streams, for that case, there is the getCombinedFormats method.
Other Features
- Stream YouTube videos directly from your server:
$youtube = new \Sorshion\YouTube\YouTubeStreamer(); $youtube->stream('https://r4---sn-n4v7knll.googlevideo.com/videoplayback?...');
- Pass in your own cookies/user-agent
If you try downloading age-restricted videos, YouTube will ask you to login. The only way to make this work, is to login to your YouTube account in your own web-browser, export those newly set cookies from your browser into a file, and then pass it all to youtube-downloader for use.
$youtube = new YouTubeDownloader(); $youtube->getBrowser()->setCookieFile('./your_cookies.txt'); $youtube->getBrowser()->setUserAgent('Opera 7.6');
See also:
https://github.com/ytdl-org/youtube-dl/blob/master/README.md#how-do-i-pass-cookies-to-youtube-dl
- Before you continue to YouTube...
Depending on your region, you might be force redirected to a page that asks you to agree to Google's cookie policy.
You can programmatically agree to those terms, and bypass that warning permanently via consentCookies method on your Browser instance. Example:
$youtube = new YouTubeDownloader(); $youtube->getBrowser()->consentCookies();
How does it work
A more detailed explanation on how to download videos from YouTube will be written soon. For now, there is this:
Miscellaneous Links
- https://gitlab.futo.org/videostreaming/plugins/youtube
- https://tyrrrz.me/blog/reverse-engineering-youtube-revisited
- https://github.com/TeamNewPipe/NewPipeExtractor/blob/d83787a5ca308c4ca4e86e63a8b63c5e7c4708d6/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java
- https://github.com/ytdl-org/youtube-dl/blob/master/youtube_dl/extractor/youtube.py
- https://github.com/yt-dlp/yt-dlp
To-do list
- Allow downloading of private videos.
- Find a way to get around YouTube's throttling system that limits downloading speed to less than 100 kb/s for most most videos now...
- Add ability to solve YouTube Captcha and avoid
HTTP 429 Too Many Requestserrors. - Add ability to download video and audio streams separately, and merge the two together using ffmpeg. Just like
youtube-dldoes! - Optional command that finds ALL video formats.
Fetch additional metadata about the video without using YouTube API.
sorshion/youtube-downloader 适用场景与选型建议
sorshion/youtube-downloader 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 99 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 03 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「youtube downloader」 「download youtube」 「download youtube videos」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sorshion/youtube-downloader 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sorshion/youtube-downloader 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sorshion/youtube-downloader 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Easy to use SDK with grabber for multiple platforms at once like YouTube, Dailymotion, Facebook and more.
The NzoFileDownloaderBundle is a Symfony Bundle used to Download all types of files from servers and Web applications safely and with ease. You can also read/show the file content in the Web Browser.
Adds a download link next to assets
PHP powered alternative for youtube-dl
Utility for downloading Microsoft Edge Driver binary with browser version detection
Downloader Library
统计信息
- 总下载量: 99
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-03-13