-
Notifications
You must be signed in to change notification settings - Fork 0
/
catch.html
executable file
·127 lines (127 loc) · 3.43 KB
/
catch.html
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
117
118
119
120
121
122
123
124
125
126
127
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>VideoRecomender</title>
<style type="text/css">
body{
background:#339933;
font-family:'微软雅黑,sans-serif';
}
#main{
width:900px;
margin-left:auto;
margin-right:auto;
}
</style>
<script src="jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
var uploadAll = function(vids){
$.get('https://openapi.youku.com/v2/videos/show_batch.json',{
client_id:'9c528d4d804d3150',
video_ids:vids
},
function(data){
var getStr = JSON.parse(data);
getStr.videos.forEach(function(videoData){
var vid = videoData.id;
var tags= videoData.category+','+videoData.tags;
var thumbnail= videoData.thumbnail;
var title = videoData.title;
$.post('/addvideo',{
vid:vid,
tags:tags,
thumbnail:thumbnail,
title:title
},function(data){
console.log(data);
});
});
});
}
var getVids = function(data){
var getStr = JSON.parse(data);
var vids;
getStr.videos.forEach(function(videoData){
if(vids){
vids = vids+','+videoData.id;
}else{
vids = videoData.id;
}
});
return vids;
}
//程序入口
$(function(){
$.get('https://openapi.youku.com/v2/videos/by_category.json',{
client_id:'9c528d4d804d3150',
category:'资讯'
},
function(data){
var vids = getVids(data);
uploadAll(vids);
alert('资讯ok');
});
$.get('https://openapi.youku.com/v2/videos/by_category.json',{
client_id:'9c528d4d804d3150',
category:'娱乐'
},
function(data){
var vids = getVids(data);
uploadAll(vids);
alert('娱乐ok');
});
$.get('https://openapi.youku.com/v2/videos/by_category.json',{
client_id:'9c528d4d804d3150',
category:'原创',
period:'history'
},
function(data){
var vids = getVids(data);
uploadAll(vids);
alert('原创ok');
});
$.get('https://openapi.youku.com/v2/videos/by_category.json',{
client_id:'9c528d4d804d3150',
category:'体育'
},
function(data){
var vids = getVids(data);
uploadAll(vids);
alert('体育ok');
});
$.get('https://openapi.youku.com/v2/videos/by_category.json',{
client_id:'9c528d4d804d3150',
category:'汽车'
},
function(data){
var vids = getVids(data);
uploadAll(vids);
alert('汽车ok');
});
$.get('https://openapi.youku.com/v2/videos/by_category.json',{
client_id:'9c528d4d804d3150',
category:'科技'
},
function(data){
var vids = getVids(data);
uploadAll(vids);
alert('科技ok');
});
$.get('https://openapi.youku.com/v2/videos/by_category.json',{
client_id:'9c528d4d804d3150',
category:'游戏'
},
function(data){
var vids = getVids(data);
uploadAll(vids);
alert('游戏ok');
});
});
</script>
</head>
<body>
<div id="main">
</div>
</body>
</html>