@@ -18,6 +18,8 @@ const BASE_URL = 'https://www.youtube.com/watch?v=';
18
18
exports . cache = new Cache ( ) ;
19
19
exports . cookieCache = new Cache ( 1000 * 60 * 60 * 24 ) ;
20
20
exports . watchPageCache = new Cache ( ) ;
21
+ // Cache for cver used in getVideoInfoPage
22
+ let cver = '2.20210622.10.00' ;
21
23
22
24
23
25
// Special error class used to determine if an error is unrecoverable,
@@ -273,7 +275,7 @@ const getWatchJSONPage = async(id, options) => {
273
275
let cookie = reqOptions . headers . Cookie || reqOptions . headers . cookie ;
274
276
reqOptions . headers = Object . assign ( {
275
277
'x-youtube-client-name' : '1' ,
276
- 'x-youtube-client-version' : '2.20201203.06.00' ,
278
+ 'x-youtube-client-version' : cver ,
277
279
'x-youtube-identity-token' : exports . cookieCache . get ( cookie || 'browser' ) || '' ,
278
280
} , reqOptions . headers ) ;
279
281
@@ -307,6 +309,7 @@ const getWatchHTMLPage = async(id, options) => {
307
309
let body = await getWatchHTMLPageBody ( id , options ) ;
308
310
let info = { page : 'watch' } ;
309
311
try {
312
+ cver = utils . between ( body , '{"key":"cver","value":"' , '"}' ) ;
310
313
info . player_response = findJSON ( 'watch.html' , 'player_response' ,
311
314
body , / \b y t I n i t i a l P l a y e r R e s p o n s e \s * = \s * \{ / i, '</script>' , '{' ) ;
312
315
} catch ( err ) {
@@ -325,6 +328,8 @@ const VIDEO_EURL = 'https://youtube.googleapis.com/v/';
325
328
const getVideoInfoPage = async ( id , options ) => {
326
329
const url = new URL ( `https://${ INFO_HOST } ${ INFO_PATH } ` ) ;
327
330
url . searchParams . set ( 'video_id' , id ) ;
331
+ url . searchParams . set ( 'c' , 'TVHTML5' ) ;
332
+ url . searchParams . set ( 'cver' , `7${ cver . substr ( 1 ) } ` ) ;
328
333
url . searchParams . set ( 'eurl' , VIDEO_EURL + id ) ;
329
334
url . searchParams . set ( 'ps' , 'default' ) ;
330
335
url . searchParams . set ( 'gl' , 'US' ) ;
0 commit comments