PageRenderTime 60ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/scripts/feeds/xVoD/xVoD/php/scraper/cinetube/index.php

http://eboda-hd-for-all-500.googlecode.com/
PHP | 1219 lines | 1002 code | 87 blank | 130 comment | 85 complexity | 1c28fde03c5b701e51eb903d3167ef88 MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0
  1. <?php
  2. /*-------------------------
  3. * Developed by Maicros
  4. * GNU/GPL v2 Licensed
  5. * ------------------------*/
  6. include_once '../../config/config.php';
  7. include_once 'CinetubeTemplate.php';
  8. include_once "../../util/VideoUtil.php";
  9. include_once "../../util/RssScriptUtil.php";
  10. include_once '../../action/Action.php';
  11. include_once '../../action/rss/SaveBookmarkAction.php';
  12. include_once '../../action/rss/DeleteBookmarkAction.php';
  13. define("SCRAPER_URL", SERVER_HOST_AND_PATH . "php/scraper/cinetube/");
  14. define("CINETUBE_URL", "http://www.cinetube.es/" );
  15. if(isset($_GET["download"])) {
  16. $downloadfile = "/tmp/xvod_links.txt";
  17. if (file_exists( $downloadfile )){
  18. $extension = " > /dev/null 2>&1 & echo $!";
  19. $outputdir = "/tmp/hdd/volumes/HDD1/movie/";
  20. $command ="/opt/bin/wget -i$downloadfile -P $outputdir";
  21. exec($command.$extension, $op);
  22. }
  23. }
  24. else
  25. //Init session
  26. if(isset($_GET["PHPSESID"])) {
  27. session_id($_GET["PHPSESID"]);
  28. }
  29. session_start();
  30. if(isset($_GET["search"])) { //Search view
  31. $type = $_GET["type"];
  32. $search = $_GET["search"];
  33. switch($type) {
  34. case "doc":
  35. fetchDocumentarySearch($type,$search);
  36. break;
  37. case "mov":
  38. fetchMovieSearch($type,$search);
  39. break;
  40. case "ser":
  41. fetchSerieSearch($type,$search);
  42. break;
  43. }
  44. }else if(isset($_GET["play"])) { // Show play links --------------------------
  45. $type = $_GET["type"];
  46. $play = base64_decode($_GET["play"]);
  47. //$title = base64_decode($_GET["title"]);
  48. fetchPlaySources($type,$play);
  49. }else if(isset($_GET["episode"])) { // Show serie season episode links -------
  50. $type = $_GET["type"];
  51. $episodeLink = base64_decode($_GET["episode"]);
  52. $episodeName = base64_decode($_GET["episodeName"]);
  53. fetchSerieSeasonEpisode($type, $episodeName,$episodeLink);
  54. }else if(isset($_GET["season"])) { // Show serie season episodes--------------
  55. $type = $_GET["type"];
  56. $season = base64_decode($_GET["season"]);
  57. fetchSerieSeason($type, $season);
  58. }else if(isset($_GET["item"])) { // Show items ------------------------------
  59. $type = $_GET["type"];
  60. $item = base64_decode($_GET["item"]);
  61. $title = base64_decode($_GET["title"]);
  62. switch($type) {
  63. case "doc":
  64. fetchDocumentary($type,$item,$title);
  65. break;
  66. case "mov":
  67. fetchMovie($type,$item,$title);
  68. break;
  69. case "ser":
  70. fetchSerie($type,$item,$title);
  71. break;
  72. }
  73. }else if(isset($_GET["cat"])) { //Category view ----------------------------
  74. $type = $_GET["type"];
  75. $category = base64_decode($_GET["cat"]);
  76. $title = base64_decode($_GET["title"]);
  77. switch($type) {
  78. case "doc":
  79. fetchDocumentaryCategoryItems($type,$category,$title);
  80. break;
  81. case "mov":
  82. fetchMovieCategoryItems($type,$category,$title);
  83. break;
  84. case "ser":
  85. fetchSerieCategoryItems($type,$category,$title);
  86. break;
  87. }
  88. }else if(isset($_GET["type"])) { // Category list view ---------------------
  89. $type = $_GET["type"];
  90. switch($type) {
  91. case "doc":
  92. fetchDocumentaryCategories($type);
  93. break;
  94. case "mov":
  95. fetchMovieCategories($type);
  96. break;
  97. case "ser":
  98. fetchSerieCategories($type);
  99. break;
  100. }
  101. }else { // Show home principal view ---------------------------------------
  102. fetchHome();
  103. }
  104. //------------------------------------------------------------------------------
  105. //------------------------------------------------------------------------------
  106. /**
  107. * Get principal scraper view.
  108. */
  109. function fetchHome() {
  110. $template = new CinetubeTemplate();
  111. $template->addItem(
  112. resourceString("anime") . " - " . resourceString("movie"),
  113. resourceString("anime") . " - " . resourceString("movie"),
  114. SCRAPER_URL . "anime.php?type=mov" . URL_AMP . "PHPSESID=" . session_id(),
  115. ""
  116. );
  117. $template = new CinetubeTemplate();
  118. $template->addItem(
  119. resourceString("anime") . " - " . resourceString("serie"),
  120. resourceString("anime") . " - " . resourceString("serie"),
  121. SCRAPER_URL . "anime.php?type=ser" . URL_AMP . "PHPSESID=" . session_id(),
  122. ""
  123. );
  124. $template->addItem(
  125. resourceString("documentary"),
  126. resourceString("documentary"),
  127. SCRAPER_URL . "index.php?type=doc" . URL_AMP . "PHPSESID=" . session_id(),
  128. ""
  129. );
  130. $template->addItem(
  131. resourceString("movie"),
  132. resourceString("movie"),
  133. SCRAPER_URL . "index.php?type=mov" . URL_AMP . "PHPSESID=" . session_id(),
  134. ""
  135. );
  136. $template->addItem(
  137. resourceString("serie"),
  138. resourceString("serie"),
  139. SCRAPER_URL . "index.php?type=ser" . URL_AMP . "PHPSESID=" . session_id(),
  140. ""
  141. );
  142. $template->addItem(
  143. resourceString("configure"),
  144. resourceString("configure"),
  145. SCRAPER_URL . "config/setup.php" . URL_AMP . "PHPSESID=" . session_id(),
  146. ""
  147. );
  148. $template->generateView(CinetubeTemplate::VIEW_HOME, "Cinetube");
  149. }
  150. //------------------------------------------------------------------------------
  151. //------------------------------------------------------------------------------
  152. /**
  153. * Get documetnary categories
  154. */
  155. function fetchDocumentaryCategories($type) {
  156. $template = new CinetubeTemplate();
  157. $template->setType($type);
  158. $typeArray = array(
  159. resourceString("latest_releases")=>"documentales/",
  160. "Top " . resourceString("documentaries") =>"documentales-top/"
  161. );
  162. //Get web categories
  163. $content = file_get_contents("http://www.cinetube.es/documentales/");
  164. $content = html_entity_decode($content);
  165. //Get categories block
  166. preg_match("/<ul class=\"categorias\">(.*)<\/ul>/siU", $content, $matches);
  167. if($matches) {
  168. //Get categories links
  169. preg_match_all("/<a href=\"(.*)\"><span>(.*)</siU", $matches[1], $links, PREG_SET_ORDER);
  170. foreach ($links as $link) {
  171. $typeArray[$link[2]] = $link[1];
  172. }
  173. }
  174. //Add rss links to template
  175. foreach ($typeArray as $key => $value ) {
  176. $template->addItem(
  177. $key,
  178. resourceString("category") . " " . $key,
  179. SCRAPER_URL . "index.php?type=$type" . URL_AMP . "cat=" . base64_encode($value) . URL_AMP . "title=" . base64_encode($key) . URL_AMP . "PHPSESID=" . session_id(),
  180. ""
  181. );
  182. }
  183. //Add serach link to template
  184. $template->setSearch( array(
  185. resourceString("search_by") . "...",
  186. resourceString("search_by") . "...",
  187. "rss_command://search",
  188. SCRAPER_URL . "index.php?search=%s" . URL_AMP . "type=$type" . URL_AMP . "title=" . base64_encode("Search by") . URL_AMP . "PHPSESID=" . session_id(),
  189. ""
  190. )
  191. );
  192. $template->generateView(CinetubeTemplate::VIEW_CATEGORY, "Documentales");
  193. }
  194. /**
  195. * Get movie categories.
  196. */
  197. function fetchMovieCategories($type) {
  198. $template = new CinetubeTemplate();
  199. $template->setType($type);
  200. $typeArray = array(
  201. "Top " . resourceString("latest_releases")=>"peliculas/top-estrenos/",
  202. "Top " . resourceString("movies") =>"peliculas-top/",
  203. "Estrenos de Cine" => "peliculas/estrenos-de-cine/",
  204. "Estrenos de DVD" => "peliculas/estrenos-dvd/",
  205. "Estrenos Sub" => "peliculas/estrenos-sub/",
  206. "Solo HD-RIP" => "peliculas/filtrar/?idioma=&calidad=11&desde=&hasta=&categoria=&valoracion=",
  207. "Solo SUBs" => "peliculas/filtrar/?idioma=3&calidad=&desde=&hasta=&categoria=&valoracion=",
  208. "Solo V.O." => "peliculas/filtrar/?idioma=4&calidad=&desde=&hasta=&categoria=&valoracion="
  209. );
  210. //Get web categories
  211. $content = file_get_contents("http://www.cinetube.es/peliculas/");
  212. $content = html_entity_decode($content);
  213. //Get categories block
  214. preg_match("/<ul class=\"categorias\">(.*)<\/ul>/siU", $content, $matches);
  215. if($matches) {
  216. //Get categories links
  217. preg_match_all("/<a href=\"(.*)\"><span>(.*)</siU", $matches[1], $links, PREG_SET_ORDER);
  218. foreach ($links as $link) {
  219. $typeArray[$link[2]] = $link[1];
  220. }
  221. }
  222. //Add rss links to template
  223. foreach ($typeArray as $key => $value ) {
  224. $template->addItem(
  225. $key,
  226. resourceString("category") . " " . $key,
  227. SCRAPER_URL . "index.php?type=$type" . URL_AMP . "cat=" . base64_encode($value) . URL_AMP . "title=" . base64_encode($key) . URL_AMP . "PHPSESID=" . session_id(),
  228. ""
  229. );
  230. }
  231. //Add serach link to template
  232. $template->setSearch( array(
  233. resourceString("search_by") . "...",
  234. resourceString("search_by") . "...",
  235. "rss_command://search",
  236. SCRAPER_URL . "index.php?search=%s" . URL_AMP . "type=$type" . URL_AMP . "title=" . base64_encode("Search by") . URL_AMP . "PHPSESID=" . session_id(),
  237. ""
  238. )
  239. );
  240. $template->generateView(CinetubeTemplate::VIEW_CATEGORY, "Peliculas");
  241. }
  242. /**
  243. * Get serie categories.
  244. */
  245. function fetchSerieCategories($type) {
  246. $template = new CinetubeTemplate();
  247. $template->setType($type);
  248. $typeArray = array(
  249. resourceString("latest_releases")=>"series/",
  250. "Top " . resourceString("series") =>"series-top/"
  251. );
  252. //Get web categories
  253. $content = file_get_contents("http://www.cinetube.es/series/");
  254. $content = html_entity_decode($content);
  255. //Get categories block
  256. preg_match("/<ul class=\"categorias\">(.*)<\/ul>/siU", $content, $matches);
  257. if($matches) {
  258. //Get categories links
  259. preg_match_all("/<a href=\"(.*)\"><span>(.*)</siU", $matches[1], $links, PREG_SET_ORDER);
  260. foreach ($links as $link) {
  261. $typeArray[$link[2]] = $link[1];
  262. }
  263. }
  264. //Add rss links to template
  265. foreach ($typeArray as $key => $value ) {
  266. $template->addItem(
  267. $key,
  268. resourceString("category") . " " . $key,
  269. SCRAPER_URL . "index.php?type=$type" . URL_AMP . "cat=" . base64_encode($value) . URL_AMP . "title=" . base64_encode($key) . URL_AMP . "PHPSESID=" . session_id(),
  270. ""
  271. );
  272. }
  273. //Add search link to template
  274. $template->setSearch( array(
  275. resourceString("search_by") . "...",
  276. resourceString("search_by") . "...",
  277. "rss_command://search",
  278. SCRAPER_URL . "index.php?search=%s" . URL_AMP . "type=$type" . URL_AMP . "title=" . base64_encode("Search by") . URL_AMP . "PHPSESID=" . session_id(),
  279. ""
  280. )
  281. );
  282. $template->generateView(CinetubeTemplate::VIEW_CATEGORY, "Series");
  283. }
  284. //------------------------------------------------------------------------------
  285. //------------------------------------------------------------------------------
  286. function fetchPlaySources($type,$play) {
  287. $template = new CinetubeTemplate();
  288. $template->setType($type);
  289. //Check for session info
  290. if(isset($_SESSION["cinetubeTitle"])) {
  291. $movieTitle = $_SESSION["cinetubeTitle"];
  292. $description = $_SESSION["cinetubeDescription"];
  293. $image = $_SESSION["cinetubeImage"];
  294. $template->setMovieTitle($movieTitle);
  295. $template->setDescription($description);
  296. $template->setImage($image);
  297. }
  298. $content = file_get_contents("http://www.cinetube.es" . $play);
  299. //Get megavideo links
  300. if( strpos($content, "www.megavideo.com/?v=" ) ) {
  301. preg_match_all("|www\.megavideo\.com\/\?v\=(.*)\"|U", $content, $links);
  302. if($links && $links[1]) {
  303. $links = $links[1];
  304. $links = array_unique( $links );
  305. foreach($links as $megavideo_id ) {
  306. if( COOKIE_STATE_ACTIVATED ) {
  307. $array = VideoUtil::generateMegavideoPremiumLink($megavideo_id);
  308. if($array) {
  309. //echo $megavideo_id;
  310. $template->addMediaItem(
  311. $array[0],
  312. "",
  313. $array[1],
  314. "",
  315. $array[2]
  316. );
  317. }
  318. }
  319. }
  320. }
  321. }
  322. //Get megaupload links
  323. if( strpos($content, "www.megaupload.com/?d=" ) ) {
  324. preg_match_all("|www\.megaupload\.com\/\?d\=(.*)\"|U", $content, $links);
  325. if($links && $links[1]) {
  326. $links = $links[1];
  327. $links = array_unique( $links );
  328. foreach($links as $megaupload_id ) {
  329. if( COOKIE_STATE_ACTIVATED ) {
  330. $array = VideoUtil::generateMegauploadPremiumLink($megaupload_id);
  331. if($array) {
  332. //echo $megavideo_id;
  333. $template->addMediaItem(
  334. $array[0],
  335. "",
  336. $array[1],
  337. "",
  338. $array[2]
  339. );
  340. }
  341. }
  342. }
  343. }
  344. }
  345. $template->generateView(CinetubeTemplate::VIEW_PLAY, "");
  346. }
  347. //------------------------------------------------------------------------------
  348. //------------------------------------------------------------------------------
  349. /**
  350. * Search documentaries that contents given word.
  351. */
  352. function fetchDocumentarySearch($type,$search) {
  353. $template = new CinetubeTemplate();
  354. $template->setSearchTerm($search);
  355. $template->setType($type);
  356. //If page equal "x" goto page number list, in other case process actual category page
  357. if( isset($_GET["page"]) && $_GET["page"] == "x" ) {
  358. $maxPages = $_GET["pages"];
  359. for($i=1;$i<=$maxPages;++$i) {
  360. $template->addItem(
  361. $i,
  362. resourceString("goto_page") . $i,
  363. SCRAPER_URL . "index.php?type=" . $type . URL_AMP . "search=" . $search . URL_AMP . "page=" . $i . URL_AMP . "pages=" . $maxPages . URL_AMP . "PHPSESID=" . session_id(),
  364. ""
  365. );
  366. }
  367. $template->generateView(CinetubeTemplate::VIEW_PAGE_NUMBERS );
  368. }else {
  369. if(!isset($_GET["page"])) {
  370. $pages = getPages($type,$search);
  371. $template->setActualPage(1);
  372. $template->setMaxPages($pages[1]);
  373. $content = $pages[0];
  374. }else {
  375. $template->setActualPage($_GET["page"]);
  376. $template->setMaxPages($_GET["pages"]);
  377. $content = file_get_contents(CINETUBE_URL . $category . "buscar/documentales/?palabra=" . $search . "&pag=" . $_GET["page"]);
  378. }
  379. //Parse first page documentaries
  380. preg_match_all("/<div class\=\"peli_item textcenter\">(.*)<\/div>\s*<\/div>/siU", $content, $divs, PREG_SET_ORDER);
  381. if($divs) {
  382. //$divs = $divs[0];
  383. foreach ($divs as $movie) {
  384. $movie = $movie[0];
  385. preg_match_all("/(<a href=\"(.*)\">)*\s*<img\s*src=\"(.*)\" alt=\"(.*)\"\s(\/)*>\s*(<\/a>)*/siU", $movie, $info, PREG_SET_ORDER);
  386. //Get info
  387. parseCoverPageInfo($info,$type,$title,$template,false);
  388. }
  389. }
  390. $template->generateView(CinetubeTemplate::VIEW_DOCUMENTARY, $title);
  391. }
  392. }
  393. /**
  394. * Search movies that contents given word.
  395. */
  396. function fetchMovieSearch($type,$search) {
  397. $template = new CinetubeTemplate();
  398. $template->setType($type);
  399. $template->setSearchTerm($search);
  400. //If page equal "x" goto page number list, in other case process actual category page
  401. if( isset($_GET["page"]) && $_GET["page"] == "x" ) {
  402. $maxPages = $_GET["pages"];
  403. for($i=1;$i<=$maxPages;++$i) {
  404. $template->addItem(
  405. $i,
  406. resourceString("goto_page") . $i,
  407. SCRAPER_URL . "index.php?type=" . $type . URL_AMP . "search=" . $search . URL_AMP . "page=" . $i . URL_AMP . "pages=" . $maxPages . URL_AMP . "PHPSESID=" . session_id(),
  408. ""
  409. );
  410. }
  411. $template->generateView(CinetubeTemplate::VIEW_PAGE_NUMBERS );
  412. }else {
  413. if(!isset($_GET["page"])) {
  414. $pages = getPages($type,$search);
  415. $template->setActualPage(1);
  416. $template->setMaxPages($pages[1]);
  417. $content = $pages[0];
  418. }else {
  419. $template->setActualPage($_GET["page"]);
  420. $template->setMaxPages($_GET["pages"]);
  421. $content = file_get_contents(CINETUBE_URL . $category . "buscar/peliculas/?palabra=" . $search . "&pag=" . $_GET["page"]);
  422. }
  423. //Parse first page movies
  424. preg_match_all("/<div class\=\"peli_item textcenter\">(.*)<\/div>\s*<\/div>/siU", $content, $divs, PREG_SET_ORDER);
  425. if($divs) {
  426. //$divs = $divs[0];
  427. foreach ($divs as $movie) {
  428. $movie = $movie[0];
  429. preg_match_all("/(<a href=\"(.*)\">)*\s*<img\s*src=\"(.*)\" alt=\"(.*)\"\s(\/)*>\s*(<\/a>)*/siU", $movie, $info, PREG_SET_ORDER);
  430. //Get info
  431. parseCoverPageInfo($info,$type,$title,$template,true);
  432. }
  433. }
  434. $template->generateView(CinetubeTemplate::VIEW_MOVIE, $title);
  435. }
  436. }
  437. /**
  438. * Search series that contents given word.
  439. */
  440. function fetchSerieSearch($type,$search) {
  441. $template = new CinetubeTemplate();
  442. $template->setType($type);
  443. $template->setSearchTerm($search);
  444. //If page equal "x" goto page number list, in other case process actual category page
  445. if( isset($_GET["page"]) && $_GET["page"] == "x" ) {
  446. $maxPages = $_GET["pages"];
  447. for($i=1;$i<=$maxPages;++$i) {
  448. $template->addItem(
  449. $i,
  450. resourceString("goto_page") . $i,
  451. SCRAPER_URL . "index.php?type=" . $type . URL_AMP . "search=" . $search . URL_AMP . "page=" . $i . URL_AMP . "pages=" . $maxPages . URL_AMP . "PHPSESID=" . session_id(),
  452. ""
  453. );
  454. }
  455. $template->generateView(CinetubeTemplate::VIEW_PAGE_NUMBERS );
  456. }else {
  457. if(!isset($_GET["page"])) {
  458. $pages = getPages($type,$search);
  459. $template->setActualPage(1);
  460. $template->setMaxPages($pages[1]);
  461. $content = $pages[0];
  462. }else {
  463. $template->setActualPage($_GET["page"]);
  464. $template->setMaxPages($_GET["pages"]);
  465. $content = file_get_contents(CINETUBE_URL . $category . "buscar/series/?palabra=" . $search . "&pag=" . $_GET["page"]);
  466. }
  467. //Parse first page series
  468. $newlines = array("\t","\n","\r","\x20\x20","\0","\x0B");
  469. $input = str_replace($newlines, "", $content );
  470. preg_match("/<ul class\=\"ver_series_list\">(.*)<\/ul>/siU", $input, $divs);
  471. preg_match_all("/<li>(.*)<\/li>/siU", $divs[0], $divs, PREG_SET_ORDER);
  472. if($divs) {
  473. //$divs = $divs[0];
  474. foreach ($divs as $movie) {
  475. $movie = $movie[1];
  476. preg_match_all("/(<a href=\"(.*)\">)*\s*<img\s*src=\"(.*)\" alt=\"(.*)\"\s(\/)*>\s*(<\/a>)*|<p class\=\"tit_ficha\">(.*)<\/p>/siU", $movie, $info, PREG_SET_ORDER);
  477. //Get info
  478. $movieIcons = array();
  479. foreach( $info as $key => $detail ) {
  480. if( $key == 0 ) {
  481. if( strpos($detail[2],'"') ) {
  482. $movieLink = substr($detail[2], 0, strpos($detail[2],'"'));
  483. }else {
  484. $movieLink = $detail[2];
  485. }
  486. $movieThumbnail = html_entity_decode($detail[3]);
  487. }else if(count($detail) == 8) {
  488. $movieTitle = $detail[7];
  489. }else if($detail[4]) {
  490. if(!strpos($detail[4],"escarga")) {
  491. array_push( $movieIcons, html_entity_decode($detail[4]) );
  492. }
  493. }else {
  494. //megavideo, veoh, tutv, google
  495. array_push( $movieIcons, html_entity_decode(substr($detail[3], strrpos($detail[3], "/")+1, strrpos($detail[3], "\.")-4)) );
  496. }
  497. }
  498. //Add video
  499. $template->addItem(
  500. $movieTitle,
  501. strtoupper(getArrayString($movieIcons).""),
  502. SCRAPER_URL . "index.php?type=ser" . URL_AMP . "item=" . base64_encode($movieLink) . URL_AMP . "title=" . base64_encode($title) . URL_AMP . "PHPSESID=" . session_id(),
  503. $movieThumbnail
  504. );
  505. }
  506. }
  507. $template->generateView(CinetubeTemplate::VIEW_SERIE, $title);
  508. }
  509. }
  510. //------------------------------------------------------------------------------
  511. //------------------------------------------------------------------------------
  512. /**
  513. * Get given documentary category pages and first page items.
  514. */
  515. function fetchDocumentaryCategoryItems($type,$category,$title) {
  516. $template = new CinetubeTemplate();
  517. $template->setCategory($category);
  518. $template->setType($type);
  519. //If page equal "x" goto page number list, in other case process actual category page
  520. if( isset($_GET["page"]) && $_GET["page"] == "x" ) {
  521. $maxPages = $_GET["pages"];
  522. for($i=1;$i<=$maxPages;++$i) {
  523. $template->addItem(
  524. $i,
  525. resourceString("goto_page") . $i,
  526. SCRAPER_URL . "index.php?type=" . $type . URL_AMP . "cat=" . base64_encode($category) . URL_AMP . "page=" . $i . URL_AMP . "pages=" . $maxPages . URL_AMP . "PHPSESID=" . session_id(),
  527. ""
  528. );
  529. }
  530. $template->generateView(CinetubeTemplate::VIEW_PAGE_NUMBERS );
  531. }else {
  532. if(!isset($_GET["page"])) {
  533. $pages = getPages($category);
  534. $template->setActualPage(1);
  535. $template->setMaxPages($pages[1]);
  536. $content = $pages[0];
  537. }else {
  538. $template->setActualPage($_GET["page"]);
  539. $template->setMaxPages($_GET["pages"]);
  540. $content = file_get_contents(CINETUBE_URL . $category . $_GET["page"] . ".html");
  541. }
  542. //Parse first page documentaries
  543. preg_match_all("/<div class\=\"peli_item textcenter( peli_item_puntos)?\">(.*)<\/div>\s*<\/div>/siU", $content, $divs, PREG_SET_ORDER);
  544. if($divs) {
  545. //$divs = $divs[0];
  546. foreach ($divs as $movie) {
  547. $movie = $movie[0];
  548. preg_match_all("/(<a href=\"(.*)\">)*\s*<img\s*src=\"(.*)\" alt=\"(.*)\"\s(\/)*>\s*(<\/a>)*/siU", $movie, $info, PREG_SET_ORDER);
  549. //Get info
  550. parseCoverPageInfo($info,$type,$title,$template,false);
  551. }
  552. }
  553. $template->generateView(CinetubeTemplate::VIEW_DOCUMENTARY, $title);
  554. }
  555. }
  556. /**
  557. * Get given movie category pages and first page items.
  558. */
  559. function fetchMovieCategoryItems($type,$category,$title) {
  560. $template = new CinetubeTemplate();
  561. $template->setCategory($category);
  562. $template->setType($type);
  563. //If page equal "x" goto page number list, in other case process actual category page
  564. if( isset($_GET["page"]) && $_GET["page"] == "x" ) {
  565. $maxPages = $_GET["pages"];
  566. for($i=1;$i<=$maxPages;++$i) {
  567. $template->addItem(
  568. $i,
  569. resourceString("goto_page") . $i,
  570. SCRAPER_URL . "index.php?type=" . $type . URL_AMP . "cat=" . base64_encode($category) . URL_AMP . "page=" . $i . URL_AMP . "pages=" . $maxPages,
  571. ""
  572. );
  573. }
  574. $template->generateView(CinetubeTemplate::VIEW_PAGE_NUMBERS );
  575. }else {
  576. if(!isset($_GET["page"])) {
  577. $pages = getPages($category);
  578. $template->setActualPage(1);
  579. $template->setMaxPages($pages[1]);
  580. $content = $pages[0];
  581. }else {
  582. $template->setActualPage($_GET["page"]);
  583. $template->setMaxPages($_GET["pages"]);
  584. $content = file_get_contents(CINETUBE_URL . $category . $_GET["page"] . ".html");
  585. }
  586. //Parse first page movies
  587. preg_match_all("/<div class\=\"peli_item textcenter( peli_item_puntos)?\">(.*)<\/div>\s*<\/div>/siU", $content, $divs, PREG_SET_ORDER);
  588. if($divs) {
  589. //$divs = $divs[0];
  590. foreach ($divs as $movie) {
  591. $movie = $movie[0];
  592. preg_match_all("/(<a href=\"(.*)\">)*\s*<img\s*src=\"(.*)\" alt=\"(.*)\"\s(\/)*>\s*(<\/a>)*/siU", $movie, $info, PREG_SET_ORDER);
  593. //Get info
  594. parseCoverPageInfo($info,$type,$title,$template,true);
  595. }
  596. }
  597. $template->generateView(CinetubeTemplate::VIEW_MOVIE, $title);
  598. }
  599. }
  600. /**
  601. * Get given serie category pages, first page items or page number list.
  602. */
  603. function fetchSerieCategoryItems($type,$category,$title) {
  604. //Init template
  605. $template = new CinetubeTemplate();
  606. $template->setCategory($category);
  607. $template->setType($type);
  608. //If page equal "x" goto page number list, in other case process actual category page
  609. if( isset($_GET["page"]) && $_GET["page"] == "x" ) {
  610. $maxPages = $_GET["pages"];
  611. for($i=1;$i<=$maxPages;++$i) {
  612. $template->addItem(
  613. $i,
  614. resourceString("goto_page") . $i,
  615. SCRAPER_URL . "index.php?type=" . $type . URL_AMP . "cat=" . base64_encode($category) . URL_AMP . "page=" . $i . URL_AMP . "pages=" . $maxPages . URL_AMP . "PHPSESID=" . session_id(),
  616. ""
  617. );
  618. }
  619. $template->generateView(CinetubeTemplate::VIEW_PAGE_NUMBERS );
  620. }else {
  621. if(!isset($_GET["page"])) {
  622. $pages = getPages($category);
  623. $template->setActualPage(1);
  624. $template->setMaxPages($pages[1]);
  625. $content = $pages[0];
  626. }else {
  627. $template->setActualPage($_GET["page"]);
  628. $template->setMaxPages($_GET["pages"]);
  629. $content = file_get_contents(CINETUBE_URL . $category . $_GET["page"] . ".html");
  630. }
  631. //Parse first page series
  632. $newlines = array("\t","\n","\r","\x20\x20","\0","\x0B");
  633. $input = str_replace($newlines, "", $content );
  634. preg_match("/<ul class\=\"ver_series_list( ver_series_list_puntos)?\">(.*)<\/ul>/siU", $input, $divs);
  635. preg_match_all("/<li>(.*)<\/li>/siU", $divs[0], $divs, PREG_SET_ORDER);
  636. //For new serie releases dont works
  637. if($category != "series/") {
  638. if($divs) {
  639. //$divs = $divs[0];
  640. foreach ($divs as $movie) {
  641. $movie = $movie[1];
  642. preg_match_all("/(<a href=\"(.*)\">)*\s*<img\s*src=\"(.*)\" alt=\"(.*)\"\s(\/)*>\s*(<\/a>)*|<p class\=\"tit_ficha\">(.*)<\/p>/siU", $movie, $info, PREG_SET_ORDER);
  643. //Get info
  644. $movieIcons = array();
  645. foreach( $info as $key => $detail ) {
  646. if( $key == 0 ) {
  647. if( strpos($detail[2],'"') ) {
  648. $movieLink = substr($detail[2], 0, strpos($detail[2],'"'));
  649. }else {
  650. $movieLink = $detail[2];
  651. }
  652. $movieThumbnail = html_entity_decode($detail[3]);
  653. }else if(count($detail) == 8) {
  654. $movieTitle = $detail[7];
  655. }else if($detail[4]) {
  656. if(!strpos($detail[4],"escarga")) {
  657. array_push( $movieIcons, html_entity_decode($detail[4]) );
  658. }
  659. }else {
  660. //megavideo, veoh, tutv, google
  661. array_push( $movieIcons, html_entity_decode(substr($detail[3], strrpos($detail[3], "/")+1, strrpos($detail[3], "\.")-4)) );
  662. }
  663. }
  664. //Add video
  665. $template->addItem(
  666. $movieTitle,
  667. strtoupper(getArrayString($movieIcons).""),
  668. SCRAPER_URL . "index.php?type=ser" . URL_AMP . "item=" . base64_encode($movieLink) . URL_AMP . "title=" . base64_encode($title) . URL_AMP . "PHPSESID=" . session_id(),
  669. $movieThumbnail
  670. );
  671. }
  672. }
  673. $template->generateView(CinetubeTemplate::VIEW_SERIE, $title);
  674. }else {
  675. if($divs) {
  676. //$divs = $divs[0];
  677. foreach ($divs as $movie) {
  678. $movie = $movie[1];
  679. preg_match_all("/<img src\=\"(.*)\"(.*)<a class\=\"tit_ficha\"(.*)href\=\"(.*)\">(.*)<\/a>(.*)<p class\=\"tem_fich\">(.*)<\/p>/siU", $movie, $info, PREG_SET_ORDER);
  680. $info = $info[0];
  681. if( strpos($info[7],"Cap") ) {
  682. $template->addItem(
  683. html_entity_decode($info[5]),
  684. $info[7],
  685. SCRAPER_URL . "index.php?type=" . $type . URL_AMP . "episodeName=" . base64_encode($info[7]) . URL_AMP . "episode=" . base64_encode($info[4]) . URL_AMP . "seasonNum=" . URL_AMP . "image=" . base64_encode($info[1]) . URL_AMP . "serieTitle=" . base64_encode($info[5]) . URL_AMP . "PHPSESID=" . session_id(),
  686. $info[1]
  687. );
  688. }else {
  689. }
  690. }
  691. }
  692. $template->generateView(CinetubeTemplate::VIEW_SERIE, $title);
  693. }
  694. }
  695. }
  696. //------------------------------------------------------------------------------
  697. //------------------------------------------------------------------------------
  698. /**
  699. * Get movie links.
  700. */
  701. function fetchMovie($type,$item,$title) {
  702. $template = new CinetubeTemplate();
  703. $template->setType($type);
  704. $content = file_get_contents( CINETUBE_URL . substr($item,1) );
  705. $newlines = array("\t","\n","\r","\x20\x20","\0","\x0B");
  706. $content = str_replace($newlines, "", html_entity_decode($content));
  707. preg_match("/<div class\=\"ficha_img pelicula_img\"><img src\=\"(.*)\"(.*)<div class\=\"ficha_des\">(.*)<h1 class\=\"bold\">(.*)<\/h1>(.*)<p>(.*)<\/p>/U",$content,$description);
  708. $thumbnail = $description[1];
  709. $movieTitle = $description[4];
  710. $template->setMovieTitle($movieTitle);
  711. $description = $description[6];
  712. $template->setImage($thumbnail);
  713. //Save info to session
  714. $_SESSION["cinetubeTitle"] = $movieTitle;
  715. $_SESSION["cinetubeDescription"] = $description;
  716. $_SESSION["cinetubeImage"] = $thumbnail;
  717. //Get mirrors
  718. preg_match_all("/<div class\=\"tit_opts\"><a(.*)href\=\"(.*)\"(.*)><p\>(.*)<\/p><p\><span\>(.*)<\/span><\/p>(.*)<\/div>/siU", $content, $divs, PREG_SET_ORDER);
  719. if($divs) {
  720. foreach ($divs as $value) {
  721. //Add video
  722. if(!strpos(strtolower($value[4]),"rar")) {
  723. $template->addItem(
  724. $value[4] . "\n" . str_replace("| ", "\n", $value[5]),
  725. strtoupper($description),
  726. SCRAPER_URL . "index.php?type=" . $type . URL_AMP . "play=" . base64_encode( $value[2] ) . URL_AMP . "PHPSESID=" . session_id(),
  727. $thumnail
  728. );
  729. }
  730. }
  731. }
  732. $template->generateView(CinetubeTemplate::VIEW_MOVIE_DETAIL,$title);
  733. }
  734. //------------------------------------------------------------------------------
  735. //------------------------------------------------------------------------------
  736. /**
  737. * Get documentary episodes, or redirect to show documentary links if it hasn't episodes.
  738. */
  739. function fetchDocumentary($type,$item,$title) {
  740. //Get content
  741. $content = file_get_contents(CINETUBE_URL . substr($item,1));
  742. $newlines = array("\t","\n","\r","\x20\x20","\0","\x0B");
  743. $content = str_replace($newlines, "", $content );
  744. //Show episode detail or episode list
  745. if( strstr($content,"tit_opts") ) {
  746. fetchDocumentaryEpisode($type,$item,$title,$content);
  747. }else {
  748. $template = new CinetubeTemplate();
  749. $template->setType($type);
  750. //Get page info
  751. preg_match("/<div class\=\"ficha_img pelicula_img\">(.*)src\=\"(.*)\"/U",$content,$thumnail);
  752. $thumnail = $thumnail[2];
  753. $template->setImage($thumnail);
  754. preg_match("/<h1 class\=\"big\"><a href\=\"(.*)\">(.*)<\/a><\/h1>/U",$content,$seasonTitle);
  755. $seasonTitle = html_entity_decode($seasonTitle[2]);
  756. $template->setMovieTitle($seasonTitle);
  757. preg_match("/<div class\=\"ficha_des\"><h1 class\=\"bold\">(.*)<\/h1><p>(.*)<\/p><\/div>/U",$content,$description);
  758. $description = strtoupper( html_entity_decode($description[2]) );
  759. // preg_match("/<table class\=\"tb_peliculas\">(.*)<\/table>/U",$content,$detail);
  760. // $detail = html_entity_decode($detail[0]);
  761. //Get episodes
  762. preg_match_all("/<div class\=\"title\">\s<a(.*)href\=\"(.*)\">(.*)<\/a>/siU", $content, $divs, PREG_SET_ORDER);
  763. if($divs) {
  764. foreach ($divs as $value) {
  765. //Add video
  766. $template->addItem(
  767. str_replace( $seasonTitle, "", html_entity_decode($value[3]) ),
  768. $description . $detail,
  769. SCRAPER_URL . "index.php?type=" . $type . URL_AMP . "item=" . base64_encode( $value[2] ) . URL_AMP . "image=" . base64_encode($thumnail) . URL_AMP . "title=" . base64_encode($seasonTitle) . URL_AMP . "PHPSESID=" . session_id(),
  770. $thumnail
  771. );
  772. }
  773. }
  774. $template->generateView(CinetubeTemplate::VIEW_DOCUMENTARY_EPISODE, $title);
  775. }
  776. }
  777. /**
  778. * Get links from episode, or documentary without episodes.
  779. */
  780. function fetchDocumentaryEpisode($type,$item,$title,$content=null) {
  781. $template = new CinetubeTemplate();
  782. $template->setType($type);
  783. if(!$content) {
  784. $content = file_get_contents( CINETUBE_URL . substr($item,1) );
  785. $newlines = array("\t","\n","\r","\x20\x20","\0","\x0B");
  786. $content = str_replace($newlines, "", html_entity_decode($content));
  787. }
  788. if(strpos($content,"ficha_img pelicula_img")) {
  789. preg_match("/<div class\=\"ficha_img pelicula_img\"><img src\=\"(.*)\"(.*)<div class\=\"ficha_des\">(.*)<h1 class\=\"bold\">(.*)<\/h1>(.*)<p>(.*)<\/p>/U",$content,$description);
  790. $thumbnail = $description[1];
  791. $movieTitle = html_entity_decode($description[4]);
  792. $template->setMovieTitle($movieTitle);
  793. $description = html_entity_decode($description[6]);
  794. $template->setImage($thumbnail);
  795. //Save info to session
  796. $_SESSION["cinetubeTitle"] = $movieTitle;
  797. $_SESSION["cinetubeDescription"] = $description;
  798. $_SESSION["cinetubeImage"] = $thumbnail;
  799. preg_match_all("/<div class\=\"tit_opts\"><a(.*)href\=\"(.*)\"(.*)><p>(.*)<\/p><p><span\>(.*)<\/span><\/p>(.*)<\/div>/siU", $content, $divs, PREG_SET_ORDER);
  800. //G et mirrors
  801. if($divs) {
  802. foreach ($divs as $value) {
  803. //Add video
  804. $template->addItem(
  805. html_entity_decode($value[4] . "\n" . str_replace("| ", "\n", $value[5])),
  806. $description,
  807. SCRAPER_URL . "index.php?type=" . $type . URL_AMP . "play=" . base64_encode( $value[2] ) . URL_AMP . "PHPSESID=" . session_id(),
  808. $thumbnail
  809. );
  810. }
  811. }
  812. }else {
  813. if(isset($_GET["image"])) {
  814. $template->setImage(base64_decode($_GET["image"]));
  815. }
  816. if(isset($_GET["title"])) {
  817. $template->setMovieTitle(base64_decode($_GET["title"]));
  818. }
  819. preg_match_all("/<div class\=\"tit_opts\"><a(.*)href\=\"(.*)\"(.*)><p>(.*)<span(.*)span><\/p><p><span\>(.*)<\/span><\/p>(.*)<\/div>/siU", $content, $divs, PREG_SET_ORDER);
  820. //Get mirrors
  821. if($divs) {
  822. foreach ($divs as $value) {
  823. //Add video
  824. $template->addItem(
  825. html_entity_decode($value[4] . "\n" . str_replace("| ", "\n", $value[6])),
  826. $description,
  827. SCRAPER_URL . "index.php?type=" . $type . URL_AMP . "play=" . base64_encode( $value[2] ) . URL_AMP . "PHPSESID=" . session_id(),
  828. $thumbnail
  829. );
  830. }
  831. }
  832. }
  833. $template->generateView(CinetubeTemplate::VIEW_DOCUMENTARY_EPISODE,$title);
  834. }
  835. //------------------------------------------------------------------------------
  836. //------------------------------------------------------------------------------
  837. /**
  838. * Get serie links.
  839. */
  840. function fetchSerie($type,$item,$title) {
  841. $template = new CinetubeTemplate();
  842. $template->setType($type);
  843. if( isset($_SESSION["seasons"]) && array_key_exists($item, unserialize($_SESSION["seasons"]))) {
  844. $seasons = unserialize( $_SESSION["seasons"] );
  845. $seasons = $seasons[$item];
  846. $serieTitle = $_SESSION["serieTitle"];
  847. $serieDescription = $_SESSION["serieDescription"];
  848. $serieCover = $_SESSION["serieCover"];
  849. }else {
  850. //Get serie seasons and info, save to session
  851. $content = file_get_contents("http://www.cinetube.es" . $item);
  852. $newlines = array("\t","\n","\r","\x20\x20","\0","\x0B");
  853. $content = str_replace($newlines, "", $content );
  854. //Get serie info
  855. preg_match("/<div class\=\"ficha_des des_move\">(.*)<a(.*)>(.*)<\/a><span>(.*)<\/span><\/h1><p>(.*)<\/p>(.*)caratulas.cinetube.es\/series\/(.*)\"/U",$content,$divs);
  856. $serieTitle = html_entity_decode( $divs[3] );
  857. $serieCategory = html_entity_decode( $divs[4] );
  858. $serieDescription = html_entity_decode( $divs[5] );
  859. $serieCover = "http://caratulas.cinetube.es/series/" . $divs[7];
  860. //Get serie seasons
  861. preg_match_all("/<a href\=\"(.*)\">(.*)<\/a>(.*)<a class\=\"caps\"(.*)>(.*)<\/a>/siU", $divs[6], $divs, PREG_SET_ORDER);
  862. $seasons = array();
  863. foreach ($divs as $season) {
  864. $episodeNumber = explode(" ",$season[5]);
  865. $seasons[$season[2]] = array($season[1],$episodeNumber[0]);
  866. }
  867. //Save data to session
  868. session_start();
  869. $_SESSION["serieTitle"] = $serieTitle;
  870. $_SESSION["serieCategory"] = $serieCategory;
  871. $_SESSION["serieDescription"] = $serieDescription;
  872. $_SESSION["serieCover"] = $serieCover;
  873. $_SESSION["seasons"] = serialize( array( $item => $seasons ) );
  874. }
  875. $template->setSerie($seasons);
  876. $template->setMovieTitle($serieTitle);
  877. $template->setDescription($serieDescription);
  878. $template->setImage($serieCover);
  879. $template->generateView(CinetubeTemplate::VIEW_SERIE_SEASON, $title);
  880. }
  881. /**
  882. * Get serie season links
  883. */
  884. function fetchSerieSeason($type,$seasonTitle,$title=null) {
  885. $template = new CinetubeTemplate();
  886. $template->setType($type);
  887. //Recover session info
  888. $serieTitle = $_SESSION["serieTitle"];
  889. $serieCategory = $_SESSION["serieCategory"];
  890. $serieDescription = $_SESSION["serieDescription"];
  891. $serieCover = $_SESSION["serieCover"];
  892. $seasons = unserialize( $_SESSION["seasons"] );
  893. $_SESSION["seasonTitle"] = $seasonTitle;
  894. $seasonKey = array_keys($seasons);
  895. $seasonKey = $seasonKey[0];
  896. $seasonLink = $seasons[$seasonKey];
  897. $seasonLink = $seasonLink[$seasonTitle];
  898. //If array count isn't 3 load data from page
  899. if( count($seasonLink) == 3 ) {
  900. $episodes = $seasonLink[2];
  901. }else {
  902. $seasonLink = $seasonLink[0];
  903. //Get season episodes and save to sesion array
  904. $content = file_get_contents("http://www.cinetube.es" . $seasonLink);
  905. $newlines = array("\t","\n","\r","\x20\x20","\0","\x0B");
  906. $content = str_replace($newlines, "", $content );
  907. preg_match_all("/<div class\=\"title\"> <a class\=\"bold\" href\=\"(.*)\">(.*)<\/a>/siU", $content, $divs, PREG_SET_ORDER);
  908. //Create episode array and save in session
  909. if($divs) {
  910. $episodes = array();
  911. foreach ($divs as $episode) {
  912. $episodes[$episode[2]] = $episode[1];
  913. }
  914. $arraySeasons = $seasons[$seasonKey];
  915. array_push( $arraySeasons[$seasonTitle], $episodes );
  916. $_SESSION["seasons"] = serialize( array( $seasonKey => $arraySeasons ) );
  917. }
  918. }
  919. //Set data to template
  920. $template->setSerie($seasons[$seasonKey]);
  921. $template->setSeason($episodes);
  922. $template->setSeasonTitle($seasonTitle);
  923. $template->setMovieTitle($serieTitle);
  924. $template->setDescription($serieDescription);
  925. $template->setImage($serieCover);
  926. $template->generateView(CinetubeTemplate::VIEW_SERIE_EPISODE, $title);
  927. }
  928. /**
  929. * Get serie season episode links
  930. */
  931. function fetchSerieSeasonEpisode($type, $episodeTitle, $episodeLink, $title=null) {
  932. $template = new CinetubeTemplate();
  933. $template->setType($type);
  934. //Recover session info
  935. $seasonTitle = $_SESSION["seasonTitle"];
  936. if(isset($_GET["serieTitle"])) {
  937. $serieTitle = base64_decode($_GET["serieTitle"]);
  938. }else {
  939. $serieTitle = $_SESSION["serieTitle"];
  940. }
  941. $serieCategory = $_SESSION["serieCategory"];
  942. $serieDescription = $_SESSION["serieDescription"];
  943. if( isset($_GET["image"])) {
  944. $serieCover = base64_decode($_GET["image"]);
  945. }else {
  946. $serieCover = $_SESSION["serieCover"];
  947. }
  948. $seasons = unserialize( $_SESSION["seasons"] );
  949. //Set data to template
  950. //$template->setSerie($seasons[$seasonKey]);
  951. $template->setEpisodeTitle($episodeTitle);
  952. $template->setSeasonTitle($seasonTitle);
  953. $template->setSerieTitle($serieTitle);
  954. $template->setDescription($serieDescription);
  955. $template->setImage($serieCover);
  956. //Save info to session
  957. $_SESSION["cinetubeTitle"] = $serieTitle . "\n" . $seasonTitle . " | " . $episodeTitle;
  958. $_SESSION["cinetubeDescription"] = $serieDescription;
  959. $_SESSION["cinetubeImage"] = $serieCover;
  960. //Get page content
  961. $content = file_get_contents( CINETUBE_URL . substr($episodeLink,1) );
  962. $newlines = array("\t","\n","\r","\x20\x20","\0","\x0B");
  963. $content = str_replace($newlines, "", html_entity_decode($content));
  964. //Get links
  965. preg_match_all("/<div class\=\"tit_opts\"><a(.*)href\=\"(.*)\"(.*)><p>(.*)<span(.*)span><\/p><p><span\>(.*)<\/span><\/p>(.*)<\/div>/siU", $content, $divs, PREG_SET_ORDER);
  966. //Get mirrors
  967. if($divs) {
  968. foreach ($divs as $value) {
  969. //Add video
  970. $template->addItem(
  971. html_entity_decode($value[4] . "\n" . str_replace("| ", "\n", $value[6])),
  972. $serieDescription,
  973. SCRAPER_URL . "index.php?type=" . $type . URL_AMP . "play=" . base64_encode( $value[2] ) . URL_AMP . "PHPSESID=" . session_id(),
  974. $serieCover
  975. );
  976. }
  977. }
  978. $template->generateView(CinetubeTemplate::VIEW_SERIE_EPISODE_LINK);
  979. }
  980. /**
  981. * -----------------------------------------------------------------------------
  982. * Get a comma separeted string from array.
  983. */
  984. function getArrayString(array $array) {
  985. $result = "";
  986. for ($i=0; $i<count($array); ++$i) {
  987. $result .= $array[$i];
  988. if( $i<count($array)-1) {
  989. $result .= ", ";
  990. }
  991. }
  992. return $result;
  993. }
  994. /**
  995. * -----------------------------------------------------------------------------
  996. * Get category page count and first page content
  997. */
  998. function getPages($category,$search=null) {
  999. $readAgain = true;
  1000. if($search) {
  1001. switch($category) {
  1002. case "doc":
  1003. $word = "documentales";
  1004. break;
  1005. case "mov":
  1006. $word = "peliculas";
  1007. break;
  1008. case "ser":
  1009. $word = "series";
  1010. break;
  1011. }
  1012. $foundPages = array("/buscar/$word/?palabra=".$search."&pag=1" => "1");
  1013. $initPage = "buscar/$word/?palabra=" . $search;
  1014. }else {
  1015. $foundPages = array("/".$category."1.html" => "1");
  1016. $initPage = $category;
  1017. }
  1018. //Add pages
  1019. while( $readAgain == true ) {
  1020. $url = CINETUBE_URL . $initPage;
  1021. $content = file_get_contents($url);
  1022. if(!$initContentPage) {
  1023. $initContentPage = $content;
  1024. }
  1025. $newlines = array("\t","\n","\r","\x20\x20","\0","\x0B");
  1026. $content = str_replace($newlines, "", html_entity_decode($content));
  1027. if(strpos($content, '<li class="pagina">') ) {
  1028. //Get pages links
  1029. preg_match_all("/<li class\=\"pagina\"><a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a><\/li>/siU", $content, $pages, PREG_SET_ORDER);
  1030. if($pages) {
  1031. $addedPages = 0;
  1032. foreach ($pages as $page) {
  1033. if(!array_key_exists($page[2], $foundPages)) {
  1034. $foundPages[$page[2]] = $page[3];
  1035. $initPage = substr($page[2],1);
  1036. ++$addedPages;
  1037. }
  1038. }
  1039. //If read less than 4 pages is the last page list
  1040. if($addedPages < 4) {
  1041. $readAgain = false;
  1042. }
  1043. }else {
  1044. $readAgain = false;
  1045. }
  1046. }else {
  1047. $readAgain = false;
  1048. }
  1049. }
  1050. return array($initContentPage,count($foundPages));
  1051. }
  1052. /**
  1053. * Parse cinetube cover info and add rss item to template.
  1054. * @param $info
  1055. * @param $type Movie, documentary or serie (mov, doc, ser)
  1056. * @param $title
  1057. * @param $template
  1058. * @param $showRipType True to parse rip type.
  1059. */
  1060. function parseCoverPageInfo($info,$type,$title,$template,$showRipType) {
  1061. //Get info
  1062. $movieIcons = array();
  1063. foreach( $info as $key => $detail ) {
  1064. if($key == 1 ) {
  1065. preg_match_all("/<span class\=\"rosa\">(.*)<\/span>/siU", $detail[0], $rips);
  1066. if($rips && (count($rips) > 1) ) {
  1067. $movieRipType = getArrayString($rips[1]);
  1068. }
  1069. }
  1070. //
  1071. if( $key == 0 ) {
  1072. if( strpos($detail[2],'"') ) {
  1073. $movieLink = substr($detail[2], 0, strpos($detail[2],'"'));
  1074. }else {
  1075. $movieLink = $detail[2];
  1076. }
  1077. $movieTitle = html_entity_decode($detail[4]);
  1078. $movieThumbnail = html_entity_decode($detail[3]);
  1079. }else if($detail[4]) {
  1080. if(!strpos($detail[4],"escarga")) {
  1081. array_push( $movieIcons, html_entity_decode($detail[4]) );
  1082. }else {
  1083. array_push( $movieIcons, "MEGAUPLOAD" );
  1084. }
  1085. }else {
  1086. //megavideo, veoh, tutv, google
  1087. array_push( $movieIcons, html_entity_decode(substr($detail[3], strrpos($detail[3], "/")+1, strrpos($detail[3], "\.")-4)) );
  1088. }
  1089. }
  1090. //Add video
  1091. if($showRipType) {
  1092. $movieDescription = strtoupper($movieRipType . " | " . getArrayString($movieIcons) . "" );
  1093. }else {
  1094. $movieDescription = strtoupper( getArrayString($movieIcons) . "" );
  1095. }
  1096. $template->addItem(
  1097. $movieTitle,
  1098. $movieDescription,
  1099. SCRAPER_URL . "index.php?type=$type" . URL_AMP . "item=" . base64_encode($movieLink) . URL_AMP . "title=" . base64_encode($title),
  1100. $movieThumbnail
  1101. );
  1102. }
  1103. ?>