das-l / youtube-dl-bundle
Symfony 扩展包,提供对 norkunas/youtube-dl-php 的服务注入和配置
1.0.0
2023-05-22 05:54 UTC
Requires
- php: ^7.4 || ^8.0
- norkunas/youtube-dl-php: ^2.1
- symfony/config: ^4.4 || ^5.1
- symfony/dependency-injection: ^4.4 || ^5.1
- symfony/http-kernel: ^4.4 || ^5.1
README
Symfony 扩展包,提供对 norkunas/youtube-dl-php
的服务注入和配置,该包是 youtube-dl 或 yt-dlp 的 PHP 封装。
提供的服务配置
services: # ... das_l_youtube_dl: class: YoutubeDl\YoutubeDl arguments: - '@das_l_youtube_dl.process_builder' - '@das_l_youtube_dl.metadata_reader' - '@filesystem' calls: - setBinPath: ['%das_l_youtube_dl.binPath%'] - setPythonPath: ['%das_l_youtube_dl.pythonPath%'] das_l_youtube_dl.process_builder: class: YoutubeDl\Process\DefaultProcessBuilder das_l_youtube_dl.metadata_reader: class: YoutubeDl\Metadata\DefaultMetadataReader
服务使用
注意:有关库本身的使用更多详情,请查看 norkunas/youtube-dl-php
提供的文档。
services: # ... App\Foo\YouTubeFoo: arguments: - '@das_l_youtube_dl'
<?php namespace App\Foo; use YoutubeDl\Options; use YoutubeDl\YoutubeDl; class YouTubeFoo { private $youtubeDl; public function __construct(YoutubeDl $youtubeDl) { $this->youtubeDl = $youtubeDl; } public function downloadVideo($downloadPath, $url) { $options = Options::create() ->downloadPath($downloadPath) ->url($url) ; $collection = $this->youtubeDl->download($options); // ... } }
配置选项
das_l_youtube_dl: binPath: '/your/custom/bin/path/youtube-dl' pythonPath: '/your/custom/path/for/python'