Print Curl Verbose Info on the web browser in php

By default, the CURLOPT_VERBOSE option will print verbose info to the stderr stream. If you want to print the verbose info to the stdout stream and make it visible to the web browser it’s easy:

PHP:


			  curl_setopt($hCurl, CURLOPT_STDERR, fopen('php://output', 'w+'));
			  curl_setopt($hCurl, CURLOPT_VERBOSE, 1);

Download a whole youtube playlist to your computer in php.

I don’t know if I should be sharing this code snippet, but this is just too cool!

  1. Get the code from the links on this page:
    http://1chris.com/post/39/using-php-to-download-youtube-flvs/
  2. Append this hack at the bottom of the php code:
$watch_ids	=	array();
$url = "http://www.youtube.com/watch?v=%s";
$plyst	=	file_get_contents("http://www.youtube.com/playlist?list=PLFE3074A4CB751B2B");
$matchall	=	preg_match_all('/<li class="playlist-video-item[^>]+>([\s\S]*?)<\/li>/', $plyst, $matches);

$info		=	preg_match_all('/<span class="title video-title "[^>]+>([^<]+)/', $plyst, $desc);

#var_dump($desc, $matches);exit;
for($i = 0; $i < $matchall ; $i++)
{
  preg_match('/watch\?v=([a-zA-Z0-9]+)/', $matches[1][$i], $id);
  $id	=	$id[1];

  $itemurl	=	sprintf($url, $id);
  $itemdesc	=	preg_replace('/[^A-Za-z0-9\s\.]+/', '', $desc[1][$i]);

  $filename	=	"$itemdesc.flv";
  if(file_exists($filename)) continue;

  echo "Fetching: " , $itemdesc, "\n";
  $youtubegrabber = new youtubegrabber($itemurl, $filename, 0);
}

3. modify and enjoy

Bonus: Add this to the options in the get_curl_binary method to get download progress info.

        curl_setopt($ch, CURLOPT_NOPROGRESS, FALSE);

Adios!

Custom Multi-Feature Clickbank Automation Software

cbautobot-small


A couple of years back, a client of mine decided to hire me to develop a custom application for automating certain actions based on sales information provided by clickbank’s api. This software is one of the most interesting projects I have worked on simply because of the array of services that it integrates and the things you are able to do with it.

Continue reading “Custom Multi-Feature Clickbank Automation Software” »