BioTorrents.de’s version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

anime.php 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. #declare(strict_types=1);
  3. if (empty($_GET['aid'])) {
  4. json_die();
  5. }
  6. $aid = $_GET['aid'];
  7. if ($Cache->get_value('anime_fill_json_'.$aid)) {
  8. json_die("success", $Cache->get_value('anime_fill_json_'.$aid));
  9. } else {
  10. $anidb_url = 'http://api.anidb.net:9001/httpapi?request=anime&client='.API_KEYS['ANIDB'].'&clientver=1&protover=1&aid='.$aid;
  11. $crl = curl_init();
  12. curl_setopt($crl, CURLOPT_URL, $anidb_url);
  13. curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1);
  14. curl_setopt($crl, CURLOPT_CONNEECTTIMEOUT, 5);
  15. $ret = curl_exec($crl);
  16. curl_close($curl);
  17. $anidb_xml = new SimpleXMLElement(zlib_decode($ret));
  18. if ($anidb_xml->xpath('/error')) {
  19. json_die("failure", $anidb_xml->xpath('/error')[0]."");
  20. }
  21. $title = $anidb_xml->xpath('//titles/title[@xml:lang = "en" and @type = "official"]')[0].'';
  22. $title = (empty($title))?$anidb_xml->xpath('//titles/title[@xml:lang = "en"]')[0].'':$title;
  23. $title = (empty($title))?$anidb_xml->xpath('//titles/title[@type = "main"]')[0].'':$title;
  24. $title_rj = $anidb_xml->xpath('//titles/title[@xml:lang = "x-jat" and @type = "official"]')[0].'';
  25. $title_rj = (empty($title_rj))?$anidb_xml->xpath('//titles/title[@xml:lang = "x-jat"]')[0].'':$title_rj;
  26. $title_jp = $anidb_xml->xpath('//titles/title[@xml:lang = "ja" and @type = "official"]')[0].'';
  27. $title_jp = (empty($title_jp))?$anidb_xml->xpath('//titles/title[@xml:lang = "ja"]')[0].'':$title_jp;
  28. $artist = $anidb_xml->xpath('//creators/name[@type = "Animation Work"]')[0].'';
  29. $year = substr($anidb_xml->startdate, 0, 4);
  30. $desc = preg_replace('/http:\/\/anidb.net\S+ \[(.*?)\]/', '$1', ($anidb_xml->description).'');
  31. $json_str = array(
  32. 'id' => $aid,
  33. 'title' => $title,
  34. 'title_rj' => $title_rj,
  35. 'title_jp' => $title_jp,
  36. 'artist' => $artist,
  37. 'year' => $year,
  38. 'description' => $desc
  39. );
  40. $Cache->cache_value('anime_fill_json_'.$aid, $json_str, 86400);
  41. json_die("success", $json_str);
  42. }
  43. ?>