1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Simple PHP xvideos direct link grab

Discussion in 'PHP' started by xAlexKimx, Feb 10, 2016.

  1. #1
    Anyone can help me with this.
    SEMrush
    <?php
    function xVideos($url)
    {
            $url = str_replace(' ', '', $url);
            if(!empty($url)):
                    curl_setopt($curl = curl_init($url), CURLOPT_RETURNTRANSFER, 1);
                    preg_match("/flv_url=(.+)url_bigthumb=([^&]+)/i", curl_exec($curl), $infos);
                    curl_close($curl);
                    return "<a href='".urldecode($infos[1])."'><img src='".urldecode($infos[2])."' width='150' height='150' border=0 alt='Download'></a>";
            endif;
    }
    
    echo (!empty($_GET['url'])) ? xVideos($_GET['url']) : 'E o link ?';
    ?>
    PHP:
    The code above supposed to get links from xvideos.com by enter localhost/index.php?url=xvideos-dot-com/videos0099/example-link. However, isn't working. Couldn't figure out why
     
    xAlexKimx, Feb 10, 2016 IP
    SEMrush
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,630
    Likes Received:
    724
    Best Answers:
    152
    Trophy Points:
    470
    #2
    You didn't check what you got back - xvideos.com redirects to www.xvideos.com, and you didn't allow for cURL to follow redirects. The following code works:
    
    <?php
    function xVideos($url)
    {
      $url = str_replace(' ', '', $url);
      if(!empty($url)):
      curl_setopt($curl = curl_init($url), CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
      preg_match("/flv_url=(.+)url_bigthumb=([^&]+)/i", curl_exec($curl), $infos);
      curl_close($curl);
      return "<a href='".urldecode($infos[1])."'><img src='".urldecode($infos[2])."' width='150' height='150' border=0 alt='Download'></a>";
      endif;
    }
    
    echo (!empty($_GET['url'])) ? xVideos($_GET['url']) : 'E o link ?';
    ?>
    
    PHP:
     
    PoPSiCLe, Feb 11, 2016 IP
  3. xAlexKimx

    xAlexKimx Well-Known Member

    Messages:
    549
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    158
    #3
    Thanks, let me try
     
    xAlexKimx, Feb 11, 2016 IP
  4. xAlexKimx

    xAlexKimx Well-Known Member

    Messages:
    549
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    158
    #4
    I tested and it works pretty good.

    Now I wanted to get mp4 file from xvideos instead. Can you help?
     
    xAlexKimx, Feb 11, 2016 IP
  5. Tuhin1234

    Tuhin1234 Active Member

    Messages:
    178
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #5
    Anyone help for Mp4 download
     
    Tuhin1234, Apr 15, 2016 IP
  6. Tuhin1234

    Tuhin1234 Active Member

    Messages:
    178
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #6
    Now this flv download code not work ..Anyone fix it
     
    Tuhin1234, May 8, 2016 IP
  7. Vooler

    Vooler Well-Known Member

    Messages:
    1,138
    Likes Received:
    63
    Best Answers:
    4
    Trophy Points:
    100
    #7
    Try "youtubedl" to download from more than 160 video sharing websites (including the one you mentioned). You can download in variety of formats including MP4.

    Calling this tool from PHP is simple:
    <?php
    $output = `youtubedl "<VIDEO_PAGE_URL> "`;
    
    print $output;
    Code (markup):
     
    Vooler, May 12, 2016 IP