anime-db / smotret-anime-browser-bundle
Smotret-Anime.ru API 浏览器
v1.1.0
2017-08-01 08:53 UTC
Requires
- php: >=5.5
- guzzlehttp/guzzle: ~6.2
Requires (Dev)
- phpunit/phpunit: ~4.8
- satooshi/php-coveralls: ^1.0
- scrutinizer/ocular: ~1.3
- symfony/config: ~2.7|~3.0
- symfony/dependency-injection: ~2.7|~3.0
- symfony/expression-language: ~2.7|~3.0
- symfony/http-kernel: ~2.7|~3.0
README
Smotret-Anime.ru API 浏览器
安装
使用 Composer 非常简单,运行
composer require anime-db/smotret-anime-browser-bundle
将 AnimeDbSmotretAnimeBrowserBundle 添加到您的应用程序内核
// app/appKernel.php public function registerBundles() { $bundles = array( // ... new AnimeDb\Bundle\SmotretAnimeBrowserBundle\AnimeDbSmotretAnimeBrowserBundle(), ); }
配置
anime_db_smotret_anime_browser: # Host name # As a default used 'http://smotret-anime.ru' host: 'http://smotret-anime.ru' # Host name # As a default used '/api/' prefix: '/api/' # HTTP User-Agent # No default value client: 'My Custom Bot 1.0'
使用方法
首先获取浏览器
$browser = $this->get('anime_db.smotret_anime.browser');
翻译
最近添加的翻译
$content = $browser->get('translations');
正在进行的最新翻译
$content = $browser->get('translations?feed=recent');
所有翻译的列表(从最旧的开始,方便进行全面扫描)
$content = $browser->get('translations?feed=id');
在全面扫描时,不要使用 offset
参数。使用 afterId
(当账户翻译数达到数百万时,offset 的工作速度非常慢)
$content = $browser->get('translations?feed=id&afterId=10000');
单个翻译
$content = $browser->get('translations/905760');
系列
动画列表
$content = $browser->get('series');
您可以选择特定的字段
$content = $browser->get('series?fields=id,title,typeTitle,posterUrlSmall');
高级过滤,如网站上的过滤
$content = $browser->get('series?chips=genre@=8,35;genre_op=and');
您可以按参数过滤
$content = $browser->get('series?myAnimeListId=24133');
按名称搜索
$content = $browser->get('series?query=gate');
关于特定动画和剧集列表的信息
$content = $browser->get('series/9866');
剧集
关于特定剧集和翻译列表的信息
$content = $browser->get('episodes/102173');
限制和偏移量
通过 limit
和 offset
,您可以调整页面上的元素数量和起始偏移量
$content = $browser->get('series?limit=1&offset=10');
捕获异常
use AnimeDb\Bundle\SmotretAnimeBrowserBundle\Exception\NotFoundException; try { $content = $browser->get('series/1'); } catch (NotFoundException $e) { // series not found } catch (\Exception $e) { // other exceptions }
请求选项
您可以根据需要自定义请求选项。请参阅Guzzle 文档。
许可证
此包受GPL v3 许可证的约束。请参阅文件中的完整许可证:LICENSE