Skip to content

Instantly share code, notes, and snippets.

@pingyen
Created March 17, 2015 14:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pingyen/37269fc560313e35518b to your computer and use it in GitHub Desktop.
Save pingyen/37269fc560313e35518b to your computer and use it in GitHub Desktop.
Xuite Vlog Downloader
<?php
$user = 'demo';
$videos = array();
for ($i = 1; $i <= 3; ++$i) {
foreach (array_slice(explode('<div class="media_thumb">', file_get_contents('http://vlog.xuite.net/' . $user . '*' . $i)), 1) as $token) {
$hq = strpos($token, '<div class="media_hq">') !== false;
$token = substr($token, strpos($token, '<a href="/play/') + 15);
$id = substr($token, 0, strpos($token, '"'));
$token = file_get_contents('http://m.xuite.net/vlog/' . $user . '/' . $id);
$token = substr($token, strpos($token, '<video class="v-player" controls ') + 33);
$token = substr($token, strpos($token, 'src="') + 5);
$url = substr($token, 0, strpos($token, '"'));
if ($hq === true) {
$url = substr($url, 0, -3) . '720';
$audio = false;
}
else {
$audio = substr($url, -3) === 'mp3';
}
$videos[] = array(
'id' => $id,
'url' => $url,
'hq' => $hq,
'audio' => $audio
);
}
}
foreach ($videos as $video) {
$file = $video['id'] . '.' . ($video['audio'] === true ? 'mp3' : 'mp4');
if (file_exists($file) === false) {
shell_exec("curl -o $file -L \"{$video['url']}\"");
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment