Advertisement
Guest User

nepumuck

a guest
Apr 11th, 2009
477
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 17.54 KB | None | 0 0
  1. <?php
  2. /**
  3.  * OFDB Parser
  4.  *
  5.  * Parses data from the OFDB
  6.  *
  7.  * @package Engines
  8.  * @author  Chinamann <chinamann@users.sourceforge.net>
  9.  * @link    http://www.ofdb.de
  10.  * @version $Id: ofdb.php,v 1.20 2009/02/28 12:09:50 andig2 Exp $
  11.  */
  12.  
  13. $GLOBALS['ofdbServer']  = 'http://www.ofdb.de';
  14. $GLOBALS['ofdbIdPrefix'] = 'ofdb:';
  15.  
  16. /**
  17.  * Get meta information about the engine
  18.  *
  19.  * @todo    Include image search capabilities etc in meta information
  20.  */
  21. function ofdbMeta()
  22. {
  23.     return array(
  24.         'name' => 'OFDB (de)'
  25.         , 'stable' => 1
  26.         , 'supportsEANSearch' => 1
  27.     );
  28. }
  29.  
  30. /**
  31.  * Get search Url for OfDB
  32.  *
  33.  * @author  Chinamann <chinamann@users.sourceforge.net>
  34.  * @param   string  The search string
  35.  * @return  string  The search URL (GET)
  36.  */
  37. function ofdbSearchUrl($title, $searchType = 'title')
  38. {
  39.     global $ofdbServer;
  40.    
  41.     // auto switch to ean Mode if title is exactly 13 digits
  42.     if (preg_match('#^\s*[0-9]{13}\s*$#',$title)) $searchType = 'ean';
  43.    
  44.     $url = $ofdbServer.'/view.php?page=suchergebnis&SText='.urlencode($title);
  45.     switch($searchType)
  46.     {
  47.         default    :
  48.         case 'text': {
  49.             $url = $url.'&Kat=All'; break;
  50.         }
  51.         case 'ean' : {
  52.             $url = $url.'&Kat=EAN'; break;
  53.         }
  54.     }
  55.    
  56.     return $url;
  57. }
  58.  
  59. /**
  60.  * Get content overview URL
  61.  *
  62.  * @author  Chinamann <chinamann@users.sourceforge.net>
  63.  * @param   string  $id The movie's external id
  64.  * @return  string      The visit URL
  65.  */
  66. function ofdbContentUrl($id)
  67. {
  68.     global $ofdbServer;
  69.     global $ofdbIdPrefix;
  70.  
  71.     $id = preg_replace('/^'.$ofdbIdPrefix.'/', '', $id);
  72.     list($id, $vid) = split("-", $id, 2);
  73.     return $ofdbServer.'/view.php?page=film&fid='.$id;
  74. }
  75.  
  76. /**
  77.  * Get content detail URL
  78.  *
  79.  * @author  Chinamann <chinamann@users.sourceforge.net>
  80.  * @param   string  $id The movie's external id
  81.  * @return  string      The visit URL
  82.  */
  83. function ofdbDetailUrl($id)
  84. {
  85.     global $ofdbServer;
  86.     return $ofdbServer.'/view.php?page=film_detail&fid='.$id;
  87. }
  88.  
  89. /**
  90.  * Get explicit version URL
  91.  *
  92.  * @author  Chinamann <chinamann@users.sourceforge.net>
  93.  * @param   string  $id     The movie's external id
  94.  * @param   string  $vid    The movie's version id
  95.  * @return  string          The visit URL
  96.  */
  97. function ofdbVersionUrl($id, $vid)
  98. {
  99.     global $ofdbServer;
  100.     return $ofdbServer.'/view.php?page=fassung&fid='.$id.'&vid='.$vid;
  101. }
  102.  
  103. /**
  104.  * Get content description URL
  105.  *
  106.  * @author  Chinamann <chinamann@users.sourceforge.net>
  107.  * @param   string  $id     The movie's external id
  108.  * @param   string  $sid    The movie's description id
  109.  * @return  string          The visit URL
  110.  */
  111. function ofdbDescriptionUrl($id, $sid)
  112. {
  113.     global $ofdbServer;
  114.     return $ofdbServer.'/view.php?page=inhalt&fid='.$id.'&sid='.$sid;
  115. }
  116.  
  117.  
  118. /**
  119.  * Search a Movie
  120.  *
  121.  * Searches for a given title on the OfDB and returns the found links in
  122.  * an array
  123.  *
  124.  * @author  Chinamann <chinamann@users.sourceforge.net>
  125.  * @param   string    The search string
  126.  * @return  array     Associative array with id and title
  127.  */
  128. function ofdbSearch($title, $searchType = 'title')
  129. {
  130.     global $ofdbServer;
  131.     global $ofdbIdPrefix;
  132.     global $CLIENTERROR;
  133.     global $cache;
  134.    
  135.     // auto switch to ean Mode if title is exactly 13 digits
  136.     if (preg_match('#^\s*[0-9]{13}\s*$#',$title)) $searchType = 'ean';
  137.    
  138.     // search for series
  139.     $resp = httpClient(ofdbSearchUrl($title, $searchType), $cache);
  140.     if (!$resp['success']) $CLIENTERROR .= $resp['error']."\n";
  141. #    dump($resp);
  142.    
  143.     // add encoding
  144.     $ary['encoding'] = engine_get_encoding($resp);
  145.    
  146.     // !! it seems OFDB is lying in this case- claiming UTF 8 but returning ISO-8859-1; so lets fix it
  147.     $ary['encoding'] = 'iso-8859-1';
  148.  
  149.     if (preg_match_all('/<br>[0-9]+\.\s*<a href="film\/([0-9]+),[^"]*" onmouseover="[^"]*"[^>]*>([^<]*)<font.*?\/font> \(([\/\-0-9]+)\)<\/a>/', $resp['data'], $data, PREG_SET_ORDER))
  150.     {
  151.         foreach ($data as $row) {
  152.             $info['id']     = $ofdbIdPrefix.$row[1];
  153.             $info['title']  = trim($row[2]).' ('.$row[3].')';
  154.             $ary[]          = $info;
  155.         }
  156.     }
  157.     if (preg_match_all('/<br>[0-9]+\.\s*<a href="film\/([0-9]+),[^"]*" onmouseover="[^"]*"><b>([^<]*)<.*?<a href="view\.php\?page=fassung.*?fid=[0-9]+.*?vid=([0-9]+)" onmouseover="[^"]*">([^<]*)</i', $resp['data'], $data, PREG_SET_ORDER))
  158.     {
  159.         foreach ($data as $row) {
  160.             $info['id']     = $ofdbIdPrefix.$row[1]."-".$row[3];
  161.             $info['title']  = trim($row[2]).' - '.$row[4];
  162.             $ary[]          = $info;
  163.         }
  164.     }
  165.     // do not return an array which contains only an encoding attribute
  166.     if (count($ary) < 2) return array();
  167.  
  168.     return $ary;
  169. }
  170.  
  171. /**
  172.  * Fetches the data for a given OfDB id
  173.  *
  174.  * @author  Chinamann <chinamann@users.sourceforge.net>
  175.  * @param   int   OfDB id
  176.  * @return  array Result data
  177.  */
  178. function ofdbData($id)
  179. {
  180.     global $CLIENTERROR;
  181.     global $ofdbServer;
  182.     global $ofdbIdPrefix;
  183.     global $cache;
  184.    
  185.     $id = preg_replace('/^'.$ofdbIdPrefix.'/', '', $id);
  186.     list($id, $vid) = split("-", $id, 2);
  187.    
  188.     $data = array(); //result
  189.     $ary  = array(); //temp
  190.     $ary2 = array(); //temp2
  191.    
  192.     // Fetch Mainpage
  193.     $resp = httpClient(ofdbContentUrl($id), $cache);
  194.     if (!$resp['success']) $CLIENTERROR .= $resp['error']."\n";
  195.  
  196. @@  //with utf8 encoding the parser will work with german mutated vowels
  197. @@  $resp['data'] = utf8_encode($resp['data']);
  198.  
  199.     // add encoding
  200.     $data['encoding'] = engine_get_encoding($resp);
  201.  
  202.     // add engine ID -> important for non edit.php refetch
  203.     $data['imdbID'] = $ofdbIdPrefix.$id;
  204.    
  205.     $resp['data'] = preg_replace('/[\r\n\t]/',' ', $resp['data']);
  206.    
  207.     // Titles / Year
  208.     preg_match('/<title>(.*?)<\/title>/i', $resp['data'], $ary);
  209.     $ary[1] = preg_replace('/^OFDb[\s-]*/', '', $ary[1]);
  210.     $ary[1] = preg_replace('/\[.*\]/', ' ', $ary[1]);
  211.     if (preg_match('/\(([0-9]*)\)/i',$ary[1],$ary2))
  212.     {
  213.         $data['year'] = trim($ary2[1]);
  214.     }
  215.     $ary[1] = preg_replace('/\([0-9]*\)/', ' ', $ary[1]);
  216.     $ary[1] = preg_replace('/\s{2,}/s', ' ', $ary[1]);
  217.    
  218.     // check if there is a comma  sperated article at the end
  219.     if (preg_match('#(.*),\s*(A|The|Der|Die|Das|Ein|Eine|Einer)\s*$#i',$ary[1],$subRes)) {
  220.         $ary[1] = $subRes[2].' '.$subRes[1];
  221.     }
  222.    
  223.     list($t,$s) = split(" - ",trim($ary[1]),2);
  224.     $data['title']      = trim($t);
  225.     $data['subtitle']   = trim($s);
  226.    
  227.     // Original Title
  228.     if (preg_match('/Originaltitel.*?<b>(.*?)</i', $resp['data'], $ary))
  229.     {
  230.         $data['orgtitle'] .= trim($ary[1]);
  231.     }
  232.    
  233.     // Country
  234.     if (preg_match('/>Herstellungsland:.*?<b><a.*?>(.*?)<\/a>/i', $resp['data'], $ary))
  235.     {
  236.         $data['country'] .= trim($ary[1]);
  237.     }
  238.    
  239.     // Rating
  240.     if (preg_match('/<br>Note:\s*([0-9\.]+)/', $resp['data'], $ary)) {
  241.         $data['rating'] = $ary[1];
  242.     }
  243.    
  244.     // Cover URL
  245.     if (preg_match('#<img src="(http://img.ofdb.de/film/.*?\.jpg)"#i', $resp['data'], $ary))
  246.     {
  247.         $data['coverurl'] =  trim($ary[1]);
  248.     }
  249.    
  250.     // Fetch first VID if none already selected
  251.     if (!$vid)
  252.     {
  253.         if (preg_match_all('/view\.php\?page=fassung&fid='.$id.'&vid=([0-9]+)".*?class="Klein">(.*?)</i', $resp['data'], $ary, PREG_SET_ORDER))
  254.         {
  255.             foreach($ary as $row)
  256.             {
  257.                 if (trim($row[2]) == "K" || trim($row[2]) == "KV") // Check if there is a good result
  258.                 {
  259.                     $vid=$row[1];
  260.                     break;
  261.                 }
  262.             }
  263.             if (!$vid) // Still empty -> Take the first one
  264.             {
  265.                 $vid=$ary[1][1];
  266.             }
  267.         }
  268.     }
  269.    
  270.     // IMDB ID
  271.     $data['imdbID'] = $ofdbIdPrefix."$id-$vid";
  272.    
  273. @@  //Fixed plot
  274. @@  //Not the best way, but it works fine ;)
  275. @@  preg_match('#href="(plot/[^"]+)"#i', $resp['data'], $ary);
  276. @@  $plotTMP = httpClient("http://www.ofdb.de/".$ary[1]);
  277. @@  $plotTMP['data'] = utf8_encode($plotTMP['data']);
  278. @@      //print_r($plotTMP['data']);
  279. @@ 
  280. @@  $start = strpos($plotTMP['data'],"</b><br><br>");
  281. @@  $end  = strpos($plotTMP['data'],"</font></p>");
  282. @@  $length = $end - $start;
  283. @@  $plotContent = substr($plotTMP['data'],$start,$length);
  284. @@  $plotContent = str_replace("</b>","",$plotContent);
  285. @@  $plotContent = str_replace("<br>","",$plotContent);
  286. @@  $data['plot'] = trim($plotContent);
  287. @@/*
  288. @@   // Fetch Plot
  289. @@  if (preg_match('#href="(plot/[^"]+)"#i', $resp['data'], $ary))
  290. @@  {
  291. @@      $subresp = httpClient($ofdbServer.'/'.$ary[1], $cache);
  292. @@      if (!$resp['success']) $CLIENTERROR .= $subresp['error']."\n";
  293. @@      $subresp['data'] = preg_replace('/[\r\n\t]/',' ', $subresp['data']);
  294. @@      //ofdbDbg($subresp['data'],false);
  295. @@      if (preg_match('#</b><br><br>(.*?)</font></p>#i', $subresp['data'], $ary))
  296. @@      {
  297. @@
  298. @@          $ary[1] = preg_replace('/\s{2,}/s', ' ', $ary[1]);
  299. @@          $ary[1] = preg_replace('#<(br|p)[ /]*>#i', "\n", $ary[1]);
  300. @@          $data['plot'] = trim($ary[1]);
  301. @@          //$data['plot'] = "aeääääaaaä";
  302. @@      }
  303. @@  }
  304. @@*/
  305.  
  306.     // Fetch Details
  307.     $resp = httpClient(ofdbDetailUrl($id), $cache);
  308.     if (!$resp['success']) $CLIENTERROR .= $resp['error']."\n";
  309.     $resp['data'] = preg_replace('/[\r\n\t]/',' ', $resp['data']);
  310.    
  311.     // Director
  312.     if (preg_match('/<b><i>Regie<\/i><\/b>.*?<table.*?>(.*?)<\/table>/i', $resp['data'], $ary))
  313.     {
  314.         if (preg_match_all('/class="Daten"><a.*?>(.*?)<\/a>/i',$ary[1],$ary2, PREG_SET_ORDER))
  315.         {
  316.             foreach ($ary2 as $row)
  317.             {
  318.                 $data['director'] .= trim($row[1]).', ';
  319.             }
  320.             $data['director'] = preg_replace('/, $/', '', $data['director']);
  321.         }
  322.     }
  323.    
  324.     // Cast
  325.     if (preg_match('/<b><i>Darsteller<\/i><\/b>.*?<table.*?>(.*)<\/table>/', $resp['data'], $ary))
  326.     {
  327.         // dirty workaround for (.*?) failed on very long match groups issue (tested at PHP 5.2.5.5)
  328.         // e.g.: ofdb:7749-111320 (Angel - Jäger der Finsternis)
  329.         $ary[1] = preg_replace('#</table.*#','',$ary[1]);
  330.        
  331.         if (preg_match_all('/class="Daten"><a(.*?)">(.*?)<\/a>.*?<\/td>  <td.*?<\/td>  <td[^>]*>(.*?)<\/td>/i',$ary[1],$ary2, PREG_SET_ORDER))
  332.         {
  333.             foreach ($ary2 as $row)
  334.             {
  335.                 $actor = trim(strip_tags($row[2]));
  336.  
  337.                 $actorid = "";
  338.                 if (!empty($row[1]))
  339.                 {
  340.                     if (preg_match('#href="view.php\?page=person&id=([0-9]*)#i', $row[1], $idAry))
  341.                     {
  342.                         $actorid = $ofdbIdPrefix.$idAry[1];
  343.                     }
  344.                 }
  345.                
  346.                 $character = "";
  347.                 if (!empty($row[3]))
  348.                 {
  349.                     if (preg_match('#class="Normal">... ([^<]*)<#i', $row[3], $charAry))
  350.                     {
  351.                         $character = trim(strip_tags($charAry[1]));
  352.                     }
  353.                 }
  354.                 $data['cast'] .= "$actor::$character::$actorid\n";
  355.             }
  356.         }
  357.     }
  358.    
  359.     // Genres
  360.     $genres = array(
  361.         'Amateur' => '',
  362.         'Eastern' => '',
  363.         'Experimentalfilm' => '',
  364.         'Mondo' => '',
  365.         'Kampfsport' => 'Sport',
  366.         'Biographie' => 'Biography',
  367.         'Katastrophen' => 'Thriller',
  368.         'Krimi' => 'Crime',
  369.         'Science-Fiction' => 'Sci-Fi',
  370.         'Kinder-/Familienfilm' => 'Family',
  371.         'Dokumentation' => 'Documentary',
  372.         'Action' => 'Action',
  373.         'Drama' => 'Drama',
  374.         'Abenteuer' => 'Adventure',
  375.         'Historienfilm' => 'History',
  376.         'Kurzfilm' => 'Short',
  377.         'Liebe/Romantik' => 'Romance',
  378.         'Heimatfilm' => 'Romance',
  379.         'Grusel' => 'Horror',
  380.         'Horror' => 'Horror',
  381.         'Erotik' => 'Adult',
  382.         'Hardcore' => 'Adult',
  383.         'Sex' => 'Adult',
  384.         'Musikfilm' => 'Musical',
  385.         'Animation' => 'Animation',
  386.         'Fantasy' => 'Fantasy',
  387.         'Trash' => 'Horror',
  388.         'Komödie' => 'Comedy',
  389.         'Krieg' => 'War',
  390.         'Mystery' => 'Mystery',
  391.         'Thriller' => 'Thriller',
  392.         'Tierfilm' => 'Documentary',
  393.         'Western' => 'Western',
  394.         'TV-Serie' => '',
  395.         'TV-Mini-Serie' => '',
  396.         'Sportfilm' => 'Sport',
  397.         'Splatter' => 'Horror',
  398.         'Manga/Anime' => 'Animation'
  399.     );
  400.     if (preg_match('/>Genre\(s\)\:.*?<b>(.*?)<\/b>/i', $resp['data'], $ary))
  401.     {
  402.         if (preg_match_all('/<a.*?>(.*?)<\/a>/i',$ary[1],$ary2, PREG_SET_ORDER))
  403.         {
  404.             foreach($ary2 as $row) {
  405.                 $genre = trim(html_entity_decode($row[1]));
  406.                 $genre = strip_tags($genre);
  407.                 if (!$genre) continue;
  408.                 if (isset($genres[$genre])) $data['genres'][] = $genres[$genre];
  409.             }
  410.         }
  411.     }
  412.    
  413.     // Fetch Version
  414.     $resp = httpClient(ofdbVersionUrl($id, $vid), $cache);
  415.     if (!$resp['success']) $CLIENTERROR .= $resp['error']."\n";
  416.     $resp['data'] = preg_replace('/[\r\n\t]/',' ', $resp['data']);
  417.    
  418.     // FSK
  419.     $fsks = array(
  420.         'FSK o.A.' => '0',
  421.         'FSK 6' => '6',
  422.         'FSK 12' => '12',
  423.         'FSK 16' => '16',
  424.         'FSK 18' => '18',
  425.         'Keine Jugendfreigabe' => '18',
  426.         'SPIO/JK' => '18',
  427.         'juristisch geprüft' => '',
  428.         'ungeprüft' => ''
  429.     );
  430.     if (preg_match('/>Freigabe:<.*?<b>(.*?)<\/tr>/i', $resp['data'], $ary))
  431.     {
  432.         $fsk = trim(html_entity_decode($ary[1]));
  433.         $fsk = strip_tags($fsk);
  434.         if (isset($fsks[$fsk])) $data['fsk'] = $fsks[$fsk];
  435.     }
  436.    
  437.     // Languages
  438.     // Languages (as Array)
  439.     $laguages = array(
  440.         'arabisch' => 'arabic',
  441.         'bulgarisch' => 'bulgarian',
  442.         'chinesisch' => 'chinese',
  443.         'tschechisch' => 'czech',
  444.         'dänisch' => 'danish',
  445.         'holändisch' => 'dutch',
  446.         'englisch' => 'english',
  447.         'französisch' => 'french',
  448.         'deutsch' => 'german',
  449.         'griechisch' => 'greek',
  450.         'ungarisch' => 'hungarian',
  451.         'isländisch' => 'icelandic',
  452.         'indisch' => 'indian',
  453.         'israelisch' => 'israeli',
  454.         'italienisch' => 'italian',
  455.         'japanisch' => 'japanese',
  456.         'koreanisch' => 'korean',
  457.         'norwegisch' => 'norwegian',
  458.         'polnisch' => 'polish',
  459.         'portugisisch' => 'portuguese',
  460.         'rumänisch' => 'romanian',
  461.         'russisch' => 'russian',
  462.         'serbisch' => 'serbian',
  463.         'spanisch' => 'spanish',
  464.         'schwedisch' => 'swedish',
  465.         'thailändisch' => 'thai',
  466.         'türkisch' => 'turkish',
  467.         'vietnamesisch' => 'vietnamese',
  468.         'kantonesisch' => 'cantonese',
  469.         'katalanisch' => 'catalan',
  470.         'zypriotisch' => 'cypriot',
  471.         'zyprisch' => 'cypriot',
  472.         'esperanto' => 'esperanto',
  473.         'gälisch' => 'gaelic',
  474.         'hebräisch' => 'hebrew',
  475.         'hindi' => 'hindi',
  476.         'jüdisch' => 'jewish',
  477.         'lateinisch' => 'latin',
  478.         'mandarin' => 'mandarin',
  479.         'serbokroatisch' => 'serbo-croatian',
  480.         'somalisch' => 'somali'
  481.     );
  482.     $lang_list = array();
  483.     if (preg_match('/>Tonformat:<.*?<b>(.*?)<\/b>/i', $resp['data'], $ary) &&
  484.         preg_match_all('/(\w+)(\s|<).*?br>/si', $ary[1], $langs, PREG_PATTERN_ORDER))
  485.     {
  486.         foreach($langs[1] as $language) {
  487.             $language = trim(strtolower($language));
  488.             $language = html_entity_decode(strip_tags($language));
  489.             $language = preg_replace('/\s+$/','',$language);
  490.             if (!$language) continue;
  491.             if (isset($laguages[$language])) $language = $laguages[$language];
  492.             else continue;
  493.             if (!$language) continue;
  494.             $lang_list[] = $language;
  495.         }
  496.         $data['language'] = trim(join(', ', array_unique($lang_list)));
  497.     }
  498.    
  499.     // Runtime
  500.     if (preg_match('/>Laufzeit:<.*?<b>(.*?)\s*Min/i', $resp['data'], $ary))
  501.     {
  502.         $ary[1] = preg_replace('/:.*/','', $ary[1]);
  503.         $data['runtime']  = trim($ary[1]);
  504.     }
  505.    
  506.     // EAN-Code
  507.     if (preg_match('/>EAN\/UPC<\/a>:.*?<b>\s*([0-9]+)\s*<\/b>/i', $resp['data'], $ary))
  508.     {
  509.         $data['barcode'] = $ary[1];
  510.     }
  511.    
  512.     return $data;
  513. }
  514.  
  515.  
  516. /**
  517.  * Get Url to visit OFDB for a specific actor
  518.  *
  519.  * @author  Chinamann <chinamann@users.sourceforge.net>
  520.  * @param   string  $name   The actor's name
  521.  * @param   string  $id The actor's external id
  522.  * @return  string  The visit URL
  523.  */
  524. function ofdbActorUrl($name, $id)
  525. {
  526.     global $ofdbServer;
  527.     global $ofdbIdPrefix;
  528.    
  529.     if ($id) {
  530.         $id = preg_replace('/^'.$ofdbIdPrefix.'/', '', $id);
  531.     } else {
  532.         $id = ofdbGetActorId($name);
  533.     }
  534.  
  535.     // now we have for shure an id
  536.     return ($id!=0) ? $ofdbServer.'/view.php?page=person&id='.$id : '';
  537. }
  538.  
  539. /**
  540.  * Parses Actor-Details
  541.  *
  542.  * Find image and detail URL for actor.
  543.  *
  544.  * @author  Chinamann <chinamann@users.sourceforge.net>
  545.  * @param   string  $name  Name of the actor
  546.  * @param   string  $id    Prefixed ofdb actor id
  547.  * @return  array          array with Actor-URL and Thumbnail
  548.  */
  549. function ofdbActor($name, $id)
  550. {
  551.     global $ofdbServer;
  552.  
  553.     if ($id) {
  554.         $id = preg_replace('/^'.$ofdbIdPrefix.'/', '', $id);
  555.     } else {
  556.         $id = ofdbGetActorId($name);
  557.     }
  558.  
  559.     // now we have for shure an id
  560.     $folderId = ($id < 1000) ? 0 : substr($id,0,strlen($id)-3);
  561.  
  562.     $imgUrl = $ofdbServer.'/images/person/'.$folderId.'/'.$id.'.jpg';
  563.    
  564.     $ary    = array();
  565.     $ary[0][0] = ofdbActorUrl($name, $id);
  566.     $ary[0][1] = $imgUrl;
  567.     return $ary;
  568. }
  569.  
  570. function ofdbGetActorId($name)
  571. {
  572.     global $ofdbServer;
  573.    
  574.     // try to guess the id -> first actor found with this name
  575.     $url = $ofdbServer.'/view.php?page=liste&Name='.urlencode(html_entity_decode_all($name));
  576.     $resp = httpClient($url, $cache);
  577.     if (!$resp['success']) $CLIENTERROR .= $resp['error']."\n";
  578.    
  579.     $resp['data'] = preg_replace('/[\r\n\t]/',' ', $resp['data']);
  580.    
  581.     return (preg_match('#view.php?page=person&id=([0-9]+)#i', $resp['data'], $ary)) ? $ary[1] : 0;
  582. }
  583.  
  584.  
  585. /**
  586.  * Get an array of all previous prefixes for the ImdbId
  587.  *
  588.  * @author  Chinamann <chinamann@users.sourceforge.net>
  589.  * @return  array     Associative array with ImdbId prefixes
  590.  */
  591. function ofdbImdbIdPrefixes()
  592. {
  593.     global $ofdbIdPrefix;
  594.     return array($ofdbIdPrefix);
  595. }
  596.  
  597. function ofdbDbg($text,$append = true)
  598. {
  599.     file_append('debug.txt', $text, $append);
  600. }
  601. ?>
  602.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement