dawson/tvdb

一个用于通过 Laravel 搜索 TVDB 数据库的包。

2.0-beta 2020-01-10 14:58 UTC

This package is auto-updated.

Last update: 2024-09-11 01:26:15 UTC


README

这是一个针对 TVDB API 的专用 Laravel 包。目前该包的文档并非完全完善,因为我仍在开发中。所以请期待文档很快会得到改进。

安装

要安装,请使用以下命令通过 Composer 拉取包。

composer require dawson/tvdb

现在在 config/app.php 中注册服务提供者。

'providers' => [
	...
	Dawson\TVDB\TVDBServiceProvider::class,
],

并将别名也添加到同一个文件中。

'aliases' => [
	...
	'TVDB' => Dawson\TVDB\TVDBFacade::class,
],

配置

现在您需要发布 tvdb.php 配置文件。

php artisan vendor:publish --provider="Dawson\TVDB\TVDBServiceProvider"

现在将以下环境变量添加到您的 .env 文件中。您可以从 TVDB 的账户中获得您的 用户密钥API 密钥

TVDB_USERNAME=
TVDB_USERKEY=
TVDB_APIKEY=

搜索

要搜索电视剧,请执行以下操作

以下是一个示例

$results = TVDB::search('Walking Dead');

return $results;

其中 $results 是 TVDB API 的 JSON 响应。以下是一个示例响应。

{
  "data": [
    {
      "aliases": [],
      "banner": "graphical/153021-g44.jpg",
      "firstAired": "2010-10-31",
      "id": 153021,
      "network": "AMC",
      "overview": "The world we knew is gone. An epidemic of apocalyptic proportions has swept the globe causing the dead to rise and feed on the living. In a matter of months society has crumbled. In a world ruled by the dead, we are forced to finally start living. Based on a comic book series of the same name by Robert Kirkman, this AMC project focuses on the world after a zombie apocalypse. The series follows a police officer, Rick Grimes, who wakes up from a coma to find the world ravaged with zombies. Looking for his family, he and a group of survivors attempt to battle against the zombies in order to stay alive.\r\n",
      "seriesName": "The Walking Dead",
      "status": "Continuing"
    },
    {
      "aliases": [],
      "banner": "graphical/290853-g5.jpg",
      "firstAired": "2015-08-23",
      "id": 290853,
      "network": "AMC",
      "overview": "A horrifying zombiocalypse spin-off series from The Walking Dead, set in the same universe but starting at a far earlier time in Los Angeles. The show follows normal people learning to deal with the rapidly growing collapse of civilization, at the very beginning of a zombie outbreak.\r\n\r\nIn Los Angeles, a city where people come to escape, shield secrets, and bury their pasts, we follow this mysterious outbreak as it threatens to disrupt what little stability high school guidance counselor Madison Clark and English teacher Travis Manawa have managed to assemble. \r\n\r\nThe pressure of blending two families while dealing with resentful, escapist, and strung out children takes a back seat when society begins to break down. A forced evolution, and survival of the fittest takes hold, as our dysfunctional family finds they must either reinvent themselves or embrace their darker histories.",
      "seriesName": "Fear the Walking Dead",
      "status": "Continuing"
    }
  ]
}

电视剧

使用电视剧 ID,您还可以执行查找以获取有关电视剧的更多信息。

$theWalkingDead = TVDB::series('153021')->get();

get() 方法也会返回 JSON。以下是一个示例响应。

{
  "data": {
    "added": "2010-03-30 01:30:16",
    "addedBy": 76261,
    "airsDayOfWeek": "Sunday",
    "airsTime": "9:00 PM",
    "aliases": [],
    "banner": "graphical/153021-g44.jpg",
    "firstAired": "2010-10-31",
    "genre": [
      "Action",
      "Drama",
      "Horror",
      "Suspense"
    ],
    "id": 153021,
    "imdbId": "tt1520211",
    "lastUpdated": 1474059455,
    "network": "AMC",
    "networkId": "",
    "overview": "The world we knew is gone. An epidemic of apocalyptic proportions has swept the globe causing the dead to rise and feed on the living. In a matter of months society has crumbled. In a world ruled by the dead, we are forced to finally start living. Based on a comic book series of the same name by Robert Kirkman, this AMC project focuses on the world after a zombie apocalypse. The series follows a police officer, Rick Grimes, who wakes up from a coma to find the world ravaged with zombies. Looking for his family, he and a group of survivors attempt to battle against the zombies in order to stay alive.\r\n",
    "rating": "TV-MA",
    "runtime": "50",
    "seriesId": "78582",
    "seriesName": "The Walking Dead",
    "siteRating": 9,
    "siteRatingCount": 1354,
    "status": "Continuing",
    "zap2itId": "EP01324002"
  }
}

演员

您还可以从电视剧中获取演员信息。

$actors = TVDB::series('153021')->actors();

剧集

您还可以获取完整的剧集列表。

$episodes = TVDB::series('153021')->episodes();

问题

如果您有任何问题,请随时提交问题。