Scriptburn movie plugin comes with the theme.
The plugin imports movies and tv shows & links from primewire.ag.
My website link is: http://ift.tt/1XyUrIM
The problem is it only imports title example : The Green Mile It should be : The Green Mile (1999)
Anyone could help me to solve this issue?
Here is the template code:
<?php
class wpmovies_primewire
{
protected $html = null;
protected $html_text = null;
protected $url_cache = null;
protected $tmp_dir = null;
var $domain_url = "";
var $captcha_sleep = 6;
public function __construct()
{
$this->html = wpmovies_object('html');
$this->html_dom = wpmovies_object('html_dom');
$this->url_cache = wpmovies_object('urlcache');
// $this->url_cache->debug = false;
$this->set_cache_folder(get_temp_dir());
$this->domain_url = wpmovies_get_setting('primewire_url');
}
function imdburl_to_linkurl($url, $is_show = false)
{
$reg = "~(tt\d{6,})~";
preg_match_all($reg, $url, $arrMatches);
if (!@$arrMatches[0][0])
{
return "";
}
else
{
$id = $arrMatches[0][0];
}
return wpmovies_get_setting('primewire_url') . "/item.php?imdb=$id";
}
function strip_page_id($data)
{
$page_id = false;
if (isset($data['page_id']))
{
if (is_array($data['page_id']))
{
$page_id = $data['page_id'];
}
else
{
$p = @unserialize(stripslashes(urldecode($data['page_id'])));
if (is_array($p))
{
$page_id = $p;
}
else
{
$page_id = array('primewire' => $data['page_id']);
}
}
}
else
{
//print_r($data);
$page_id = (urldecode($data['meta_extra']['page_id']));
// die($page_id);
if ($page_id)
{
$page_id = @unserialize($page_id);
if (!is_array($page_id))
{
$page_id = array('primewire' => $page_id);
}
}
}
return $page_id;
}
function generate_url($post_detail, $fetch_id = false, $s = 0, $e = 0)
{
$this->html = wpmovies_object('html');
$this->html_dom = wpmovies_object('html_dom');
$this->url_cache = wpmovies_object('urlcache');
$url = "";
$page_id = $this->strip_page_id($post_detail);
if (!is_array($page_id) && !$post_detail['imdb'])
{
return $url;
}
if (is_array($page_id) || !$post_detail['imdb'])
{
$page_id = $page_id['primewire'];
if ($post_detail['post_type'] == 'movies')
{
$url = wpmovies_get_setting('primewire_url') . "/watch-$page_id-xx";
}
elseif ($post_detail['post_type'] == 'shows')
{
$url = wpmovies_get_setting('primewire_url') . "/tv-" . $page_id . "-xy" . ($s && $e ? "/season-$s-episode-$e" : '');
}
}
elseif ($post_detail['imdb'] && $fetch_id)
{
$provider = identify_movie_info_url($post_detail['imdb']);
if ($provider['name'] == 'imdb')
{
$url = $this->imdburl_to_linkurl($post_detail['imdb']);
$ret = $this->parse_page_item($url, $cache = true, $details = true, $links = false);
if ($ret[0])
{
$ret = $ret[1];
$page_id = (int) @$ret['details']['page_id']['primewire'];
$url = wpmovies_get_setting('primewire_url') . "/watch-" . $page_id . "-xy" . ($s && $e ? "/season-$s-episode-$e" : '');
return $url;
}
}
}
return $url;
}
function set_cache_folder($path)
{
$this->html = wpmovies_object('html');
$this->html_dom = wpmovies_object('html_dom');
$this->url_cache = wpmovies_object('urlcache');
if (!$this->url_cache)
{
return;
}
$this->url_cache->cache_folder = $path;
}
function get_cache_folder($path)
{
$this->html = wpmovies_object('html');
$this->html_dom = wpmovies_object('html_dom');
$this->url_cache = wpmovies_object('urlcache');
if (!$this->url_cache)
{
return;
}
return $this->url_cache->cache_folder;
}
function parse_array($beg_tag, $close_tag)
{
$this->html = wpmovies_object('html');
$this->html_dom = wpmovies_object('html_dom');
$this->url_cache = wpmovies_object('urlcache');
preg_match_all("($beg_tag.*$close_tag)siU", $this->html, $matching_data);
return $matching_data[0];
}
function fetch_page($url, $verify_text = "", $cache = false)
{
$this->html = wpmovies_object('html');
$this->html_dom = wpmovies_object('html_dom');
$this->url_cache = wpmovies_object('urlcache');
$this->url_cache->verify_text = $verify_text;
$time = time();
$ret = $this->url_cache->cache($url, md5($url) . ".html", $cache);
//log_local((time() - $time) . " Seconds to fetch");
return $ret;
}
function no_item_in_page($data)
{
$str = "Sorry but I couldn't find anything like that";
return stripos($data, $str) === false ? false : true;
}
function is_resumeable($data)
{
$resumable_errors = array('Empty reply from server', 'Operation timed out');
return $data && array_find($data, $resumable_errors);
}
function wait_and_fetch($url, $signature, $cache, $retry = 5)
{
$this->html = wpmovies_object('html');
$this->html_dom = wpmovies_object('html_dom');
$this->url_cache = wpmovies_object('urlcache');
$j = 0;
$resumable_errors = array('Empty reply from server', 'Operation timed out');
while (true)
{
$ret = $this->fetch_page($url, $signature, $cache);
// print_r($ret );
if (!$ret[0])
{
if ($this->is_resumeable($ret[2]))
{
log_local("Error:$ret[1] retrying ");
sleep(1);
continue;
}
else
{
return $ret;
}
}
//print_nice($ret);
$this->html_text = $ret[2];
if (!$this->is_expected_page($this->html_text, $signature))
{
if ($this->is_expected_page($this->html_text, 'We suspect that you might be a robot'))
{
$j++;
if ($j > $retry)
{
log_local("Found captcha retried");
return array(0, 'Found captcha');
}
else
{
log_local("Found captcha sleeping for " . $this->captcha_sleep . " seconds [$j]");
sleep($this->captcha_sleep);
continue;
}
}
else
{
$ret = array(0, 'Unexpected page signature', $ret[1], $signature, $this->html_text);
return $ret;
}
}
else
{
return $ret;
}
}
}
function search_items($text, $cache = true)
{
$url = wpmovies_get_setting('primewire_url') . "/index.php?search_keywords=" . urlencode($text);
$items = $this->parse_page_items($url, $cache);
return $items;
}
function parse_page_items($url, $cache = false)
{
$this->html = wpmovies_object('html');
$this->html_dom = wpmovies_object('html_dom');
$this->url_cache = wpmovies_object('urlcache');
$signature = 'items found';
$this->html_text = "";
$ret = $this->wait_and_fetch($url, $signature, $cache);
if ($this->no_item_in_page($ret[2]))
{
return array(0, "no items");
}
$items = array();
if (!$ret[0])
{
return $ret;
}
$this->html_text = $ret[2];
$ret_items = $this->html->get_HTMLtag('class', 'featured_movie_item', $this->html_text, 'div');
$items_featured = array();
foreach ($ret_items as &$item)
{
$v = $this->html->read_value($item, 'a', 'href');
$t = $this->html->read_value($item, 'a', 'title');
if ($t)
{
$t = explode("(", $t);
$t = trim($t[0]);
$t = substr($t, 5);
}
if ($this->domain_url)
{
$v = substr($v, 0, 1) == "/" ? $this->domain_url . $v : $v;
}
$items_featured[] = array('url' => $v, 'title' => trim($t), 'featured' => 1);
}
$ret_items = $this->html->get_HTMLtag('class', 'index_item index_item_ie', $this->html_text, 'div');
foreach ($ret_items as &$item)
{
$v = $this->html->read_value($item, 'a', 'href');
$t = $this->html->read_value($item, 'a', 'title');
if ($t)
{
$t = explode("(", $t);
$t = trim($t[0]);
$t = substr($t, 5);
}
if ($this->domain_url)
{
$v = substr($v, 0, 1) == "/" ? $this->domain_url . $v : $v;
}
$title = trim($t);
$key = array_search($title, array_column($items_featured, 'title'));
if ($key === false)
{
$items[] = array('url' => $v, 'title' => $title, 'featured' => 0);
}
}
//$items=array_merge( $items_featured,$items);
return array(1, $items);
}
function parse_featured_items($data)
{
}
function get_tvshow_sessions($url, $cache = true, $details = true)
{
$this->html = wpmovies_object('html');
$this->html_dom = wpmovies_object('html_dom');
$this->url_cache = wpmovies_object('urlcache');
$session = array();
$signature = '<strong>Released:</strong>';
$this->html_text = "";
$ret = $this->wait_and_fetch($url, $signature, $cache);
if (!$ret[0])
{
return $ret;
}
$this->html_text = $ret[2];
$cnt = $this->html->get_HTMLtag('class', 'tv_episode_item', $this->html_text, 'div', 0);
$dtl = $this->parse_item_info();
//$item
// [0] => <div class="tv_episode_item"> <a href="/tv-5211-South-Park/season-1-episode-0">E0
// <span class="tv_episode_name"> - The Spirit of Christmas (Jesus vs. Frosty)</span>
//<span class="tv_num_versions">[ 3 Links ]</span></a> </div>
$page_id = 0;
foreach ($cnt as &$item)
{
if (stripos($item, 'transp2') === false)
{
$title = $this->html->get_HTMLtag($attr = 'class', $value = 'tv_episode_name', $item);
$title = trim(@$title[0]);
$title = trim(substr($title, 0, 1) == "-" ? substr($title, 1) : $title);
$href = $this->html->read_value($item, 'a', 'href');
$href = explode("/", $href);
$id = $href[1];
$href = $href[count($href) - 1];
$href = str_replace(array('season-', 'episode-'), "", $href);
$href = explode("-", $href);
$href[0] = (int) $href[0];
//$href[0] = $href[0] == 0 ? 1 : $href[0];
$href[1] = (int) $href[1];
//$href[1] = $href[1] == 0 ? 1 : $href[1];
$id = explode("-", $id);
if (!$page_id)
{
$page_id = $id[1];
}
if ($href[0] && $href[1])
{
$session[$href[0]][$href[1]] = array('details' => array('title' => $title));
}
}
}
if (!$details)
{
$dt = array();
}
else
{
$dt = $dtl;
}
return array(1, array('details' => $dt, 'sessions' => $session, 'page_id' => array('primewire' => $page_id)));
}
function parse_page_item($url, $cache = true, $details = true, $links = true)
{
$this->html = wpmovies_object('html');
$this->html_dom = wpmovies_object('html_dom');
$this->url_cache = wpmovies_object('urlcache');
$signature = array('<strong>Air Date:</strong>', '<strong>Released:</strong>', '<strong>Title:</strong>', '<< Previous Episode', 'Next Episode >>');
$this->html_text = "";
$ret = $this->wait_and_fetch($url, $signature, $cache);
if (!$ret[0])
{
return $ret;
}
$this->html_text = $ret[2];
$ret = array();
if ($details)
{
$info = $this->parse_item_info();
$ret['details'] = $info;
}
//else {
// $ret['details']['title'] = $info->title;
//}
if ($links)
{
$ret['links'] = $this->parse_item_links();
}
$ret = array(1, $ret);
return $ret;
}
function parse_item_info()
{
$this->html = wpmovies_object('html');
$this->html_dom = wpmovies_object('html_dom');
$this->url_cache = wpmovies_object('urlcache');
$details = array();
$stag = '<div class="index_container">';
$etag = '<ul id="multi_drop">';
$linkarray = $this->html->parse_array($this->html_text, $stag, $etag);
$imdb = $this->html->get_HTMLtag('class', 'mlink_imdb', $this->html_text, 'div');
$page_id = $this->html->get_HTMLtag('class', 'mlink_submitlink', $this->html_text, 'div');
$trailer = "";
$t = $this->html->get_HTMLtag('data-id', 'trailer', $this->html_text, 'div');
if (isset($t[0]))
{
$t = $t[0];
$trailer = $this->html->read_value($t, 'iframe', 'src');
}
if ($imdb)
{
$imdb = $this->html->read_value($imdb[0], 'a', 'href');
}
else
{
$imdb = "";
}
if ($page_id)
{
$page_id = $this->html->read_value($page_id[0], 'a', 'href');
$page_id = explode('/submit.php?movieid=', $page_id);
$page_id = $page_id[1];
$page_id = explode("&", $page_id);
$page_id = $page_id[0];
}
else
{
$page_id = "";
}
foreach ($linkarray as &$vidinfo)
{
$vid = $vidinfo;
$vidinfo = str_replace(["\n", " "], ["", " "], $vidinfo);
preg_match("'Title:<\/strong><\/td><td>(.*?)<\/td>'si", $vidinfo, $title);
$title = @$title[1];
preg_match("'<div class=\"movie_info\">(.*?)</td>'si", $vidinfo, $desc);
// print_d($vidinfo);
//preg_match("'Title:(.*?)</tr>'si", $vidinfo, $title);
// $title = ""; // trim((strip_tags(@$title[1])));
if (!$title)
{
$title = explode(":", trim((strip_tags(@$desc[1]))));
$title = @$title[0];
}
$desc = trim(strip_tags(@$desc[1]));
$desc = explode(":", $desc);
if (count($desc) > 1)
{
unset($desc[0]);
}
$desc = implode("", $desc);
//$desc = count($desc) > 1 ? $desc[count($desc)-1] : $desc[0];
preg_match("'Released:(.*?)</tr>'si", $vidinfo, $released);
$released = trim(strip_tags(@$released[1]));
if (!$released)
{
preg_match("'Air Date:(.*?)</tr>'si", $vidinfo, $airdate);
$released = trim(strip_tags(@$airdate[1]));
}
preg_match("'Runtime:(.*?)</tr>'si", $vidinfo, $runtime);
preg_match("'Genres:(.*?)</tr>'si", $vidinfo, $genres);
preg_match("'Countries:(.*?)</tr>'si", $vidinfo, $countries);
preg_match("'Director:(.*?)</tr>'si", $vidinfo, $director);
preg_match("'Actors:(.*?)</tr>'si", $vidinfo, $actors);
preg_match("'<li class=\"current-rating\" style=\"width:[0-9]+.[0-9]+px;\">Currently (.*?)<'si", $vidinfo, $rating);
if (@$rating[1] == '')
{
preg_match("'<li class=\"current-rating\" style=\"width:[0-9]+px;\">Currently (.*?)<'si", $vidinfo, $rating);
}
$actors = str_replace('</a> <a', '</a>, <a', $actors);
$thumb = $this->html->get_HTMLtag('class', 'movie_thumb', $vidinfo, 'div');
$thumb = @$thumb[0];
$thumb = $this->html->getAttribute('src', $thumb);
$thumb = (substr(@$thumb, 0, 5) != 'http:' ? 'http:' : '') . $thumb;
$details = array('title' => $title,
'featured' => 0,
'thumb' => $thumb,
'description' => $desc,
'trailer' => $trailer,
'released' => $released,
'runtime' => trim(strip_tags(@$runtime[1])),
'genres' => trim(strip_tags(@$genres[1])),
'countries' => trim(strip_tags(@$countries[1])),
'director' => trim(strip_tags(@$director[1])),
'actors' => trim(strip_tags((@$actors[1]))),
'imdb' => trim(strip_tags($imdb)),
'rating' => @$rating[1],
'page_id' => array('primewire' => $page_id));
}
return $details;
}
function parse_item_links()
{
$this->html = wpmovies_object('html');
$this->html_dom = wpmovies_object('html_dom');
$this->url_cache = wpmovies_object('urlcache');
$links = array('detail' => array(), 'simple' => array());
$stag2 = '<span class=quality_';
$etag2 = '</div></td>';
$linkarray2 = $this->html->parse_array($this->html_text, $stag2, $etag2);
// print_r($linkarray2);
// die("x");
foreach ($linkarray2 as &$vid_links)
{
$star = 0;
preg_match("'<span class=quality_(.*?)>'si", $vid_links, $quality);
if (stristr($vid_links, "star.gif") == true)
{
$star = true;}
preg_match("'<li class=\"current-rating\" style=\"width:[0-9]+.[0-9]+px;\">Currently (.*?)<'si", $vid_links, $rating);
if (@$rating[1] == '')
{
preg_match("'<li class=\"current-rating\" style=\"width:[0-9]+px;\">Currently (.*?)<'si", $vid_links, $rating);
}
preg_match("'<a href=\"/external.php(.*?)\"'si", $vid_links, $link);
if(!is_array($link) || !count($link))
{
preg_match("'<a href=\"/goto.php(.*?)\"'si", $vid_links, $link);
}
preg_match("'<span class=\"version_veiws\"> (.*?) views'si", $vid_links, $views);
preg_match("'<span class=\"version_host\"><script type=\"text/javascript\">document.writeln\(\'(.*?)\'\);</script>'si", $vid_links, $host);
if (isset($link[1]))
{
parse_str($link[1], $new_link);
if ($new_link['url'])
{
$arr_invalid = array('Promo Host', "HD Sponsor", "Watch HD", 'Sponsor Host');
if (in_array($host[1], $arr_invalid) === false)
{
$links['detail'][] = array('quality' => $quality[1], 'quality' => $quality[1], 'verified' => $star,
'rating' => $rating[1], 'views' => @$views[1], 'host' => $host[1], 'link' => base64_decode($new_link['url']));
$links['simple'][] = base64_decode($new_link['url']);
}
}
}
}
return $links;
}
function clean($string)
{
$string = strip_tags($string); //tv-shows have extra tags
$string = preg_replace('/[^A-Za-z0-9\. -]/', '', $string);
return trim($string);
}
function is_expected_page($content, $signature)
{
$found = false;
if (is_array($signature))
{
foreach ($signature as &$verf)
{
if (!(stripos($content, $verf) === false))
{
$found = true;
break;
}
}
if ($found)
{
return true;
}
}
else
{
return stripos($content, $signature) === false ? false : true;
}
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire