{"id":16761191,"url":"https://github.com/norkunas/youtube-dl-php","last_synced_at":"2025-05-14T06:13:29.915Z","repository":{"id":29516376,"uuid":"33054763","full_name":"norkunas/youtube-dl-php","owner":"norkunas","description":"A PHP wrapper for youtube-dl or yt-dlp.","archived":false,"fork":false,"pushed_at":"2025-02-21T05:24:44.000Z","size":436,"stargazers_count":479,"open_issues_count":12,"forks_count":159,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-04-08T23:11:18.153Z","etag":null,"topics":["php","youtube-dl","yt-dlp"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/norkunas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2015-03-28T23:45:48.000Z","updated_at":"2025-04-04T17:26:35.000Z","dependencies_parsed_at":"2023-12-27T07:28:58.868Z","dependency_job_id":"076c46c5-2dc8-4019-8a1b-88bd8f654c0e","html_url":"https://github.com/norkunas/youtube-dl-php","commit_stats":{"total_commits":213,"total_committers":14,"mean_commits":"15.214285714285714","dds":0.07511737089201875,"last_synced_commit":"173d5e4528cf55dcb6027869f5b9de8154330474"},"previous_names":[],"tags_count":47,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/norkunas%2Fyoutube-dl-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/norkunas%2Fyoutube-dl-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/norkunas%2Fyoutube-dl-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/norkunas%2Fyoutube-dl-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/norkunas","download_url":"https://codeload.github.com/norkunas/youtube-dl-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248314083,"owners_count":21082978,"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":["php","youtube-dl","yt-dlp"],"created_at":"2024-10-13T04:41:58.106Z","updated_at":"2025-04-10T23:27:23.282Z","avatar_url":"https://github.com/norkunas.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Youtube-dl PHP\nA PHP wrapper for [youtube-dl](https://github.com/ytdl-org/youtube-dl) or [yt-dlp](https://github.com/yt-dlp/yt-dlp).\n\n[![Latest Stable Version](https://poser.pugx.org/norkunas/youtube-dl-php/v/stable.svg)](https://packagist.org/packages/norkunas/youtube-dl-php)\n[![Latest Unstable Version](https://poser.pugx.org/norkunas/youtube-dl-php/v/unstable.svg)](https://packagist.org/packages/norkunas/youtube-dl-php)\n[![Total Downloads](https://poser.pugx.org/norkunas/youtube-dl-php/downloads)](https://packagist.org/packages/norkunas/youtube-dl-php)\n![CI Status](https://github.com/norkunas/youtube-dl-php/workflows/CI/badge.svg?branch=master)\n[![License](https://poser.pugx.org/norkunas/youtube-dl-php/license.svg)](https://packagist.org/packages/norkunas/youtube-dl-php)\n\n## Install\nFirst step is to download the [youtube-dl](https://ytdl-org.github.io/youtube-dl/download.html) or [yt-dlp](https://github.com/yt-dlp/yt-dlp#installation).\n\nSecond step is to install the wrapper using [Composer](http://getcomposer.org/):\n```\ncomposer require norkunas/youtube-dl-php:dev-master\n```\n\n## Download video\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nrequire __DIR__ . '/vendor/autoload.php';\n\nuse YoutubeDl\\Options;\nuse YoutubeDl\\YoutubeDl;\n\n$yt = new YoutubeDl();\n\n$collection = $yt-\u003edownload(\n    Options::create()\n        -\u003edownloadPath('/path/to/downloads')\n        -\u003eurl('https://www.youtube.com/watch?v=oDAw7vW7H0c')\n);\n\nforeach ($collection-\u003egetVideos() as $video) {\n    if ($video-\u003egetError() !== null) {\n        echo \"Error downloading video: {$video-\u003egetError()}.\";\n    } else {\n        echo $video-\u003egetTitle(); // Will return Phonebloks\n        // $video-\u003egetFile(); // \\SplFileInfo instance of downloaded file\n    }\n}\n\n```\n\n## Download only audio (requires ffmpeg or avconv and ffprobe or avprobe)\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nrequire __DIR__ . '/vendor/autoload.php';\n\nuse YoutubeDl\\Options;\nuse YoutubeDl\\YoutubeDl;\n\n$yt = new YoutubeDl();\n$collection = $yt-\u003edownload(\n    Options::create()\n        -\u003edownloadPath('/path/to/downloads')\n        -\u003eextractAudio(true)\n        -\u003eaudioFormat('mp3')\n        -\u003eaudioQuality('0') // best\n        -\u003eoutput('%(title)s.%(ext)s')\n        -\u003eurl('https://www.youtube.com/watch?v=oDAw7vW7H0c')\n);\n\nforeach ($collection-\u003egetVideos() as $video) {\n    if ($video-\u003egetError() !== null) {\n        echo \"Error downloading video: {$video-\u003egetError()}.\";\n    } else {\n        $video-\u003egetFile(); // audio file\n    }\n}\n```\n\n## Download progress\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nrequire __DIR__ . '/vendor/autoload.php';\n\nuse YoutubeDl\\YoutubeDl;\n\n$yt = new YoutubeDl();\n$yt-\u003eonProgress(static function (?string $progressTarget, string $percentage, string $size, string $speed, string $eta, ?string $totalTime): void {\n    echo \"Download file: $progressTarget; Percentage: $percentage; Size: $size\";\n    if ($speed) {\n        echo \"; Speed: $speed\";\n    }\n    if ($eta) {\n        echo \"; ETA: $eta\";\n    }\n    if ($totalTime !== null) {\n        echo \"; Downloaded in: $totalTime\";\n    }\n});\n```\n\n## Custom Process Instantiation\n\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nnamespace App\\YoutubeDl;\n\nuse Symfony\\Component\\Process\\Process;\nuse YoutubeDl\\Process\\ProcessBuilderInterface;\n\nclass ProcessBuilder implements ProcessBuilderInterface\n{\n    public function build(?string $binPath, ?string $pythonPath, array $arguments = []): Process\n    {\n        $process = new Process([$binPath, $pythonPath, ...$arguments]);\n        // Set custom timeout or customize other things..\n        $process-\u003esetTimeout(60);\n\n        return $process;\n    }\n}\n```\n\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nuse App\\YoutubeDl\\ProcessBuilder;\nuse YoutubeDl\\YoutubeDl;\n\n$processBuilder = new ProcessBuilder();\n\n// Provide your custom process builder as the first argument.\n$yt = new YoutubeDl($processBuilder);\n```\n\n\n## Questions?\n\nIf you have any questions please [open a discussion](https://github.com/norkunas/youtube-dl-php/discussions/new).\n\n## License\n\nThis library is released under the MIT License. See the bundled [LICENSE](https://github.com/norkunas/youtube-dl-php/blob/master/LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnorkunas%2Fyoutube-dl-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnorkunas%2Fyoutube-dl-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnorkunas%2Fyoutube-dl-php/lists"}