gotcreations/hubtraffic-api

Get video information from servers like redtube.com, pornhub.com and youporn.com

2.1.0 2021-01-18 08:12 UTC

This package is auto-updated.

Last update: 2023-07-04 11:06:48 UTC


README

Installation

composer install gotcreations/hubtraffic-api

How to use

  • Get video information by url
$api = new \HubtrafficApi\Api;
$video = $api->getVideoByUrl('http://www.pornhub.com/view_video.php?viewkey=ph57c67facc4ab2'); 
  • Or by source and id
$api = new \HubtrafficApi\Api;
$details = $api->parseSourceAndId('http://www.pornhub.com/view_video.php?viewkey=ph57c67facc4ab2');
$video = $this->getVideo($details['source'], $details['id']);
  • Check if video is active
$video; // some video
$api = new \HubtrafficApi\Api;
if (!$this->isVideoActive($video->source, $video->sourceId)) {
	// delete
}
  • Get Porn star list
    $api = new \HubtrafficApi\Api;
    $list = $api->getPornStarList($api::SOURCE_PORNHUB);
    

Create your own parser

  • Define your own parse source class.

    class MyOwnParser extends \HubtrafficApi\Parser\BaseParser {
      public function parseVideoData($source, $videoId, $data)
      {
          // TODO: Implement parseVideoData() method.
      }
    
      public function parseEmbedData($data)
      {
          // TODO: Implement parseEmbedData() method.
      }
    
      public function parseIsActive($data)
      {
          // TODO: Implement parseIsActive() method.
      }
    
      public function parsePornstarsList($data)
      {
           // TODO: Implement parsePornstarsList() method.
      }
    }
    
  • Registry your parser in api source
    $api = new \HubtrafficApi\Api();
    $api->registrySource('myOwnSource', array(
      'parser' => MyOwnParser::class,
    'serverName' => 'MySource.com', //Server name
    'pattern' => '/([0-9]+)', //Pattern to get id from url
    'url' => [
        'video' => 'http://api.mysource.com/video_id_api_url', //Url to get video data, videoId will added to end of url
        'embed' => 'http://api.redtube.com/embed_code_api_url', //Url to get embed video code, videoId will added to end of url
        'active' => 'http://api.redtube.com/video_active_url', //Url to get if video is active, videoId will added to end of url
        'pornstars' => 'http://api.redtube.com/pornstars', //URl to get porn stars list
    ]
    ));
    

    Supported servers

  • Redtube
  • PornHub
  • YouPorn
  • Tube8
  • XTube