Jump to content

Script struggles with more than 25 letters or multiple spaces


Boxerman

Recommended Posts

Hey guys,

 

Sorry to waste your time here, but i'm hoping you can help.

 

I'm really not sure how to ask for help here, but the below script basically runs off, checks a webpage for a page then returns results, however, if the title has more than 25 letters or has multiple spaces in like "I Am The One" it struggles to find it correctly.

 

How would one attack such a problem?

    public function getTitle($title){
        $title = trim($title);
        $title = stripslashes($title);
        $title = strtolower(urldecode($title));
        $title = str_replace(" ","-",$title);
        $title = str_replace("'","'",$title);
        $title = str_replace(":",":",$title);
        
        return $title;
    }
    
     public function getMovieEmbeds($title) {
        $misc = new Misc(); 
        //Step1 find key
        $movie_url = null;
        $html = file_get_html('https://primewire.unblocked.pe/');
        $elements = $html->find('input[name=key]',0);
        $key = null;
        if(!is_null($elements)){
            $key = $elements->value;
        }
        if(is_null($key)){
            return array();
        }
        
        
        $search = urlencode($title);                
        $html = file_get_html("https://primewire.unblocked.pe/index.php?search_keywords=$search&key=$key&search_section=1");
        $elements = $html->find(".index_item h2");
        if(!is_null($elements)){
            foreach($elements as $element){
                $element_title = strtolower(strip_tags(trim(preg_replace('/\s*\([^)]*\)/', '', $element->innertext))));                 
                if ($element_title == strtolower(trim($title))) {
                    $parent = $element->parent();
                    $movie_url = "https://primewire.unblocked.pe".$parent->href;
                    break;
                }
            } 
        }
        if (is_null($movie_url)) { 
            return array();
        }
        
        
        $html = file_get_html($movie_url);
        $elements = $html->find(".movie_version_link a");
        if(!is_null($elements)){
            foreach($elements as $element){
                $encoded_url = "https://primewire.unblocked.pe".$element->href;
                $query = parse_url($encoded_url, PHP_URL_QUERY);
                parse_str($query,$op);
                $link = base64_decode($op["url"]);  
                
                if(strpos($link, "affbuzzads")===false && strpos($link, "webtrackerplus")===false){
                    $embed = $misc->buildEmbed($link);
                    if ($embed) {
                        $embeds[] = array(
                            "embed" => $embed,
                            "link" => $link,
                            "language" => "ENG",
                        );
                    }
                }
            }
            return $embeds;
        }
        return array(); 
    }
    
    public function getEmbeds($title, $showid, $season, $episode) {
        $misc = new Misc(); 
        
        $movie_url = null;
        $html = file_get_html('https://primewire.unblocked.pe/?tv');
        $elements = $html->find('input[name=key]',0);
        $key = null;
        if(!is_null($elements)){
            $key = $elements->value;
        }
        if(is_null($key)){
            return array();
        }
         
        
        $search = urlencode($title);                
        $html = file_get_html("https://primewire.unblocked.pe/index.php?search_keywords=$search&key=$key&search_section=2");
        $elements = $html->find(".index_item h2");
        if(!is_null($elements)){
            foreach($elements as $element){
                $element_title = strtolower(strip_tags(trim(preg_replace('/\s*\([^)]*\)/', '', $element->innertext))));                 
                if ($element_title == strtolower(trim($title))) {
                    $parent = $element->parent();
                    $movie_url = "https://primewire.unblocked.pe".$parent->href;
                    break;
                }
            } 
        }
        if (is_null($movie_url)) { 
            return array();
        }
        
        $episode_url = str_replace("watch", "tv", $movie_url)."/season-".$season."-episode-".$episode;
          
        
        $html = file_get_html($episode_url);
        $elements = $html->find(".movie_version_link a");
        if(!is_null($elements)){
            $embeds = array();
            foreach($elements as $element){
                $encoded_url = "https://primewire.unblocked.pe".$element->href;
                $query = parse_url($encoded_url, PHP_URL_QUERY);
                parse_str($query,$op);
                $link = base64_decode($op["url"]);   
                if(strpos($link, "affbuzzads")===false && strpos($link, "webtrackerplus")===false){
                    $embed = $misc->buildEmbed($link);
                    if ($embed) {
                        $embeds[] = array(
                            "embed" => $embed,
                            "link" => $link,
                            "language" => "ENG",
                        );
                    }
                }
            }
            return $embeds;
        }
        return array();

Thanks for taking your time to read! - Please be gentle! 

B-Man

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.