Jump to content

Recommended Posts

Hi all,

 

Hopefully you guys can help me.

 

I'm having an issue finding out what being outputted from the below class.

 

Can someone please help me echo out what is being grabbing and stored (if any)?

 

I've spent hours look and re-reading and i can't quite put my finger on it :(

 

 

CODE:

public function getEmbeds($title,$showid,$season,$episode){
        $misc = new Misc();
        
        $title = $this->getTitle($title);
		//some issues look at later
        $link = "http://projectfreetv.so/".$title."/".$title."-season-".$season."/";
        
        $this->curl->header(true);
        $page = file_get_contents($link);        
        $code = 200;
    

        $page = explode("\r\n\r\n",$page);
        if (count($page)>1){
            $page = $page[1];
        } else {
            $page = $page[0];
        }
        
        if ($code==200){
            $searchstring = "season$season"."episode$episode";
            $codes = 1;
            
            $ret = array();
    
            $dom = new DOMDocument();
            @$dom->loadHTML($page);
            $xp = new DOMXPath($dom);
            $tds = $xp->query('//td[@class="mnllinklist dotted"]');
            for ($i=0;$i<$tds->length;$i++){
                if ($tds){
                    $td = $tds->item($i);
                    
                    $linktitle = $td->getElementsByTagName('a')->item(0)->getElementsByTagName('div');
                    if ($linktitle->length){
                        $linktitle = $linktitle->item(0)->textContent;
                        $linktitle = strtolower(preg_replace("/[^a-zA-Z0-9]/i","",$linktitle));
                    } else {
                        $linktitle = '';
                    }
                    
                    $tmp = explode($searchstring,$linktitle);
                
                    if (count($tmp)==2 && @$tmp[1]==""){
                        // we have the link I guess
                        $videolink = $td->getElementsByTagName('a')->item(0)->getAttribute("href");
                        $test = str_replace('http://projectfreetv.so/watch/','',$videolink);
                        $vdlink = urldecode($test);
                        $videolink = substr($vdlink, 0, strpos($vdlink, "&ttl"));
                        if (substr_count($videolink,"/player/")){
                            $tmp = explode("/player/",$videolink);
                            $tmp = explode(".php?id=",$tmp[1]);
                            
                            if (count($tmp)!=2){
                                continue;
                            }
                            
                            $host = $tmp[0];
                            $id = $tmp[1];
                                                        
                            
                            $link = $misc->makeLink($host,$id);
                            if ($link){
                                $embed = $misc->buildEmbed($link);
                                if ($embed){
                                    $ret[$codes] = array();
                                    $ret[$codes]['embed'] = $embed;
                                    $ret[$codes]['link'] = $link;
                                    $ret[$codes]['language'] = "ENG";
                                    $codes++;
                                }
                            } 
                        }
                    }
                }
            }
        
            return $ret;
        
        } else {
            return array();
        }
    }

Thanks in advance!

B-Man

Link to comment
https://forums.phpfreaks.com/topic/299677-not-sure-whats-outputting/
Share on other sites

Seems like that function is scraping a page from freetvproject.so and returning an array with all the embed video html from that page, as well as other information.

 

pretty sure the key part is this part:

 

 

if ($embed){
$ret[$codes] = array();
$ret[$codes]['embed'] = $embed;
$ret[$codes]['link'] = $link;
$ret[$codes]['language'] = "ENG";
$codes++;
}

 

this kind of shows you the general format of the returned array.

 

Hope this helps.

I've used the following note to save repeating i and copied them all into one file: note multiple attempts tried in the listed locations.

public function getEmbeds($title,$showid,$season,$episode){
        $misc = new Misc();
        
        $title = $this->getTitle($title);
		//some issues look at later
        $link = "http://projectfreetv.so/".$title."/".$title."-season-".$season."/";
        
        $this->curl->header(true);
        $page = file_get_contents($link);        
        $code = 200;
    

        $page = explode("\r\n\r\n",$page);
        if (count($page)>1){
            $page = $page[1];
        } else {
            $page = $page[0];
        }
        
        if ($code==200){
            $searchstring = "season$season"."episode$episode";
            $codes = 1;
            
            $ret = array();
    
            $dom = new DOMDocument();
            @$dom->loadHTML($page);
            $xp = new DOMXPath($dom);
            $tds = $xp->query('//td[@class="mnllinklist dotted"]');
            for ($i=0;$i<$tds->length;$i++){
                if ($tds){
                    $td = $tds->item($i);
                    
                    $linktitle = $td->getElementsByTagName('a')->item(0)->getElementsByTagName('div');
                    if ($linktitle->length){
                        $linktitle = $linktitle->item(0)->textContent;
                        $linktitle = strtolower(preg_replace("/[^a-zA-Z0-9]/i","",$linktitle));
                    } else {
                        $linktitle = '';
                    }
                    
                    $tmp = explode($searchstring,$linktitle);
                
                    if (count($tmp)==2 && @$tmp[1]==""){
                        // we have the link I guess
                        $videolink = $td->getElementsByTagName('a')->item(0)->getAttribute("href");
                        $test = str_replace('http://projectfreetv.so/watch/','',$videolink);
                        $vdlink = urldecode($test);
                        $videolink = substr($vdlink, 0, strpos($vdlink, "&ttl"));
                        if (substr_count($videolink,"/player/")){
                            $tmp = explode("/player/",$videolink);
                            $tmp = explode(".php?id=",$tmp[1]);
                            
                            if (count($tmp)!=2){
                                continue;
                            }
                            
                            $host = $tmp[0];
                            $id = $tmp[1];
                                                        
                            
                            $link = $misc->makeLink($host,$id);
                            if ($link){
                                $embed = $misc->buildEmbed($link);
                                if ($embed){
                                    $ret[$codes] = array();
                                    $ret[$codes]['embed'] = $embed;
                                    $ret[$codes]['link'] = $link;
                                    $ret[$codes]['language'] = "ENG";
                                    $codes++;
                                    //attempt 1 - print_r(array_values($embed));
                                    //attempt 2 - var_dump($embed);
                                    //attempt 3 - echo count($embed);
                                }
                            } 
                        }
                    }
                }
            }
        //attempt 1 - print_r(array_values($embed));
//attempt 2 - var_dump($embed);
//attempt 3 - echo count($embed);
            return $ret;
        
        } else {
            return array();
        }
//attempt 1 - print_r(array_values($embed));
//attempt 2 - var_dump($embed);
//attempt 3 - echo count($embed);
    }

I don't have the rest of the class but that won't matter.

 

They changed the code since that script was made, is now all js and there is no class="mnllinklist dotted" within a td in the html code.

 

They don't want others scraping their links.

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.