Simple integration with OpenSubtitles API to search for and download subtitles.
To install this package through composer run the following command in the terminal
composer require codebuglab/laravel-opensubtitles
You have to publish config file with this artisan command:
php artisan vendor:publish --provider="CodeBugLab\OpenSubtitles\OpenSubtitlesServiceProvider"
- File
opensubtitles.php
will be publish inconfig
folder after that. - Then you have to put your opensubtitles api key in your
env
file like thisOpenSubtitles_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
.
- You can use opensubtitles api and get information your want, first take a quick look at official api page.
- For all next API requests you have to use OpenSubtitles facade
use CodeBugLab\OpenSubtitles\Facades\OpenSubtitles;
- Every request have it's own parameters and response and we gonna explain it in details
$parameters = [
'imdb_id' => "315642",
'languages' => 'en',
'type' => 'movie'
];
$opensubtitles = OpenSubtitles::subtitles()->searchForSubtitles($parameters)->toArray();
- Simply this will search for subtitles depends on movie id in opensubtitles, IMDB id or even TMDB id.
- For more information about parameters and response click here.
$parameters = [
'file_id' => "2712566",
'sub_format' => 'srt'
];
$srtFile = OpenSubtitles::download()->details($parameters)->getSrt();
- Here you can get srt file by file_id that you can get from search for subtitles query.
- You can download the file with other format, take a look at this link to know all other formats you can download.
- Unfortunately there is a limit depends on your opensubtitle account start from 10 up to 1000 download per day.
- For more information about parameters and response click here.
$legacySubtitleId = "7090487";
$zipFile = OpenSubtitles::download()->getZipFileByLegacySubtitleId($legacySubtitleId);
- This is unofficial way to download the subtitles but it still supported by opensubtitles website.
- We need legacy subtitle id instead of file id and both are available in search for subtitles response.
- There is no specific limit to download by using this method.
This package is a free software distributed under the terms of the MIT license.