-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
69 lines (63 loc) · 1.68 KB
/
index.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
var bparser = require("./lib/parseBiliURL");
function Bili_video(){
this.avnumber = undefined;
this.page = undefined;
switch (arguments.length) {
case 1:
switch (typeof(arguments[0])) {
case 'number':
this.avnumber = arguments[0];
this.page = 1;
break;
case 'string':
var av_page = bparser.parse(arguments[0]);
this.avnumber = av_page[0];
this.page = av_page[1];
break;
default:
console.error("Wrong argument type.");
}
break;
case 2:
if(typeof(arguments[0])!='number'
|| typeof(arguments[1])!='number'){
console.error("Arguments must be numbers.");
}else{
this.avnumber = arguments[0];
this.page = arguments[1];
}
break;
default:
console.error("Wrong arguments number.");
}
}
Bili_video.prototype.getIndex = function(){
return [this.avnumber, this.page];
}
Bili_video.prototype.getURL = function(){
return 'https://www.bilibili.com/video/av'
+ this.avnumber
+ '/index_'
+ this.page
+ '.html';
}
Bili_video.prototype.flashAddr = function(){
return '//static.hdslb.com/miniloader.swf?aid='
+ this.avnumber
+ '&page='
+ this.page;
}
Bili_video.prototype.embedAddr = function(){
var height = arguments[0] || 452,
width = arguments[1] ||544;
return '<iframe src="https://player.bilibili.com/player.html?aid='
+ this.avnumber
+ '&page='
+ this.page
+ '" scrolling="no" border="0" frameborder="no" framespacing="0" width="'
+ width
+ '" height="'
+ height
+ '" allowfullscreen="true"> </iframe>';
}
module.exports = Bili_video;