PageRenderTime 44ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/scripts/feeds/xVoD/xVoD/php/scraper/10starmovies/index.php

http://eboda-hd-for-all-500.googlecode.com/
PHP | 303 lines | 263 code | 21 blank | 19 comment | 16 complexity | 2db101e6b25a6d8df04919711fe501fd MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0
  1. <?php
  2. /* -------------------------
  3. * Developed by Maicros
  4. * modified by Mezzo
  5. * to use loombo
  6. * GNU/GPL v2 Licensed
  7. * ------------------------ */
  8. include_once '../../config/config.php';
  9. include_once 'TenstarmoviesTemplate.php';
  10. include_once "../../util/VideoUtil.php";
  11. include_once "../../util/RssScriptUtil.php";
  12. include_once '../../action/Action.php';
  13. include_once '../../action/rss/SaveBookmarkAction.php';
  14. include_once '../../action/rss/DeleteBookmarkAction.php';
  15. define("SCRAPER_URL", SERVER_HOST_AND_PATH . "php/scraper/10starmovies/");
  16. if(isset($_GET["download"])) {
  17. $downloadfile = "/tmp/xvod_links.txt";
  18. if (file_exists( $downloadfile )){
  19. $extension = " > /dev/null 2>&1 & echo $!";
  20. $outputdir = "/tmp/hdd/volumes/HDD1/movie/";
  21. $command ="/opt/bin/wget -i$downloadfile -P $outputdir";
  22. exec($command.$extension, $op);
  23. }
  24. }
  25. else
  26. if (isset($_GET["serie"])) {
  27. $serieLink = base64_decode($_GET["serie"]);
  28. $serieTitle = base64_decode($_GET["title"]);
  29. fetchSerie($serieLink, $serieTitle);
  30. }else if (isset($_GET["season"])) {
  31. $season = $_GET["season"];
  32. fetchSeason($season);
  33. }else if (isset($_GET["episode"])) {
  34. $season = $_GET["seasonNum"];
  35. $episode = $_GET["episode"];
  36. $episodeName = base64_decode($_GET["episodeName"]);
  37. fetchEpisode($season,$episode,$episodeName);
  38. } else {
  39. fetchSeries();
  40. }
  41. //------------------------------------------------------------------------------
  42. //------------------------------------------------------------------------------
  43. function fetchEpisode($season,$episode,$episodeName) {
  44. $template = new TenstarmoviesTemplate();
  45. if(isset($_GET["PHPSESID"])) {
  46. session_id($_GET["PHPSESID"]);
  47. session_start();
  48. $serie = unserialize( $_SESSION["serie"] );
  49. $coverImage = $_SESSION["coverImage"];
  50. $title = $_SESSION["title"];
  51. $link = $serie[$season];
  52. $link = $link[$episode];
  53. $episodeLink = $link[1];
  54. $template->setEpisodeName($episodeName);
  55. $template->setCoverImage($coverImage);
  56. $template->setTitle($title);
  57. $content = file_get_contents($episodeLink);
  58. $newlines = array("\t","\n","\r","\x20\x20","\0","\x0B");
  59. $input = str_replace($newlines, "", utf8_decode( $content) );
  60. preg_match("/<script type=\"text\/javascript\"> function loadinitial(.*)<div id=\"video_loading_stat\">/U", $input, $div);
  61. //Get episode description
  62. if(strpos($input,"<div id=\"incomplete")) {
  63. preg_match("/<div id\=\"incomplete\" style\=\"display\:block\;\">(.*)</U", $input, $des);
  64. }else {
  65. preg_match("/<div class\=\"sum\">(.*)</U", $input, $des);
  66. }
  67. if($des) {
  68. $template->setDescription($des[1]);
  69. }
  70. //LOOMBO
  71. if($div && strpos($div[1],"loombo")) {
  72. $div2 = $div;
  73. preg_match_all("/<span>(.*)<\/span>/siU", $div2[1], $div2);
  74. //Get only loombo
  75. if( $div2) {
  76. $i2 = 0;
  77. foreach ($div2[1] as $value2) {
  78. if(strpos($value2,"loombo")) {
  79. preg_match("/load_source_new\((.*)\,/U", $value2, $id2);
  80. $loombo_id = file_get_contents(substr($episodeLink,0,strrpos($episodeLink,"/")) . "/play_source.php?id=".$id2[1]);
  81. preg_match("/href=\"http:\/\/loombo\.com\/(.*)\"/U", $loombo_id, $loombo_id);
  82. if( $loombo_id ) {
  83. $content = file_get_contents("http://loombo.com/embed-".$loombo_id[1]."-0x0.html");
  84. preg_match("/\(\'flashvars\',\'file=(.*)\'\)\;/U", $content, $links);
  85. if($links) {
  86. $link = $links[1];
  87. $template->addMediaItem(
  88. "[Loombo " . $i2 . "]",
  89. substr($link, strrpos($link,"/")+1),
  90. $link,
  91. "",
  92. VideoUtil::getEnclosureMimetype($link)
  93. );
  94. ++$i2;
  95. }
  96. }
  97. }
  98. if($i2 > 1) {
  99. break;
  100. }
  101. }
  102. }
  103. }
  104. //MEGAVIDEO
  105. if($div && strpos($div[1],"megavideo")) {
  106. preg_match_all("/<span>(.*)<\/span>/siU", $div[1], $div);
  107. //Get only megavideos
  108. if( $div) {
  109. $i = 0;
  110. foreach ($div[1] as $value) {
  111. if(strpos($value,"megavideo")) {
  112. preg_match("/load_source_new\((.*)\,/U", $value, $id);
  113. $megavideo_id = file_get_contents(substr($episodeLink,0,strrpos($episodeLink,"/")) . "/play_source.php?id=".$id[1]);
  114. preg_match("/megavideo.com\/\?v\\=(.*)\"/U", $megavideo_id, $megavideo_id);
  115. if( $megavideo_id ) {
  116. $megavideo_id = $megavideo_id[1];
  117. if( COOKIE_STATE_ACTIVATED ) {
  118. $array = VideoUtil::generateMegavideoPremiumLink($megavideo_id);
  119. if( $array && $array[2]) {
  120. $template->addMediaItem(
  121. "[Megavideo " . $i . "]",
  122. $array[0],
  123. $array[1],
  124. "" . $megavideo_id,
  125. $array[2]
  126. );
  127. ++$i;
  128. }
  129. }
  130. }
  131. }
  132. if($i > 1) {
  133. break;
  134. }
  135. }
  136. }
  137. }
  138. $template->generateView(TenstarmoviesTemplate::VIEW_PLAY, $episodeName );
  139. }
  140. }
  141. //------------------------------------------------------------------------------
  142. //------------------------------------------------------------------------------
  143. function fetchSeason($season) {
  144. $template = new TenstarmoviesTemplate();
  145. //Recover from session
  146. if(isset($_GET["PHPSESID"])) {
  147. session_id($_GET["PHPSESID"]);
  148. session_start();
  149. $backgroundImage = $_SESSION["backgroundImage"];
  150. $coverImage = $_SESSION["coverImage"];
  151. $description = $_SESSION["description"];
  152. $headerImage = $_SESSION["headerImage"];
  153. $title = $_SESSION["title"];
  154. $serie = unserialize( $_SESSION["serie"] );
  155. //Set data to template
  156. $template->setEpisode($serie[$season]);
  157. $template->setSelectedSeason($season);
  158. $template->setBackgroundImage($backgroundImage);
  159. $template->setCoverImage($coverImage);
  160. $template->setDescription($description);
  161. $template->setHeaderImage($headerImage);
  162. $template->setTitle($title);
  163. $template->setSerie($serie);
  164. //Show template view
  165. $template->generateView(TenstarmoviesTemplate::VIEW_EPISODE);
  166. }
  167. }
  168. //------------------------------------------------------------------------------
  169. //------------------------------------------------------------------------------
  170. function fetchSerie($serieLink, $serieTitle) {
  171. $template = new TenstarmoviesTemplate();
  172. //GET HEADER IMAGE AND DESCRIPTION
  173. $content = file_get_contents($serieLink . "about.html");
  174. $newlines = array("\t","\n","\r","\x20\x20","\0","\x0B");
  175. $input = str_replace($newlines, "", utf8_decode( $content) );
  176. //Get header image, description and cover
  177. preg_match("/<div class\=\"header\-middle\" style\=\"background:url\((.*)\)\;(.*)<img src\=\"(.*)\"(.*)>(.*)<div style\=\"margin\-bottom\:10px\;\">(.*)<\/div>/U", $input, $div);
  178. if($div) {
  179. $headerImage = $div[1];
  180. $coverImage = $div[3];
  181. $description = $div[6];
  182. }
  183. //--------------------------------------------------------------------------
  184. // GET SEASONS AND EPISODES
  185. $content = file_get_contents($serieLink. "sitemap.xml");
  186. $newlines = array("\t", "\n", "\r", "\x20\x20", "\0", "\x0B");
  187. $input = str_replace($newlines, "", utf8_decode($content));
  188. //$input = strstr($input, "<td valign=\"top\" width=\"33%\">");
  189. preg_match_all("/<loc>(.*)<\/loc>/siU", $input, $div);
  190. $serie = array();
  191. if ($div) {
  192. $div = $div[1];
  193. $links = array();
  194. for ($i = count($div); $i >= 0; --$i) {
  195. $value = $div[$i];
  196. if (strpos($value, "Episode_")) {
  197. preg_match_all("/(.*)_Online_Season_(.*)_Episode_(.*)_(.*)\.html/siU", $value, $links);
  198. $seasonNum = $links[2];
  199. $episodeNum = $links[3];
  200. $episodeName = $links[4];
  201. if (!array_key_exists($seasonNum[0], $serie)) {
  202. $serie[$seasonNum[0]] = array($episodeNum[0] => array( str_replace("_", " ", $episodeName[0]), $value ) );
  203. } else {
  204. $season = $serie[$seasonNum[0]];
  205. $season[$episodeNum[0]] = array( str_replace("_", " ", $episodeName[0]), $value );
  206. $serie[$seasonNum[0]] = $season;
  207. }
  208. }
  209. }
  210. //Save all in session
  211. if(isset($_GET["PHPSESID"])) {
  212. session_id($_GET["PHPSESID"]);
  213. session_start();
  214. $_SESSION["backgroundImage"] = $backgroundImage;
  215. $_SESSION["coverImage"] = $coverImage;
  216. $_SESSION["description"] = $description;
  217. $_SESSION["headerImage"] = $headerImage;
  218. $_SESSION["title"] = $serieTitle;
  219. $_SESSION["serie"] = serialize($serie);
  220. }
  221. $template->setBackgroundImage($backgroundImage);
  222. $template->setCoverImage($coverImage);
  223. $template->setDescription($description);
  224. $template->setHeaderImage($headerImage);
  225. $template->setTitle($serieTitle);
  226. $template->setSerie($serie);
  227. $template->generateView(TenstarmoviesTemplate::VIEW_SEASON);
  228. }
  229. }
  230. //------------------------------------------------------------------------------
  231. //------------------------------------------------------------------------------
  232. function fetchSeries() {
  233. $template = new TenstarmoviesTemplate();
  234. $seriesLoaded = false;
  235. //Start session
  236. if(isset($_GET["PHPSESID"])) {
  237. session_id($_GET["PHPSESID"]);
  238. }
  239. session_start();
  240. //Check for loaded series on session
  241. if(isset($_SESSION["tenstarSeries"])) {
  242. $div = unserialize($_SESSION["tenstarSeries"]);
  243. $seriesLoaded = true;
  244. }else {
  245. //Get principal page and parse category list
  246. $content = file_get_contents("http://10starmovies.com/Tv-Shows/");
  247. $newlines = array("\t","\n","\r","\x20\x20","\0","\x0B");
  248. $input = str_replace($newlines, "", utf8_decode( $content) );
  249. $input = strstr($input, "<td valign=\"top\" width=\"33%\">");
  250. preg_match_all("/<div><a href\=\"(.*)\"(.*)<span class\=\\\'description\\\'>(.*)<\/span>(.*)\">(.*)<\/a><\/div>/U", $input, $div, PREG_SET_ORDER);
  251. }
  252. if($div) {
  253. foreach ($div as $value) {
  254. $serieName = html_entity_decode($value[5]);
  255. $description = $value[3];
  256. $link = $value[1];
  257. $serieLink = SCRAPER_URL . "index.php?serie=" . base64_encode($link) . URL_AMP . "title=" . base64_encode($serieName). URL_AMP . "PHPSESID=" . session_id();
  258. $template->addItem(
  259. $serieName,
  260. $description,
  261. $serieLink,
  262. ""
  263. );
  264. }
  265. }
  266. //If series has been loaded from page, save to session
  267. if(!$seriesLoaded){
  268. $_SESSION["tenstarSeries"] = serialize($div);
  269. }
  270. $template->generateView(TenstarmoviesTemplate::VIEW_SERIE, "10StarMovies TV-Series" );
  271. }
  272. ?>