WEB Warning: ereg() [function.ereg]: REG_EMPTY in....

Discussion in 'OT Technology' started by Browning, Feb 4, 2009.

  1. Browning

    Browning Active Member

    Joined:
    Feb 14, 2005
    Messages:
    89,465
    Likes Received:
    10
    /home/user/public_html/domain.com/php/getURL.php on line 10

    It's a youtube video downloading script. Here is the beginning of getURL.php
    Code:
    <?php
    
    if (isset($_GET{'url'})){
        $url=$_GET{'url'};
        $url=trim($url);
    
        if (strstr($_GET['url'],"youtube.com")){
            $data = @file_get_contents($_GET['url']);
            @preg_match('#/watch_fullscreen\?video_id=([a-z0-9-_]+)&l=([0-9]+)&t=([a-z0-9-_]+)#i', $data, $matches);
            if (ereg($matches[1], $_GET['url'])) {
                Header("Location: http://www.youtube.com/get_video?video_id=$matches[1]&l=$matches[2]&t=$matches[3]");
            } 
        }
            
    
    there any way of fixing this?
     
  2. rodman8600

    rodman8600 OT Supporter

    Joined:
    Sep 6, 2003
    Messages:
    13,542
    Likes Received:
    6
    Location:
    South Bay, CA
    Downloading or viewing?

    From the looks of if the youtube video url is passed into the script and then the script send the user to the big mode.

    amirite? if so i've got another way of going about this.
     
  3. Browning

    Browning Active Member

    Joined:
    Feb 14, 2005
    Messages:
    89,465
    Likes Received:
    10
    it's just a script that lets users download from popular video sites. Most aren't working but few are. I just want to fix the youtube one.

    http://www.grabthevid.com/demo
     
  4. rodman8600

    rodman8600 OT Supporter

    Joined:
    Sep 6, 2003
    Messages:
    13,542
    Likes Received:
    6
    Location:
    South Bay, CA
    Alright, you're obviously going to need to do some work on the header redirect to force a download but the easiest way of going about this without having to deal with regular expressions (which I try to avoid as much as I can) would be:

    Code:
    <?PHP
    	if (isset($_GET{'url'})){  //Get YouTube URL.
    		$url=$_GET{'url'};
    		$url=trim($url);
    	}
        if (strstr($_GET['url'],"youtube.com")){
            $data = file_get_contents($url); //No need to keep using $_GET, we already set it to $url
    		$data = explode("var fullscreenUrl = '",$data); //Drop everything before var fullscreenUrl = '
    		$data = explode("&title",$data[1]); //Drop everything after &title giving us the fullscreen url in $data[0]
    		$data = $data[0]; //Cleanup of variables
            if (strstr($data,"/watch_fullscreen")){ //If we do infact have the watch_fullscreen url in $data, engage
                Header("Location: http://www.youtube.com" . $data);
            } 
        }
    ?>
    
    It's messy and dirty, but it'll do what you need I think.
     
  5. Limp_Brisket

    Limp_Brisket New Member

    Joined:
    Jan 2, 2006
    Messages:
    48,422
    Likes Received:
    0
    Location:
    Utah
    i'm guessing it's because that huge preg_match isn't matching anything so the matches[1] is empty when it gets to the ereg.

    p.s. there's really no reason to use ereg over preg
     
  6. Limp_Brisket

    Limp_Brisket New Member

    Joined:
    Jan 2, 2006
    Messages:
    48,422
    Likes Received:
    0
    Location:
    Utah
    why wouldn't you want to deal with regular expressions? they solve all of life's problems :cool:
     
  7. rodman8600

    rodman8600 OT Supporter

    Joined:
    Sep 6, 2003
    Messages:
    13,542
    Likes Received:
    6
    Location:
    South Bay, CA
    I don't know, I the past I've ended up wasting hours on regular expressions when I could've just written something simple like this which works for a very specific case, ie only YouTube.

    Regular expressions are great when you're trying to crawl through a huge amount of data but Browning only needs to work out YouTube.

    :wiggle:
     
  8. Browning

    Browning Active Member

    Joined:
    Feb 14, 2005
    Messages:
    89,465
    Likes Received:
    10
    how do I tie that in so the others work as well?

    The code I posted was just the beginning
     
  9. rodman8600

    rodman8600 OT Supporter

    Joined:
    Sep 6, 2003
    Messages:
    13,542
    Likes Received:
    6
    Location:
    South Bay, CA
    Same process, find the url to the actual video file and explode or use regular expressions.

    Instead of using strstr to determine which video site you're trying to download from make the drop down box functional and use the php switch function.

    EDIT:

    If you understand what the block of code I posted is doing the rest should be a cake. Study it, and the source to a YouTube video page and you've pretty much got everything you need.
     
  10. Browning

    Browning Active Member

    Joined:
    Feb 14, 2005
    Messages:
    89,465
    Likes Received:
    10
  11. rodman8600

    rodman8600 OT Supporter

    Joined:
    Sep 6, 2003
    Messages:
    13,542
    Likes Received:
    6
    Location:
    South Bay, CA
    Gotta replace the old block of code with mine, I didn't make use or ereg once in my initial post, so that error is coming from the old script.
     
  12. Browning

    Browning Active Member

    Joined:
    Feb 14, 2005
    Messages:
    89,465
    Likes Received:
    10
    did, so it would be this

    Code:
    <?php
    
        if (isset($_GET{'url'})){  //Get YouTube URL.
            $url=$_GET{'url'};
            $url=trim($url);
        }
        if (strstr($_GET['url'],"youtube.com")){
            $data = file_get_contents($url); //No need to keep using $_GET, we already set it to $url
            $data = explode("var fullscreenUrl = '",$data); //Drop everything before var fullscreenUrl = '
            $data = explode("&title",$data[1]); //Drop everything after &title giving us the fullscreen url in $data[0]
            $data = $data[0]; //Cleanup of variables
            if (strstr($data,"/watch_fullscreen")){ //If we do infact have the watch_fullscreen url in $data, engage
                Header("Location: http://www.youtube.com" . $data);
            } 
        }
    
            
        if (strstr($_GET['url'],"video.google.com")){
            [email protected]($url);
            $count=count($file);
    
            $main="";
            for ($i=0;$i<$count;$i++){
                $main=$main.$file[$i];
            }
    
    
            $parse=explode("http://vp.video.google.com",$main);
            $parse1=explode('"',$parse[1]);
            $google="http://vp.video.google.com".$parse1[0];
            $google=str_replace('&amp;','&',$google);
    
    //echo <<<D
    //<META HTTP-EQUIV="REFRESH" CONTENT="0; URL=$google">
    //D;
    Header("Location:$google");
    
        }
        
    
        if (strstr($_GET['url'],"ifilm.com")){
            [email protected]($url);
            $count=count($file);
        
            $flag=0;
            for ($i=0;$i<$count;$i++){
                if (strstr($file[$i],"so.addVariable") and strstr($file[$i],"getStream")){
                        $main=$file[$i]; $flag=1; break;
                }
            }
    
        if ($flag==1){
            $parse=explode("http://",$main);
            $parse1=explode("?e=",$parse[1]);
    
            $ifilm="http://".$parse1[0]."?e=";
            Header("Location:$ifilm");
            }
            if ($flag==0){
                Header("Location: http://ifilm-840.vo.llnwd.net/o/contentstore/getStream/2826840_300.flv?e=");
            }
        }
    
        if (strstr($_GET['url'],"myspace.com")){
            //$id=$_GET['videoid'];
    
            $parse0=explode("videoid=",$url);
            $id=$parse0[1];
    
            $urlthis=$url.'&videoid='.$id;
    
            [email protected]($urlthis);
            $count=count($file);
    
            for ($i=0;$i<$count;$i++){
                if (strstr($file[$i],$id."_thumb1.jpg")){
                    $main=$file[$i]; break;
                }
            }
    
            $parse=explode("_thumb1.jpg",$main);
            $parse1=explode(".net/",$parse[0]);
            $parse2=explode("/",$parse1[1]);
    
            $rest=substr($id,0,5);
    
            $myspace="http://content.movies.myspace.com/00".$rest."/".$parse2[1]."/".$parse2[2]."/".$id.".flv";
            Header("Location:$myspace");
        }
    
        if (strstr($_GET['url'],"bolt.com")){
    
    
            [email protected]($url);
            $count=count($file);
    
            for ($i=0;$i<$count;$i++){
                if (strstr($file[$i],'[IMG]')){
                    $main=$file[$i]; break;
                }
            }
    
            
            $parse=explode("[IMG]",$main);
            $parse1=explode('_',$parse[1]);
    
            $bolt=$parse1[0];
            $bolt=str_replace('/image/','/movie/',$bolt);
            $bolt=$bolt.".flv";
    
            
            Header("Location: $bolt");
        
        }
    
        if (strstr($_GET['url'],"dailymotion.com")){
            [email protected]($url);
            $count=count($file);
    
            $flag=0;
            for ($i=0;$i<$count;$i++){
                if (strstr($file[$i],"addVariable") and strstr($file[$i],".flv") and strstr($file[$i],'"url"')){
                    $main=$file[$i]; $flag=1; break;
                }
            }
        if ($flag==1){
            $parse=explode("http%3A%2F%2F",$main);
            $parse1=explode('");',$parse[1]);
            $parse1[0]=str_replace("%2F","/",$parse1[0]);
            $parse1[0]=str_replace("%3F","?",$parse1[0]);
            $parse1[0]=str_replace("%3D","=",$parse1[0]);
    
            $dailymotion="http://".$parse1[0];
            Header("Location: $dailymotion");
            }
            if ($flag==0){
                Header("Location: http://www.dailymotion.com/get/14/320x240/flv/2197705.flv?key=467179fa53996b0c93b92c2bba62724612a2e36");
            }
        }
    
        if (strstr($_GET['url'],"blip.tv")){
            [email protected]($url);
            $count=count($file);
    
            for ($i=0;$i<$count;$i++){
                if (strstr($file[$i],"setPrimaryMediaUrl")){
                    $main=$file[$i]; break;
                }
            }
    
            $parse=explode('setPrimaryMediaUrl("',$main);
            $parse1=explode('?source=',$parse[1]);
    
            $blip=$parse1[0];
            Header("Location: $blip");
        }
    
        if (strstr($_GET['url'],"break.com")){
            [email protected]($url);
            $count=count($file);
    
            $main="";
            for ($i=0;$i<$count;$i++){
                $main=$main.$file[$i];
            }
    
            $parse=explode("sGlobalFileName='",$main);
            $parse1=explode("'",$parse[1]);
    
            $name=$parse1[0];
    
    
            $parse2=explode("sGlobalContentFilePath='",$main);
            $parse3=explode("'",$parse2[1]);
    
            $fp=$parse3[0];
            $break="http://media1.break.com/dnet/media/".$fp."/".$name.".flv";
            Header("Location: $break");
    
        }
    }
    ?>
    Bolt, Myspace and DailyMotion are the others that aren't working.
     
  13. JesterFX

    JesterFX New Member

    Joined:
    Oct 10, 2004
    Messages:
    4,557
    Likes Received:
    0
  14. Browning

    Browning Active Member

    Joined:
    Feb 14, 2005
    Messages:
    89,465
    Likes Received:
    10

    Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got 404' in /home/jed1201/public_html/forums/demo/Zend/Gdata/App.php:285 Stack trace: #0 /home/jed1201/public_html/forums/demo/Zend/Gdata/App.php(143): Zend_Gdata_App::import('http://gdata.yo...', Object(Zend_Http_Client), 'Zend_Gdata_YouT...') #1 /home/jed1201/public_html/forums/demo/Zend/Gdata.php(130): Zend_Gdata_App->getEntry('http://gdata.yo...', 'Zend_Gdata_YouT...') #2 /home/jed1201/public_html/forums/demo/Zend/Gdata/YouTube.php(152): Zend_Gdata->getEntry('http://gdata.yo...', 'Zend_Gdata_YouT...') #3 /home/jed1201/public_html/forums/demo/download.php(25): Zend_Gdata_YouTube->getVideoEntry('WVQZeWoWVng') #4 {main} thrown in /home/jed1201/public_html/forums/demo/Zend/Gdata/App.php on line 285
     
  15. JesterFX

    JesterFX New Member

    Joined:
    Oct 10, 2004
    Messages:
    4,557
    Likes Received:
    0
    Is that from trying to download? I don't know php enough to read errors lol. Just copy paste
     
  16. Browning

    Browning Active Member

    Joined:
    Feb 14, 2005
    Messages:
    89,465
    Likes Received:
    10
    that's what happens when you paste in a url on the site you gave me and hit enter.

    I think I'm going a different route.
    http://videodownload.biz/test/
     
  17. JesterFX

    JesterFX New Member

    Joined:
    Oct 10, 2004
    Messages:
    4,557
    Likes Received:
    0
    try vidgrab.com and see if it works...

    I just downloaded 3 vids and it worked fine. But maybe youtube changed something recently?

    What vid are you trying to download? Stupid questions but are you sure it's still on youtube and available?
     
  18. JesterFX

    JesterFX New Member

    Joined:
    Oct 10, 2004
    Messages:
    4,557
    Likes Received:
    0
    lol, that's basically how I had vidgrab for like a year. But then it started getting some ok traffic so I added some "features" to it.

    Used to just be this: http://supersift.com/
     
  19. Browning

    Browning Active Member

    Joined:
    Feb 14, 2005
    Messages:
    89,465
    Likes Received:
    10
    error the first time, worked on the second
     
  20. JesterFX

    JesterFX New Member

    Joined:
    Oct 10, 2004
    Messages:
    4,557
    Likes Received:
    0
    Really weird. If that supersift works I can give you access to the files so you can copy/read all the code and maybe figure it out.
     
  21. nida

    nida Guest

    these sites are dead.
     
  22. Browning

    Browning Active Member

    Joined:
    Feb 14, 2005
    Messages:
    89,465
    Likes Received:
    10

    k:hsugh:
     
  23. biawokauns

    biawokauns New Member

    Joined:
    Sep 18, 2001
    Messages:
    19,893
    Likes Received:
    0
    Location:
    Republic of Kalifornia
    what does the @ do in front of @file_get_contents?
     
  24. Limp_Brisket

    Limp_Brisket New Member

    Joined:
    Jan 2, 2006
    Messages:
    48,422
    Likes Received:
    0
    Location:
    Utah
    suppress warnings
     
  25. biawokauns

    biawokauns New Member

    Joined:
    Sep 18, 2001
    Messages:
    19,893
    Likes Received:
    0
    Location:
    Republic of Kalifornia
    oh dope,
    so could i do that for anything that might throw an error?
     

Share This Page