hsnfirdaus / subscene-sdk
一个非官方的subscene.com SDK,用于搜索、下载和智能过滤字幕
This package is auto-updated.
Last update: 2023-07-04 17:48:24 UTC
README
一个PHP库,用于通过智能过滤从subscene.com网站获取字幕数据和文件。
安装
使用Composer
建议通过 Composer 安装此库
composer require "hsnfirdaus/subscene-sdk"
或者您可以直接手动下载此存储库作为zip文件并解压缩到项目目录中。
注意
如果您使用的是此库的V1版本,请阅读 (README.v1.md)
用法
调用类
开始之前,只需require composer的自动加载器
require __DIR__ . '/vendor/autoload.php';
或者如果您手动下载此脚本,require /src/Subscene.php 文件
require __DIR__ . '/subscene-sdk/src/Subscene.php';
然后您就可以像这样调用Subscene类
$subscene = new Hsnfirdaus\Subscene();
获取结果
此类支持以数组或JSON形式获取结果。只需调用getArray()方法或getJSON()方法。所有方法都将响应三个对象/数组:type、info和result。
错误处理
您可以使用 try{ } catch() { } 异常来处理错误。
| 异常名称 | 描述 |
|---|---|
CURLError |
cURL有问题 |
PageStructurError |
无法匹配cURL结果的内容,可能是subscene页面结构已更改。 |
FunctionError |
运行方法时出错,可能是您错误地调用了方法。 |
方法列表
搜索
此方法用于搜索在subscene中提供字幕的电影或电视剧。
示例请求
$subscene = new Hsnfirdaus\Subscene(); $search = $subscene->search($query); print_r($search->getArray());
参数
| 参数 | 类型 | 默认值 | 详细信息 |
|---|---|---|---|
$query |
字符串 |
null | 您想要搜索的电影/电视剧的标题。 |
示例响应
示例 $subscene->search('ncis')->getArray() 响应
Array ( [type] => SEARCH [info] => Array ( [search_query] => ncis ) [result] => Array ( [0] => Array ( [permalink] => ncis-los-angeles-twelfth-season [title] => NCIS: Los Angeles - Twelfth Season [year] => [count] => 27 [in_heading] => TV-Series [season] => 12 ) [1] => Array ( [permalink] => ncis-new-orleans-seventh-season [title] => NCIS: New Orleans - Seventh Season [year] => [count] => 11 [in_heading] => TV-Series [season] => 7 ) [2] => Array ( [permalink] => ncis-eighteenth-season [title] => NCIS: Naval Criminal Investigative Service (Navy CIS) - Eighteenth Season [year] => [count] => 37 [in_heading] => TV-Series [season] => 18 ) ) )
listSubtitle
此方法用于从特定的永久链接列出字幕。
示例请求
$subscene = new Hsnfirdaus\Subscene(); $listSubtitle = $subscene->listSubtitle($permalink); print_r($listSubtitle->getArray());
参数
| 参数 | 类型 | 默认值 | 详细信息 |
|---|---|---|---|
$permalink |
字符串 |
null | 您将查找的页面永久链接列表子标题。 |
示例响应
示例 $subscene->listSubtitle('ncis-eighteenth-season')->getArray() 响应
Array ( [type] => LIST_SUBTITLE [info] => Array ( [permalink] => ncis-eighteenth-season [title] => NCIS: Naval Criminal Investigative Service (Navy CIS) - Eighteenth Season [year] => 2020 [poster] => https://i.jeded.com/i/ncis-eighteenth-season.196526.jpg [imdb_id] => tt0364845 ) [result] => Array ( [0] => Array ( [id] => 2391386 [language] => Array ( [code] => english [name] => English ) [rate] => positive [name] => NCIS.S18E07.WEBRip.x264-ION10 [hearing_impaired] => 1 [user] => Array ( [id] => 1068258 [name] => M_I_S ) [comment] => Hi:WebRip/WebDl:Duration : 43 min 14 s ) [1] => Array ( [id] => 2391385 [language] => Array ( [code] => english [name] => English ) [rate] => positive [name] => NCIS.S18E07.WEBRip.x264-ION10 [hearing_impaired] => [user] => Array ( [id] => 1068258 [name] => M_I_S ) [comment] => Non Hi:WebRip/WebDl:Duration : 43 min 14 s ) [2] => Array ( [id] => 2391412 [language] => Array ( [code] => english [name] => English ) [rate] => neutral [name] => NCIS.S18E07.The.First.Day.720p.AMZN.WEB-DL.DDP5.1.H.264-NTb [hearing_impaired] => [user] => Array ( [id] => 1358973 [name] => SoftSpotForBoobies ) [comment] => A Amazon Original Subtitle ) [3] => Array ( [id] => 2391412 [language] => Array ( [code] => english [name] => English ) [rate] => neutral [name] => NCIS.S18E07.The.First.Day.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb [hearing_impaired] => [user] => Array ( [id] => 1358973 [name] => SoftSpotForBoobies ) [comment] => A Amazon Original Subtitle ) ) )
getSubtitle
此方法用于生成特定字幕的下载链接和信息。
示例请求
$subscene = new Hsnfirdaus\Subscene(); $getSubtitle = $subscene->getSubtitle($permalink,$lang_code,$id) print_r($getSubtitle->getArray());
参数
| 参数 | 类型 | 默认值 | 详细信息 |
|---|---|---|---|
$permalink |
字符串 |
null | 您将获取字幕的页面永久链接。 |
$lang_code |
字符串 |
null | 字幕的语言代码。 |
$id |
整数 |
null | 字幕的ID。 |
示例响应
示例 $subscene->getSubtitle('ncis-eighteenth-season','english',2391412)->getArray() 响应
Array ( [type] => GET_SUBTITLE [info] => Array ( [permalink] => ncis-eighteenth-season [language] => Array ( [code] => english [name] => English ) [id] => 2391412 [poster] => https://i.jeded.com/i/ncis-eighteenth-season.196526.jpg [title] => NCIS: Naval Criminal Investigative Service (Navy CIS) - Eighteenth Season [imdb_id] => tt0364845 [release_list] => Array ( [0] => NCIS.S18E07.The.First.Day.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb [1] => NCIS.S18E07.The.First.Day.720p.AMZN.WEB-DL.DDP5.1.H.264-NTb ) [user] => Array ( [id] => 0 [name] => Anonymous ) [comment] => A Amazon Original Subtitle ) [result] => Array ( [preview] => 1<br />00:00:05,135 --> 00:00:08,269<br />You know what 4:00 a.m.<br />in February feels like, Ronnie?<br /><br />2<br />00:00:08,312 --> 00:00:11,924<br />And I'm out here chasing a cat<br />in a coal mine.<br /><br />3<br />00:00:11,968 --> 00:00:14,144<br />RONNIE:<br />All I do is take the info down,<br />pass it along.<br /><br />4<br />00:00:14,188 --> 00:00:17,234<br />Well, next time, verify the GPS.<br /><br />5<br />00:00:17,278 --> 00:00:20,759<br /> [details] => Array ( [online] => 2/10/2021 8:16 AM 1 days ago [hearing_impaired] => No [foreign_parts] => No [framerate] => Not available [files] => 1 (26,329 bytes) [production_type] => From retail [release_type] => Web [ratings] => Array ( [score] => 0 [of] => 0 [total_user] => 0 ) [total_download] => 156 ) [download_link] => https://subscene.com/subtitles/english-text/eEahuEBLjo_jAxOXb7uqIn-HDlNNckpyomovJYazgItv0-TbEJV0AwOdhVnI6NAAGwpKKQV7E1miRitP2gZSPwa9_WM8qD0dd9SgZ53iud-8nZfvXYMEPdFuZcot43gw0 ) )
smartFilterSeries
此方法用于从 listSubtitle 获取特定电视剧发布的剧集。
示例请求
$subscene = new Hsnfirdaus\Subscene(); $listSubtitle=$subscene->listSubtitle('ncis-eighteenth-season'); $filter = $listSubtitle->smartFilterSeries($language,$primary_type,$option); print_r($search->getArray());
参数
| 参数 | 类型 | 默认值 | 详细信息 |
|---|---|---|---|
$language |
字符串 |
english | 您要查找的语言代码/名称(例如:english)。 |
$primary_type |
数组 |
['hdtv'] |
主要字幕类型(例如:['amzn','web','hdtv'])。 |
$option |
数组 |
null | 可选选项season:系列季数,默认将从标题获取季数。start_episode:要查找的起始剧集,默认为1。end_episode:要查找的结束剧集,默认为循环到结束。hearing_impaired:是否寻找听力受损字幕?设置为true或false,默认为false。 |
示例响应
示例
$listSubtitle=$subscene->listSubtitle('ncis-eighteenth-season'); $filter=$listSubtitle->smartFilterSeries('english',['amzn','web'],[ 'start_episode'=>1, 'end_episode'=>3, 'hearing_impaired'=>FALSE ]); print_r($filter->getArray());
响应
Array ( [type] => SMART_FILTER_SERIES [info] => Array ( [permalink] => ncis-eighteenth-season [title] => NCIS: Naval Criminal Investigative Service (Navy CIS) - Eighteenth Season [year] => 2020 [poster] => https://i.jeded.com/i/ncis-eighteenth-season.196526.jpg [imdb_id] => tt0364845 [season] => 18 [total_episode] => 2 [language] => english [primary_type] => Array ( [0] => amzn [1] => web ) [missing_episode] => Array ( ) ) [result] => Array ( [1] => Array ( [id] => 2335928 [language] => Array ( [code] => english [name] => English ) [rate] => positive [name] => NCIS.S18E01.Sturgeon.Season.720p.AMZN.WEBRip.DDP5.1.x264-NTb.41 min 28 [hearing_impaired] => [user] => Array ( [id] => 1068258 [name] => M_I_S ) [comment] => Hi MRD :Official:WebRip&webDl:41:28 [season] => 18 [episode] => 01 ) [2] => Array ( [id] => 2340604 [language] => Array ( [code] => english [name] => English ) [rate] => positive [name] => ncis.s18e02.1080p.web.h264-ggwp [hearing_impaired] => [user] => Array ( [id] => 1221159 [name] => class123 ) [comment] => class123 [season] => 18 [episode] => 02 ) [3] => Array ( [id] => 2351225 [language] => Array ( [code] => english [name] => English ) [rate] => neutral [name] => NCIS.S18E03.iNTERNAL.1080p.WEB.h264-KOGi [hearing_impaired] => [user] => Array ( [id] => 1221159 [name] => class123 ) [comment] => class123 [season] => 18 [episode] => 03 ) ) )
smartDownloadSeries
此方法尝试从 smartFilterSeries 结果中下载和解压字幕。
示例请求
$subscene = new Hsnfirdaus\Subscene(); $listSubtitle=$subscene->listSubtitle('ncis-eighteenth-season'); $filter=$listSubtitle->smartFilterSeries('english',['amzn','web'],[ 'start_episode'=>1, 'end_episode'=>3, 'hearing_impaired'=>FALSE ]); $download=$filter->smartDownloadSeries($folder_target,$name_format); print_r($download->getArray());
参数
| 参数 | 类型 | 默认值 | 详细信息 |
|---|---|---|---|
$folder_target |
字符串 |
__DIR__.'/../../../../' |
下载的srt字幕将保存的目标文件夹。 |
$name_format |
字符串 |
将字幕重命名为此字符串,例如:'NCIS - S%sE%s' |
示例响应
示例
$listSubtitle=$subscene->listSubtitle('ncis-eighteenth-season'); $filter=$listSubtitle->smartFilterSeries('english',['amzn','web'],[ 'start_episode'=>1, 'end_episode'=>3, 'hearing_impaired'=>FALSE ]); $download=$filter->smartDownloadSeries(__DIR__,'NCIS - S%sE%s'); print_r($filter->getArray());
响应
Array ( [type] => SMART_DOWNLOAD_SERIES [info] => Array ( [permalink] => ncis-eighteenth-season [title] => NCIS: Naval Criminal Investigative Service (Navy CIS) - Eighteenth Season [year] => 2020 [poster] => https://i.jeded.com/i/ncis-eighteenth-season.196526.jpg [imdb_id] => tt0364845 [season] => 18 [total_episode] => 2 [language] => english [primary_type] => Array ( [0] => amzn [1] => web ) [missing_episode] => Array ( ) ) [result] => Array ( [folder_target] => /htdocs/subtitle [file_failed] => Array ( ) [file_saved] => Array ( [0] => NCIS - S18E01.srt [1] => NCIS - S18E02.srt [2] => NCIS - S18E03.srt ) ) )