forked from sonichy/VideoGrab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsohu.js
94 lines (91 loc) · 2.65 KB
/
sohu.js
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
console.clear();
var domain = location.host;
console.info(domain);
var dialog = document.getElementById('dialog');
if (dialog == null) {
var dialog = document.createElement('dialog');
dialog.setAttribute('id', 'dialog');
dialog.setAttribute('open', 'open');
dialog.style.position = 'fixed';
dialog.style.margin = '0px';
dialog.style.top = '100px';
dialog.style.left = '0px';
dialog.style.zIndex = 10000;
document.body.appendChild(dialog);
}
dialog.innerHTML = '';
function xmlHttpRequest1(url, c) {
console.info(url);
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
console.info(xhr.responseText);
var data = JSON.parse(xhr.responseText);
var a = document.createElement('a');
a.textContent = '[' + c + ']';
a.target = '_blank';
a.href = data.url;
a.onclick = function(){
var as = dialog.getElementsByTagName('a');
for(l=0; l<as.length; l++){
as[l].style.color = 'black';
}
this.style.color = 'red';
}
dialog.append(a);
var br = document.createElement('br');
dialog.append(br);
}
} else {
console.error(url);
console.error(xhr.responseText);
}
}
xhr.open('GET', url, false);
xhr.send();
}
function xmlHttpRequest(url) {
console.info(url);
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
console.info(xhr.responseText);
var data = JSON.parse(xhr.responseText);
var clipsURL = data.data.clipsURL;
for (k = 0; k < clipsURL.length; k++) {
var d = new Date();
var url1 = 'http://' + data.allot + '/?prot=9&prod=flash&pt=1&file=' + data.data.clipsURL[k] + '&new=' + data.data.su[k] + '&key=' + data.data.ck[k] + '&vid=' + videoId + '&uid=' + d.getTime() + '&t=' + Math.random() + '&rb=1';
xmlHttpRequest1(url1, k+1);
}
}
} else {
console.error(url);
console.error(xhr.responseText);
}
}
xhr.open('GET', url, false);
xhr.send();
}
var videoId;
var embed = document.getElementsByTagName('embed');
console.info(embed);
for (i = 0; i < embed.length; i++) {
var flashvars = embed[i].getAttribute('flashvars');
console.info(flashvars);
if (flashvars.indexOf('&') != -1) {
var vars = new Array();
vars = flashvars.split('&');
for (j = 0; j < vars.length; j++) {
//console.info(vars[j]);
if (vars[j].indexOf('vid=') != -1) {
videoId = vars[j].substring(4);
console.info(videoId);
var url = 'http://hot.vrs.sohu.com/vrs_flash.action?vid=' + videoId;
xmlHttpRequest(url);
break;
}
}
}
}