codebuglab / laravel-opensubtitles
Simple integration with OpenSubtitles API to search for and download subtitles.
1.0.1
2024-06-19 01:07 UTC
Requires
- php: >=7.0
- illuminate/support: >=6.0.0
This package is auto-updated.
Last update: 2024-12-19 02:14:03 UTC
README
Simple integration with OpenSubtitles API to search for and download subtitles.
Table of contents
Setup
Installation
To install this package through composer run the following command in the terminal
composer require codebuglab/laravel-opensubtitles
Publish
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
.
Instructions
- 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
Subtitles
Search For Subtitles
$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.
Download
Details
$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.
Get Zip File By Legacy Subtitle Id
$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.
License
This package is a free software distributed under the terms of the MIT license.