Added option to pass html body data directly to video_basic_info | video_info | stream functions.
 Fixed Playlist ID regexp to allow multiple playlist ID support.
 Added Dezer advanced search
 Improved Deezer Share Link handling.
 Added cookiesHeaders options to update cookies when using external https request module.
 Added Artists badge in YouTubeChannel Class.
This commit is contained in:
Killer069
2021-11-01 15:43:52 +05:30
committed by GitHub
10 changed files with 54 additions and 34 deletions

View File

@@ -46,3 +46,17 @@ export function setCookieToken(options: { cookie: string }) {
youtubeData = { cookie };
youtubeData.file = false;
}
export function cookieHeaders(headCookie: string[]) {
if (!youtubeData?.cookie) return;
headCookie.forEach((x: string) => {
x.split(';').forEach((x) => {
const arr = x.split('=');
if (arr.length <= 1) return;
const key = arr.shift()?.trim() as string;
const value = arr.join('=').trim();
setCookie(key, value);
});
});
uploadCookie();
}

View File

@@ -6,6 +6,7 @@ import { InfoData } from '../stream';
interface InfoOptions {
proxy?: Proxy[];
htmldata?: boolean;
}
interface PlaylistOptions {
@@ -79,14 +80,19 @@ export function extractID(url: string): string {
* @returns Data containing video_details, LiveStreamData and formats of video url.
*/
export async function video_basic_info(url: string, options: InfoOptions = {}) {
if (yt_validate(url) !== 'video') throw new Error('This is not a YouTube Watch URL');
const video_id: string = extractID(url);
const new_url = `https://www.youtube.com/watch?v=${video_id}&has_verified=1`;
const body = await request(new_url, {
proxies: options.proxy ?? [],
headers: { 'accept-language': 'en-US,en-IN;q=0.9,en;q=0.8,hi;q=0.7' },
cookies: true
});
let body: string;
if (options.htmldata) {
body = url;
} else {
if (yt_validate(url) !== 'video') throw new Error('This is not a YouTube Watch URL');
const video_id: string = extractID(url);
const new_url = `https://www.youtube.com/watch?v=${video_id}&has_verified=1`;
body = await request(new_url, {
proxies: options.proxy ?? [],
headers: { 'accept-language': 'en-US,en-IN;q=0.9,en;q=0.8,hi;q=0.7' },
cookies: true
});
}
const player_data = body
.split('var ytInitialPlayerResponse = ')?.[1]
?.split(';</script>')[0]