PageRenderTime 47ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/library/imdb/imdb_nowplaying.class.php

https://github.com/hegylako/openTracker
PHP | 60 lines | 26 code | 4 blank | 30 comment | 2 complexity | 464bcc4b444ee3302cadc266c6857325 MD5 | raw file
Possible License(s): MIT
  1. <?php
  2. #############################################################################
  3. # IMDBPHP (c) Giorgos Giagas & Itzchak Rehberg #
  4. # written by Giorgos Giagas #
  5. # extended & maintained by Itzchak Rehberg <izzysoft AT qumran DOT org> #
  6. # http://www.izzysoft.de/ #
  7. # ------------------------------------------------------------------------- #
  8. # IMDBPHP NOW PLAYING (c) Ricardo Silva & Itzchak Rehberg #
  9. # written by Ricardo Silva (banzap) <banzap@gmail.com> #
  10. # http://www.ricardosilva.pt.tl/ #
  11. # ------------------------------------------------------------------------- #
  12. # This program is free software; you can redistribute and/or modify it #
  13. # under the terms of the GNU General Public License (see doc/LICENSE) #
  14. #############################################################################
  15. # $Id: imdb_nowplaying.class.php 471 2011-10-11 12:16:23Z izzy $
  16. require_once (dirname(__FILE__)."/mdb_base.class.php");
  17. #=================================================[ The IMDB Person class ]===
  18. /** Obtain the Now Playing Movies in theaters of USA, from IMDB
  19. * @package openTracker
  20. * @class imdb_nowplaying
  21. * @author Ricardo Silva (banzap) <banzap@gmail.com>
  22. * @author Itzchak Rehberg
  23. * @version $Revision: 471 $ $Date: 2011-10-11 14:16:23 +0200 (Di, 11. Okt 2011) $
  24. */
  25. class imdb_nowplaying {
  26. var $nowplayingpage = "http://www.imdb.com/movies-in-theaters/";
  27. var $page = "";
  28. /** Constructor: Obtain the raw data from IMDB site
  29. * @constructor imdb_nowplaying
  30. */
  31. function __construct() {
  32. $req = new MDB_Request($this->nowplayingpage);
  33. $req->sendRequest();
  34. $this->page=$req->getResponseBody();
  35. $this->revision = preg_replace('|^.*?(\d+).*$|','$1','$Revision: 471 $');
  36. }
  37. /** Retrieve the Now Playing Movies
  38. * @method getNowPlayingMovies
  39. * @return array of IMDB IDs
  40. */
  41. function getNowPlayingMovies() {
  42. $matchinit = '<h1 class="header">';
  43. $matchend = "<!-- begin TOP_RHS -->";
  44. $init_pos = strpos($this->page,$matchinit);
  45. $end_pos = strpos($this->page,$matchend);
  46. //$pattern = '!href="/title/tt(\d{7})/!';
  47. $pattern = '!rg/in-theaters/overview-title/images/b.gif\?link=/title/tt(\d+)!';
  48. if ( preg_match_all($pattern, substr($this->page,$init_pos,$end_pos - $init_pos), $matches) ) {
  49. $res = array_values(array_unique($matches[1]));
  50. } else {
  51. $res = array();
  52. }
  53. return $res;
  54. }
  55. }
  56. ?>