anime-db/smotret-anime-browser-bundle

v1.1.0 2017-08-01 08:53 UTC

This package is auto-updated.

Last update: 2024-10-15 19:54:21 UTC


README

Smotret-Anime.ru

Latest Stable Version Total Downloads Build Status Coverage Status Scrutinizer Code Quality SensioLabs Insight StyleCI License

Smotret-Anime.ru API browser

Installation

Pretty simple with Composer, run:

composer require anime-db/smotret-anime-browser-bundle

Add AnimeDbSmotretAnimeBrowserBundle to your application kernel

// app/appKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new AnimeDb\Bundle\SmotretAnimeBrowserBundle\AnimeDbSmotretAnimeBrowserBundle(),
    );
}

Configuration

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'

Usage

First get browser

$browser = $this->get('anime_db.smotret_anime.browser');

Translations

Last added translations:

$content = $browser->get('translations');

Last translations for ongoings:

$content = $browser->get('translations?feed=recent');

List of all translations (at the beginning of the oldest, convenient for a full scan):

$content = $browser->get('translations?feed=id');

When scanning in full, do not use the offset parameter. Use afterId (offset works very slowly when the account goes to hundreds of thousands of translations):

$content = $browser->get('translations?feed=id&afterId=10000');

One translation:

$content = $browser->get('translations/905760');

Series

Anime List:

$content = $browser->get('series');

You can select only specific fields:

$content = $browser->get('series?fields=id,title,typeTitle,posterUrlSmall');

Advanced filter as on the site:

$content = $browser->get('series?chips=genre@=8,35;genre_op=and');

You can filter by parameters:

$content = $browser->get('series?myAnimeListId=24133');

Search by name:

$content = $browser->get('series?query=gate');

Information about a specific anime and a list of episodes:

$content = $browser->get('series/9866');

Episodes

Information about a specific episode and a list of translations:

$content = $browser->get('episodes/102173');

Limit and Offset

Through limit and offset, you can adjust the number of elements "on the page" and the offset from the beginning:

$content = $browser->get('series?limit=1&offset=10');

Catch exceptions

use AnimeDb\Bundle\SmotretAnimeBrowserBundle\Exception\NotFoundException;

try {
    $content = $browser->get('series/1');
} catch (NotFoundException $e) {
    // series not found
} catch (\Exception $e) {
    // other exceptions
}

Request options

You can customize request options. See Guzzle Documentation.

License

This bundle is under the GPL v3 license. See the complete license in the file: LICENSE