Редактор темы

Реклама
Реклама
Реклама
Реклама

Серверная часть для yohoho

  • Автор темы Автор темы chuvak
  • Дата начала Дата начала

chuvak

Бывалый
Регистрация
14 Окт 2021
Сообщения
196
Рейтинг реакций
36
Баллы
28
1/3
Автор темы
PHP:
<?php
require __DIR__ . '/vendor/autoload.php';

use Clue\React\Buzz\Browser;
use React\EventLoop\LoopInterface;

class KinopoiskParser {

    private $client;

    private $loop;
    
    private $parsed = [];

    public function __construct(Browser $client, LoopInterface $loop)
    {
        $this->client = $client;
        $this->loop = $loop;
    }

    public function parse($idkp)
    {
        $this->client->get('https://api.alloha.tv/?token=&kp=' .$idkp)->then(
            function (\Psr\Http\Message\ResponseInterface $response) {
                $this->parsed['alloha'] = $this->extractFromHtml((string) $response->getBody(), 0);
        });
        
                $this->client->get('https://bazon.cc/api/search?token=&kp=' .$idkp)->then(
            function (\Psr\Http\Message\ResponseInterface $response) {
                $this->parsed['bazon'] = $this->extractFromHtml((string) $response->getBody(), 1);
        });
        
                $this->client->get('https://api1640838797.bhcesh.me/list?token=&kinopoisk_id=' .$idkp)->then(
            function (\Psr\Http\Message\ResponseInterface $response) {
                $this->parsed['collaps'] = $this->extractFromHtml((string) $response->getBody(), 2);
        });
        
                $this->client->get('https://videocdn.tv/api/short?api_token=&kinopoisk_id=' .$idkp)->then(
            function (\Psr\Http\Message\ResponseInterface $response) {
                $this->parsed['videocdn'] = $this->extractFromHtml((string) $response->getBody(), 3);
        });
        
                $this->client->get('https://apivb.info/api/videos.json?token=&id_kp=' .$idkp)->then(
            function (\Psr\Http\Message\ResponseInterface $response) {
                $this->parsed['hdvb'] = $this->extractFromHtml((string) $response->getBody(), 4);
        });
        
                $this->client->get('https://kodikapi.com/search?token=&kinopoisk_id=' .$idkp)->then(
            function (\Psr\Http\Message\ResponseInterface $response) {
                $this->parsed['kodik'] = $this->extractFromHtml((string) $response->getBody(), 5);
        });
        
                $this->client->get('https://apidevel.ustore.bz/?f=search_by_id&hash=&where=kinopoisk&id=' .$idkp)->then(
            function (\Psr\Http\Message\ResponseInterface $response) {
                $this->parsed['ustore'] = $this->extractFromHtml((string) $response->getBody(), 6);
        });

    }
    
    public function extractFromHtml($html, $i)
    {
        switch ($i) {
        case 0:
            $array = json_decode($html,true)['data'];
            $trs = explode(",", $array['translation']);
            $arr['alloha']['translate'] = $trs['0'];
            $trss = explode(",", $array['quality']);
            $arr['alloha']['quality'] = $trs['0'];
            return [
                        'iframe'        => $array['iframe'],
                        'translate'       => $trs['0'],
                        'quality'  => $trss['0']
                    ];
            break;
        case 1:
            $array = json_decode($html,true)['results']['0'];
            return [
                        'iframe'        => $array['link'],
                        'translate'       => $array['translation'],
                        'quality'  => $array['quality']
                    ];
            break;
        case 2:
            $array = json_decode($html,true)['results']['0'];
            return [
                        'iframe'        => $array['iframe_url'],
                        'translate'       => '',
                        'quality'  => $array['quality']
                    ];
            break;
        case 3:
            $array = json_decode($html,true)['data']['0'];
            return [
                        'iframe'        => $array['iframe_src'],
                        'translate'       => $array['translations']['0'],
                        'quality'  => $array['quality']
                    ];
            break;
        case 4:
            $array = json_decode($html,true)['0'];
            return [
                        'iframe'        => $array['iframe_url'],
                        'translate'       => $array['translator'],
                        'quality'  => $array['quality']
                    ];
            break;
        case 5:
            $array = json_decode($html,true)['results']['0'];
            return [
                        'iframe'        => $array['link'],
                        'translate'       => $array['translation']['title'],
                        'quality'  => $array['quality']
                    ];
            break;
        case 6:
            $array = json_decode($html,true)['0'];
            return [
                        'iframe'        => $array['iframe'],
                        'translate'       => $array['translate'],
                        'quality'  => $array['quality']
                    ];
            break;
        }
    }
    
    public function getMovieData()
    {
        return $this->parsed;
    }
}
$loop = React\EventLoop\Factory::create();
$client = new Browser($loop);
$parser = new KinopoiskParser($client, $loop);
$parser->parse(370);
$loop->run();
echo json_encode($parser->getMovieData());
Накидал побыстрому(стырил) тестовый вариант, еще много что доделать надо, у кого есть желание, помогайте
 
Не шарю за dev, но с удовольствием буду следить за развитием. Сам сижу на yohoho, круто будет, если появится альтернатива без связки с yohoho серверами. Где-то видел что разработчик утерял доступ к серверам((((
 
PHP:
require __DIR__ . '/vendor/autoload.php';
 
Последнее редактирование:
кто то ставил? как работает? как вставлять в страницу?
 
/vendor/autoload.php

Это где взять?)
 
Автор темы
Сюда надо еще кэш приделать, и так помельчи. Кому не лень сделайте
 

Похожие темы Последние темы Популярные темы

Назад
Сверху