tongyifan/doubanphp

Library for parsing metadata information about movies and TV shows from Douban Movie

0.1.1 2020-02-22 07:20 UTC

This package is auto-updated.

Last update: 2024-04-26 21:58:56 UTC


README

Library for parsing metadata information about movies and TV shows from Douban Movie. This library use data api from Rhilip/pt-gen-cfworker, cache included.

  1. Setup your own pt-gen on Cloudflare worker See Rhilip/pt-gen-cfworker. Then change api_endpoint in conf/config.ini to your own cfworker.

  2. Requirements

  • PHP >= 5.6
  • PHP cURL extension
  • PHP JSON extension
  1. Install
composer install tongyifan/doubanphp
  1. Usage
<?php
require 'vendor/autoload.php';

use Douban\Douban;

$douban_id = '30458442';
$douban = new Douban($douban_id);

$douban_rating = $douban->douban_rating;
  1. Advanced usage
  • You can change cache settings by changing conf/config.ini.
  • Or change it in your application.
<?php
require 'vendor/autoload.php';

use Douban\Douban;
use Douban\Config;

$config = new Config();
// see https://book.cakephp.org/3/en/core-libraries/caching.html for more information.
$config->cache_config = [
    'className' => 'Redis',
    'duration' => '+14 days',
    'prefix' => 'doubanphp_',
    'host' => '127.0.0.1',
    'port' => 6379
];

$imdb_id = 'tt11043632';
$douban = new Douban($imdb_id, null, $config);
$douban_rating = $douban->douban_rating;

// or use numeric IMDb id, but you should add "source".
$imdb_id = '11043632';
$douban = new Douban($imdb_id, 'imdb', $config);
$douban_rating = $douban->douban_rating;