-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathdebug.js
180 lines (147 loc) · 4.48 KB
/
debug.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
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
const yts = require( './src/index.js' )
// console.log( yts.search )
m15()
async function m15 () {
const video = await yts({ videoId: '-ObdvMkCKws' });
console.log(video.title);
console.log(video.url);
console.log(video.thumbnail);
console.log(video.timestamp)
console.log('----')
console.log(video.description)
console.log(video.duration)
console.log(video.views)
}
async function m14 () {
const video = await yts({ videoId: 'e9vrfEoc8_g' });
console.log(video.title);
console.log(video.url);
console.log(video.thumbnail);
console.log(video.timestamp)
console.log('----')
console.log(video.description)
console.log(video.duration)
console.log(video.views)
}
async function m13 () {
const r = await yts("王菲 Faye Wong");
// const r = await yts("irregular pineapples");
// const r = await yts("pewdiepie");
const channels = r.channels
const topChannel = channels[ 0 ]
console.log( 'topChannel.name: ' + topChannel.name )
console.log( 'topChannel url: ' + topChannel.url )
console.log('----')
console.log( 'topChannel.baseUrl: ' + topChannel.baseUrl )
console.log( 'topChannel.id: ' + topChannel.id )
console.log( 'topChannel.about: ' + topChannel.about )
console.log( 'topChannel.verified: ' + topChannel.verified )
console.log('----')
console.log( 'topChannel.videoCount: ' + topChannel.videoCount )
console.log( 'topChannel.subCount: ' + topChannel.subCount )
console.log( 'topChannel.subCountLabel: ' + topChannel.subCountLabel )
}
async function m12 () {
const video = await yts({ videoId: '62ezXENOuIA' });
console.log(video.title);
console.log(video.url);
console.log(video.thumbnail);
}
async function m11 () {
const video = await yts( { videoId: '62ezXENOuIA' } ).then(function (result) {
console.log( result )
})
console.log(video.title);
console.log(video.url);
console.log(video.thumbnail);
}
async function m10 () {
const id = 'z95fi3uazYA'
const res = await yts(id);
const videoIdSearch = await yts({ videoId: id });
console.log(videoIdSearch.videoId === res.videos[0].videoId);
console.log(videoIdSearch.title);
console.log(res.videos[0].title);
}
async function m9 () {
let result = await yts({ listId: "PLQ9SiFtEqtYByscXDLGNOC8XL49BFn9tZ" });
console.log( result )
}
async function m8 () {
let result = await yts({ listId: "PLSwcuYF4r6MJHkUVYbDAekT7j0FvZ_B4X" });
console.log( result )
}
async function m7 () {
let result = await yts( 'superman theme list' );
// let result = await yts({ listId: "PL7k0JFoxwvTbKL8kjGI_CaV31QxCGf1vJ" });
console.log( result )
}
async function m6 () {
let result = await yts({ listId: "PL67B0C9D86F829544" });
// let result = await yts({ listId: "PL7k0JFoxwvTbKL8kjGI_CaV31QxCGf1vJ" });
console.log( result )
}
async function m5 () {
let result = await yts({ listId: "RDGMEM_v2KDBP3d4f8uT-ilrs8fQ" });
console.log( result )
}
function m4 () {
yts( { query: 'superman theme' }, function ( err, result ) {
if ( err ) throw err
console.log( result.videos[ 1 ].title )
} )
}
async function m3 () {
const r = await yts( 'live streams' )
console.log( r.videos )
console.log( r.live )
}
async function m2 () {
const list = await yts( { listId: 'PL7k0JFoxwvTbKL8kjGI_CaV31QxCGf1vJ' } )
console.log( list )
}
async function m1 () {
const r = await yts( 'live streams' )
const v = r.live.sort(
function ( b, a ) {
return b.watching - a.watching
}
)[ 0 ]
console.log( v )
console.log(
r.live.reduce( function ( a, c ) {
return a + c.description
}, '' )
)
}
async function main () {
const message = 'Nier: Automata - Bipolar Nightmare 【Intense Symphonic Metal Cover】'
// find video id in message (url)
let match = message.match( /[?&]v=(\w+)&?/ )
const videoId = match && match[ 1 ]
// find list id in message (url)
match = message.match( /[?&]list=(\w+)&?/ )
const listId = match && match[ 1 ]
// find list index specified in message (url)
match = message.match( /[?&]index=(\w+)&?/ )
const listIndex = match && match[ 1 ]
if ( videoId ) {
// found video id in url
const opts = { videoId: videoId }
const r = await yts( opts )
console.log( r )
} else if ( listId ) {
// only a list id was found
const opts = { listId: listId }
const r = await yts( opts )
console.log( r )
// first video in playlist
console.log( r.videos[ 0 ] )
if ( listIndex ) {
console.log( r.videos[ listIndex ] )
}
} else {
const r = await yts( message )
console.log( r )
}
}