From e88537f6b68d251c69533b9cd99b7079c25eb3b5 Mon Sep 17 00:00:00 2001 From: fent <933490+fent@users.noreply.github.com> Date: Wed, 21 Oct 2020 19:58:56 -0700 Subject: [PATCH] fix: use `get_video_info` endpoint if watch and embed pages fail fixes #735 --- lib/info.js | 9 ++++++--- .../videos/age-restricted/embed-player-vars.html | 16 ++++++++++++++++ test/info-test.js | 14 ++++++++++++++ 3 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 test/files/videos/age-restricted/embed-player-vars.html diff --git a/lib/info.js b/lib/info.js index dd63faff..429d77a3 100644 --- a/lib/info.js +++ b/lib/info.js @@ -88,7 +88,7 @@ exports.getBasicInfo = async(id, options) => { // and requires an account logged in to view, try the embed page. let embedUrl = `${EMBED_URL + id}?${params}`; body = await miniget(embedUrl, options.requestOptions).text(); - let jsonStr = util.between(body, /['"]PLAYER_CONFIG['"]:\s?/, ''); + let jsonStr = util.between(body, /(['"])PLAYER_(CONFIG|VARS)\1:\s?/, ''); let config; if (!jsonStr) { throw Error('Could not find player config'); @@ -99,9 +99,12 @@ exports.getBasicInfo = async(id, options) => { throw Error(`Error parsing config: ${err.message}`); } playErr = util.playError(info, 'LOGIN_REQUIRED'); - if (!config.args.player_response && !config.args.embedded_player_response && playErr) { + if ((!config.args || (!config.args.player_response && !config.args.embedded_player_response)) && + !config.embedded_player_response && playErr) { throw playErr; } + let html5playerRes = / + + + +