kesar / php-open-subtitles
phpOpenSubtitles is a PHP library for opensubtitles.org
Installs: 127
Dependents: 0
Suggesters: 0
Security: 0
Stars: 24
Watchers: 4
Forks: 12
Open Issues: 2
Requires
- php: >=5.4.0
- symfony/yaml: >=2.6.6
Requires (Dev)
- phpunit/phpunit: ~4.0
This package is auto-updated.
Last update: 2025-03-11 15:50:06 UTC
README
Library to connect with opensubtitles.org
Example
-
Update your config/configuration.yml.dist with login from Open Subtitles
-
run in console ``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'; }