-
Notifications
You must be signed in to change notification settings - Fork 3
/
pusha_video_videobash.php
53 lines (43 loc) · 1.45 KB
/
pusha_video_videobash.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?
// getting video from videobash.com
error_reporting(E_ALL ^ E_NOTICE);
include "lib/gootrans.php";
include "lib/nokogiri.php";
$gootrans = new gootrans();
$used_file = 'used.txt';
if (file_exists($used_file) == false) {
file_put_contents($used_file, '');
$used = array();
} else {
$used = explode("\n", file_get_contents($used_file));
}
while (true) {
$content = file_get_contents("http://videobash.com");
$saw = new nokogiri($content);
$hrefs = $saw->get("#topVideo li div div a")->toArray();
foreach ($hrefs as $href) {
if (empty($href['img'])) {
continue;
}
$url = $href['href'];
$video_content = file_get_contents($url);
$saw = new nokogiri($video_content);
$flashvars = $saw->get("param[name=flashvars]")->toArray();
$title = $saw->get("h1.video-title")->toArray();
$title = preg_replace("/[^\ 0-9a-zA-Zа-яА-Я]/u", "", $title['#text']);
$title = $gootrans->translate($title, "en", "ru");
if (in_array($title, $used)) {
echo "$title -- we have this video\n";
continue; // going to fetch another video
} else {
echo "video is new\n";
}
parse_str($flashvars['value'], $params);
system("wget \"{$params['video_url']}\" -O \"videos/1/{$title}.flv\"");
system("php pusha_video.php");
$used[] = $title;
file_put_contents($used_file, implode("\n", $used));
system("rm -rf videos/1/*");
}
sleep(600);
}