-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtudou.js
More file actions
118 lines (103 loc) · 2.29 KB
/
Copy pathtudou.js
File metadata and controls
118 lines (103 loc) · 2.29 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//http://www.tudou.com/programs/view/html5embed.action?code=r4S7Hl4mvLs&resourceId=0_06_05_99
//http://www.tudou.com/programs/view/r4S7Hl4mvLs/?resourceId=0_06_02_99
function getVideoId(url) {
if(config != undefined && config != null) {
return config.item.iid;
}
if(pageConfig != undefined && pageConfig != null) {
return pageConfig.iid;
}
//config.item.iid
//pageConfig
}
function getFlvPath(videoId, callback) {
$.ajax({
url: "http://ct.v2.tudou.com/f?id="+videoId,
dataType: 'JSONP',
//here
success: function(param) {
if (param == -1) {
callback({
isok: false,
type:'detail',
});
return;
}
callback({
isok: true,
url: param[0]['server'],
type:'detail',
});
},
error: function(param) {
callback({
isok: false,
type:'detail',
msg: param.status+videoId
});
}
})
}
function parseTudouCode(url, callback) {
var videoId = getVideoId(url);
if (!videoId) {
callback({
isok: false,
type:'detail',
msg: "-1"
});
return;
}
console.log("videoId:" + videoId );
//http://www.tudou.com/outplay/goto/getItemSegs.action?iid=%s
$.ajax({
url: 'http://www.tudou.com/outplay/goto/getItemSegs.action?iid=' + videoId ,
// dataType: 'JSONP',
//here
success: function(param) {
console.log(param);
var data = JSON.parse(param);
var size = 0;
var info = null;
for(var i in data) {
if(data[i][0].size > size) {
info = data[i][0];
}
}
var k = info.k;
console.log(k);
//getFlvPath(k,callback);
callback({
isok: true,
url: "http://ct.v2.tudou.com/f?id="+k,
json: [
{
name : 'url',
tag: 'f',
func: 'text',
},
],
type:'detail',
});
},
error: function(param) {
callback({
isok: false,
type:'detail',
msg: param.status+"videoId:" + videoId
});
}
})
}
function getVideos(url, callback) {
parseTudouCode(url, callback)
}
console.log("onloadonloadonload");
getVideos(document.URL, function(e) {
//$("#info").text(typeof(WebViewBridgeAndroid));
console.log(e);
if (typeof(WebViewBridgeAndroid) != "undefined" && WebViewBridgeAndroid) {
WebViewBridgeAndroid.send(JSON.stringify(e));
// $("#info").text(JSON.stringify(e));
}
});