kesar / php-open-subtitles
phpOpenSubtitles 是一个用于 opensubtitles.org 的 PHP 库
dev-master
2017-05-30 21:09 UTC
Requires
- php: >=5.4.0
- symfony/yaml: >=2.6.6
Requires (Dev)
- phpunit/phpunit: ~4.0
This package is auto-updated.
Last update: 2024-09-11 14:54:05 UTC
README
连接到 opensubtitles.org 的库
示例
-
更新你的 config/configuration.yml.dist,使用来自 Open Subtitles 的登录信息
-
在控制台运行 ``php console.php ```
<?php /** * Example that use SubtitleManager in console * * @author César Rodríguez <kesarr@gmail.com> * @example php console.php <filepath> */ use Symfony\Component\Yaml\Yaml; use OpenSubtitlesApi\SubtitlesManager; use OpenSubtitlesApi\FileGenerator; require_once 'vendor/autoload.php'; $file = $argv[1]; if (empty($file)) { echo 'error! you must supply a file'; return 1; } if (!is_file($file)) { echo 'error! file ' . $file . ' does not exist'; return 1; } $config = Yaml::parse(file_get_contents(__DIR__ . '/config/configuration.yml.dist')); if (empty($config)) { echo 'error! config file does not exist'; return 1; } $manager = new SubtitlesManager($config['username'], $config['password'], $config['language']); $subtitles = $manager->get($file); if (!empty($subtitles) && !empty($subtitles[0])) { $fileGenerator = new FileGenerator(); $fileGenerator->downloadSubtitle($subtitles[0], $file); } else { echo 'error! impossible to find the subtitle'; }