Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ytmusic_api_unofficial

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ytmusic_api_unofficial - npm Package Compare versions

Comparing version 1.1.0-beta.2.6.8 to 1.1.0-beta.2.6.130

4

dist/errors/errorCodes.js

@@ -17,4 +17,8 @@ "use strict";

INVALID_TYPE_PAGE: 'INVALID_TYPE_PAGE',
INVALID_URL: 'INVALID_URL',
NOT_FOUND: 'NOT_FOUND',
/* Axios Errors */
ENOTFOUND: 'ENOTFOUND'
};
exports.default = ErrorCode;
//# sourceMappingURL=errorCodes.js.map

10

dist/errors/index.js

@@ -11,5 +11,5 @@ "use strict";

function makeAxiosError(message, error, ...args) {
const msg = (message in errorCodes_1.default) ? Messages_1.default[message] : null;
const msg = (error.code in errorCodes_1.default) ? Messages_1.default[error.code] : null;
if (typeof msg === 'function')
return new Error(msg(...args));
return new Error(msg(message));
if (!(args === null || args === void 0 ? void 0 : args.length)) {

@@ -21,4 +21,3 @@ new Error(`An unknown error has occurred: ${message}`);

}
args.unshift(msg);
return new Error(String(...args));
return new Error(message);
}

@@ -35,6 +34,5 @@ exports.makeAxiosError = makeAxiosError;

constructor(code, ...args) {
var _a;
super(message(code, args));
this.code = code;
(_a = Error.captureStackTrace) === null || _a === void 0 ? void 0 : _a.call(Error, this, YTjsError);
Error.captureStackTrace(this, YTjsError);
}

@@ -41,0 +39,0 @@ get name() {

@@ -21,4 +21,8 @@ "use strict";

[errorCodes_1.default.INVALID_TYPE_PAGE]: (types) => `The type of page was invalid. Type Available: ${types}`,
[errorCodes_1.default.INVALID_URL]: (url) => `The url ${url} is invalid. Please use a valid youtube url.`,
[errorCodes_1.default.NOT_FOUND]: (error) => `The requested resource was not found. Message: ${error.message}`,
/* Axios errors */
[errorCodes_1.default.ENOTFOUND]: (error) => `The remote server was not found. Please check your internet connection. Message: ${error.message}`
};
exports.default = Messages;
//# sourceMappingURL=Messages.js.map

@@ -74,5 +74,11 @@ "use strict";

if (!DownloadType_1.DownloadType_arr.includes(type))
throw new errors_1.YTjsErrorError(errorCodes_1.default.INVALID_TYPE_DOWNLOAD, { typeRequested: type, typesAvailable: DownloadType_1.DownloadType_arr });
throw new errors_1.YTjsErrorError(errorCodes_1.default.INVALID_TYPE_DOWNLOAD, {
typeRequested: type,
typesAvailable: DownloadType_1.DownloadType_arr
});
if (quality && !DownloadQuality_1.DownloadQuality_arr.includes(quality))
throw new errors_1.YTjsErrorError(errorCodes_1.default.INVALID_TYPE_QUALITY, { typeRequested: quality, typesAvailable: DownloadQuality_1.DownloadQuality_arr });
throw new errors_1.YTjsErrorError(errorCodes_1.default.INVALID_TYPE_QUALITY, {
typeRequested: quality,
typesAvailable: DownloadQuality_1.DownloadQuality_arr
});
type = type.replace('mp3', 'mp4');

@@ -100,3 +106,6 @@ getPlayer(id).then((res) => __awaiter(this, void 0, void 0, function* () {

if (!download)
return reject(new errors_1.YTjsErrorError(errorCodes_1.default.DOWNLOAD_LINK_NOT_FOUND, { typeRequested: type, qualityRequested: quality || 'default' }));
return reject(new errors_1.YTjsErrorError(errorCodes_1.default.DOWNLOAD_LINK_NOT_FOUND, {
typeRequested: type,
qualityRequested: quality || 'default'
}));
try {

@@ -106,3 +115,3 @@ download.url = decode(download);

catch (e) {
return reject(new errors_1.YTjsErrorError(errorCodes_1.default.DECHIPHER_ERROR, { error: e }));
return reject(new errors_1.YTjsErrorError(errorCodes_1.default.DECHIPHER_ERROR, e));
}

@@ -144,3 +153,2 @@ download.expireDate = new Date(parseInt(download.url.split('expire=')[1].split('&')[0]) * 1000);

return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
let time = (new Date()).getTime().toString();
(0, requestManager_1.requestToYtApi)('player?key=', {

@@ -147,0 +155,0 @@ videoId: videoId,

@@ -1,4 +0,5 @@

import { Music, Playlist, Home, Album } from "../models/";
import { Album, Home, Music, Playlist } from "../models/";
import { TypeSearch_param } from '../types/TypeSearch';
import { TypeunitOfTime } from "../types/TypePage";
import Search from "../models/Search";
/**

@@ -9,3 +10,3 @@ * Search music, video or other with query

*/
export declare function search(query: string, type?: string | TypeSearch_param): Promise<Array<(Music | Album)>>;
export declare function search(query: string, type?: string | TypeSearch_param): Promise<(Search | Array<Music | Album>)>;
/**

@@ -32,3 +33,4 @@ * Get the home page (NOT WORKING)

export declare function getPlaylist(id: string): Promise<Playlist>;
export declare function GetData(id: string): Promise<any>;
export declare function GetDataVid(id: string): Promise<any>;
export declare function GetDataPl(id: string): Promise<any>;
//# sourceMappingURL=searchManager.d.ts.map

@@ -15,3 +15,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.GetData = exports.getPlaylist = exports.get = exports.relative = exports.getPage = exports.search = void 0;
exports.GetDataPl = exports.GetDataVid = exports.getPlaylist = exports.get = exports.relative = exports.getPage = exports.search = void 0;
const requestManager_1 = require("../utils/requestManager");

@@ -25,2 +25,3 @@ const models_1 = require("../models/");

const typeBuilder_1 = require("../utils/typeBuilder");
const Search_1 = __importDefault(require("../models/Search"));
/**

@@ -32,32 +33,72 @@ * Search music, video or other with query

function search(query, type = TypeSearch_1.TypeSearch[0]) {
var _a, _b, _c, _d, _e, _f;
return __awaiter(this, void 0, void 0, function* () {
// Check If type is valid with TypeSearch
type = type.toUpperCase();
if (!TypeSearch_1.TypeSearch.includes(type))
throw new errors_1.YTjsErrorError(errorCodes_1.default.INVALID_TYPE_SEARCH, { typeRequested: type, typesAvailable: TypeSearch_1.TypeSearch });
if ((_a = query.match(/^(?:https?:\/\/)?(?:www\.)?.*(?:youtu\.be\/|youtube\.com(?:\/embed\/|\/v\/|\/watch\?v=|\/watch\?.+&v=))([\w-]{11})(?:.+)?$/)) === null || _a === void 0 ? void 0 : _a[1]) {
return [new models_1.Music(yield GetData(((_b = query.match(/^(?:https?:\/\/)?(?:www\.)?.*(?:youtu\.be\/|youtube\.com(?:\/embed\/|\/v\/|\/watch\?v=|\/watch\?.+&v=))([\w-]{11})(?:.+)?$/)) === null || _b === void 0 ? void 0 : _b[1]) || ''))];
}
else {
let data = [];
const resp_data = [];
const typeSearch = (0, TypeSearch_1.getTypeSearchParam)(type);
if (typeSearch === null || typeSearch === void 0 ? void 0 : typeSearch.param) {
const music_data = yield (0, requestManager_1.requestToYtApi)('search', {
"query": query,
"params": typeSearch.param,
});
data = music_data.data.contents.tabbedSearchResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents.filter((item) => { var _a, _b, _c; return ((_c = (_b = (_a = item === null || item === void 0 ? void 0 : item.musicShelfRenderer) === null || _a === void 0 ? void 0 : _a.title) === null || _b === void 0 ? void 0 : _b.runs[0]) === null || _c === void 0 ? void 0 : _c.text) === typeSearch.ytID; })[0];
data = ((_c = data[Object.keys(data)[0]]) === null || _c === void 0 ? void 0 : _c.contents) || [];
}
for (const item of data) {
if (type === 'ALBUM') {
resp_data.push(new models_1.Album((0, extract_1.extract_dataFromPlaylist)(item.musicResponsiveListItemRenderer)));
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
var _a, _b, _c, _d, _e, _f, _g, _h;
type = type.toUpperCase();
if (!TypeSearch_1.TypeSearch.includes(type))
return reject(new errors_1.YTjsErrorError(errorCodes_1.default.INVALID_TYPE_SEARCH, {
typeRequested: type,
typesAvailable: TypeSearch_1.TypeSearch
}));
let searchs = [];
let typeSearch = (0, TypeSearch_1.getTypeSearchParam)(type);
if (query.match(/^(?:https?:\/\/)?(?:www\.|music\.)?(?:youtube\.com|youtu\.?be)\/.+$/)) {
const url = new URL(query);
if (!url.hostname.includes('youtube'))
return reject(new errors_1.YTjsErrorError(errorCodes_1.default.INVALID_URL, url.hostname));
if (url.searchParams.get('list')) {
try {
return resolve([new models_1.Album(yield GetDataPl(url.searchParams.get('list') || ''))]);
}
catch (e) {
return reject(e);
}
}
else if (url.searchParams.get('v')) {
try {
return resolve([new models_1.Music((0, extract_1.extract_dataFromGetData)(yield GetDataVid(url.searchParams.get('v') || '')))]);
}
catch (e) {
return reject(e);
}
}
else if (url.pathname.includes('channel'))
return reject(new errors_1.YTjsErrorError(errorCodes_1.default.CURRENTLY_NOT_SUPPORTED));
else
resp_data.push(new models_1.Music((0, extract_1.extract_dataFromGetData)(yield GetData(((_e = (_d = item.musicResponsiveListItemRenderer) === null || _d === void 0 ? void 0 : _d.playlistItemData) === null || _e === void 0 ? void 0 : _e.videoId) || ((_f = item.musicResponsiveListItemRenderer) === null || _f === void 0 ? void 0 : _f.onTap.watchEndpoint.videoId)))));
return reject(new errors_1.YTjsErrorError(errorCodes_1.default.INVALID_URL, url.hostname));
}
return resp_data;
}
else if ((_a = query.match(/^(?:https?:\/\/)?(?:www\.)?.*(?:youtu\.be\/|youtube\.com(?:\/embed\/|\/v\/|\/watch\?v=|\/watch\?.+&v=))([\w-]{11})(?:.+)?$/)) === null || _a === void 0 ? void 0 : _a[1]) {
return resolve([new models_1.Music(yield GetDataVid(((_b = query.match(/^(?:https?:\/\/)?(?:www\.)?.*(?:youtu\.be\/|youtube\.com(?:\/embed\/|\/v\/|\/watch\?v=|\/watch\?.+&v=))([\w-]{11})(?:.+)?$/)) === null || _b === void 0 ? void 0 : _b[1]) || ''))]);
}
const music_data = yield (0, requestManager_1.requestToYtApi)('search', {
"query": query,
"params": typeSearch.param,
});
if (!typeSearch.param) {
for (const item of music_data.data.contents.tabbedSearchResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents.filter((item) => { var _a, _b, _c; return (_c = (_b = (_a = item === null || item === void 0 ? void 0 : item.musicShelfRenderer) === null || _a === void 0 ? void 0 : _a.title) === null || _b === void 0 ? void 0 : _b.runs[0]) === null || _c === void 0 ? void 0 : _c.text.includes(typeSearch.ytID); })) {
if ((_d = (_c = item.musicShelfRenderer) === null || _c === void 0 ? void 0 : _c.contents) === null || _d === void 0 ? void 0 : _d.length) {
for (const music of item.musicShelfRenderer.contents) {
// Get type of music
if ((item.musicShelfRenderer.title.runs[0].text === 'Songs' || item.musicShelfRenderer.title.runs[0].text === 'Videos') && ((_f = (_e = music.musicResponsiveListItemRenderer.flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].navigationEndpoint) === null || _e === void 0 ? void 0 : _e.watchEndpoint) === null || _f === void 0 ? void 0 : _f.videoId)) {
try {
searchs.push((yield this.search(`https://music.youtube.com/watch?v=${(_h = (_g = music.musicResponsiveListItemRenderer.flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].navigationEndpoint) === null || _g === void 0 ? void 0 : _g.watchEndpoint) === null || _h === void 0 ? void 0 : _h.videoId}`, 'MUSIC'))[0]);
}
catch (e) {
reject(e);
}
}
else if (item.musicShelfRenderer.title.runs[0].text === 'Albums') {
searchs.push((yield this.search(`https://music.youtube.com/playlist?list=${music.musicResponsiveListItemRenderer.navigationEndpoint.browseEndpoint.browseId}`, 'ALBUM'))[0]);
}
}
}
}
}
if (!searchs.length)
return reject(new errors_1.YTjsErrorError(errorCodes_1.default.NOT_FOUND, query));
else if (!typeSearch.param)
return resolve(new Search_1.default(query, searchs));
else
resolve(searchs);
}));
});

@@ -127,3 +168,3 @@ }

resp_data.music_list.find((e: any) => e.title === title_music_list).musics.push(
extract_dataFromGetData(await searchManager.GetData(musicdt.musicResponsiveListItemRenderer.playlistItemData.videoId))
extract_dataFromGetData(await searchManager.GetDataVid(musicdt.musicResponsiveListItemRenderer.playlistItemData.videoId))
)

@@ -188,3 +229,3 @@ }

return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
GetData(id).then((e) => {
GetDataVid(id).then((e) => {
return resolve(new models_1.Music((0, extract_1.extract_dataFromGetData)(e)));

@@ -212,3 +253,3 @@ }).catch((e) => __awaiter(this, void 0, void 0, function* () {

for (let i = 0; music_list.length > i; i++) {
//musics.push(extract_dataFromGetData(await GetData(music_list[i].musicResponsiveListItemRenderer.playlistItemData.videoId)))
//musics.push(extract_dataFromGetData(await GetDataVid(music_list[i].musicResponsiveListItemRenderer.playlistItemData.videoId)))
if (music_list.length === i + 1)

@@ -238,3 +279,3 @@ resolve(null);

return resolve(data);
const data2 = yield index_1.searchManager.GetData(data.musicCarouselShelfRenderer.contents[i].musicResponsiveListItemRenderer.playlistItemData.videoId);
const data2 = yield index_1.searchManager.GetDataVid(data.musicCarouselShelfRenderer.contents[i].musicResponsiveListItemRenderer.playlistItemData.videoId);
if (data2.videoId) {

@@ -248,3 +289,3 @@ data.musicCarouselShelfRenderer.contents[i] = data2;

}
function GetData(id) {
function GetDataVid(id) {
return new Promise((resolve, reject) => {

@@ -262,4 +303,13 @@ (0, requestManager_1.requestToYtApi)('next', {

}
exports.GetData = GetData;
const MUSIC_param = 'EgWKAQIIAWoOEAMQBBAJEA4QChAFEBU%3D', VIDEO_param = 'EgWKAQIQAWoOEAkQBRADEAQQDhAKEBU%3D';
exports.GetDataVid = GetDataVid;
function GetDataPl(id) {
return new Promise((resolve, reject) => {
(0, requestManager_1.requestToYtApi)('browse', {
"browseId": id
}).then((res) => {
resolve((0, extract_1.extract_dataFromPlaylist)(res.data));
}).catch(reject);
});
}
exports.GetDataPl = GetDataPl;
//# sourceMappingURL=searchManager.js.map

@@ -8,2 +8,6 @@ import { Artwork, Music } from "./index";

/**
* The description of the album
*/
description?: string;
/**
* The YT id of the album

@@ -10,0 +14,0 @@ */

@@ -19,2 +19,3 @@ "use strict";

this.name = album.name;
this.description = album === null || album === void 0 ? void 0 : album.description;
this.id = album.id;

@@ -38,3 +39,3 @@ this.artworks = (album === null || album === void 0 ? void 0 : album.artworks) || [];

for (const item of res.data.contents.singleColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents[0].musicShelfRenderer.contents) {
resp_data.push(new index_1.Music((0, extract_1.extract_dataFromGetData)(yield (0, searchManager_1.GetData)(((_b = (_a = item.musicResponsiveListItemRenderer) === null || _a === void 0 ? void 0 : _a.playlistItemData) === null || _b === void 0 ? void 0 : _b.videoId) || ((_c = item.musicResponsiveListItemRenderer) === null || _c === void 0 ? void 0 : _c.onTap.watchEndpoint.videoId)))));
resp_data.push(new index_1.Music((0, extract_1.extract_dataFromGetData)(yield (0, searchManager_1.GetDataVid)(((_b = (_a = item.musicResponsiveListItemRenderer) === null || _a === void 0 ? void 0 : _a.playlistItemData) === null || _b === void 0 ? void 0 : _b.videoId) || ((_c = item.musicResponsiveListItemRenderer) === null || _c === void 0 ? void 0 : _c.onTap.watchEndpoint.videoId)))));
}

@@ -41,0 +42,0 @@ resolve(resp_data);

@@ -1,28 +0,22 @@

import { Artwork, Artist } from "./";
export default class Music {
import Music from "./Music";
import Album from "./Album";
export default class Search {
/**
* An array of Artwork objects
* The query of the search
*/
artworks: Array<Artwork>;
query: string;
/**
* The YTmusic id of the music
* An array of musics
*/
id: string;
musics: Array<Music>;
/**
* The title of the music
* An array of musics videos
*/
name: string;
videos: Array<Music>;
/**
* The artist of the music
* An array of albums
*/
artist: Artist;
/**
* The type of the video (audio or video)
*/
typeVideo: string;
private artist_data;
constructor(search_result: any);
extractArtistData(search_result: any): any;
getLink(): string;
albums: Array<Album>;
constructor(query: string, search_result: any);
}
//# sourceMappingURL=Search.d.ts.map
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const _1 = require("./");
class Music {
constructor(search_result) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
this.artworks = search_result.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails;
this.id = search_result.playlistItemData.videoId;
this.name = search_result.flexColumns.find((item) => { var _a, _b, _c, _d, _e, _f; return ((_f = (_e = (_d = (_c = (_b = (_a = item === null || item === void 0 ? void 0 : item.musicResponsiveListItemFlexColumnRenderer) === null || _a === void 0 ? void 0 : _a.text) === null || _b === void 0 ? void 0 : _b.runs) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.navigationEndpoint) === null || _e === void 0 ? void 0 : _e.watchEndpoint) === null || _f === void 0 ? void 0 : _f.videoId) === this.id; }).musicResponsiveListItemFlexColumnRenderer.text.runs[0].text;
this.artist = new _1.Artist({
name: (_a = this.extractArtistData(search_result)) === null || _a === void 0 ? void 0 : _a.text,
id: (_d = (_c = (_b = this.extractArtistData(search_result)) === null || _b === void 0 ? void 0 : _b.navigationEndpoint) === null || _c === void 0 ? void 0 : _c.browseEndpoint) === null || _d === void 0 ? void 0 : _d.browseId
});
this.typeVideo = (_p = (_o = (_m = (_l = (_k = (_j = (_h = (_g = (_f = (_e = search_result === null || search_result === void 0 ? void 0 : search_result.flexColumns) === null || _e === void 0 ? void 0 : _e.find((item) => { var _a, _b, _c, _d, _e, _f; return ((_f = (_e = (_d = (_c = (_b = (_a = item === null || item === void 0 ? void 0 : item.musicResponsiveListItemFlexColumnRenderer) === null || _a === void 0 ? void 0 : _a.text) === null || _b === void 0 ? void 0 : _b.runs) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.navigationEndpoint) === null || _e === void 0 ? void 0 : _e.watchEndpoint) === null || _f === void 0 ? void 0 : _f.videoId) === this.id; })) === null || _f === void 0 ? void 0 : _f.musicResponsiveListItemFlexColumnRenderer) === null || _g === void 0 ? void 0 : _g.text) === null || _h === void 0 ? void 0 : _h.runs) === null || _j === void 0 ? void 0 : _j[0]) === null || _k === void 0 ? void 0 : _k.navigationEndpoint) === null || _l === void 0 ? void 0 : _l.watchEndpoint) === null || _m === void 0 ? void 0 : _m.watchEndpointMusicSupportedConfigs) === null || _o === void 0 ? void 0 : _o.watchEndpointMusicConfig) === null || _p === void 0 ? void 0 : _p.musicVideoType;
const Music_1 = __importDefault(require("./Music"));
const Album_1 = __importDefault(require("./Album"));
class Search {
constructor(query, search_result) {
this.query = query;
this.musics = search_result.filter((item) => Music_1.default.prototype.isPrototypeOf(item) && item.isAudioOnly);
this.videos = search_result.filter((item) => Music_1.default.prototype.isPrototypeOf(item) && !item.isAudioOnly);
this.albums = search_result.filter((item) => Album_1.default.prototype.isPrototypeOf(item));
}
extractArtistData(search_result) {
let artist_dt = {};
search_result.flexColumns.find((item) => {
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
artist_dt = (_b = (_a = item === null || item === void 0 ? void 0 : item.musicResponsiveListItemFlexColumnRenderer) === null || _a === void 0 ? void 0 : _a.text) === null || _b === void 0 ? void 0 : _b.runs.find((item2) => { var _a, _b, _c, _d, _e, _f, _g, _h; return ((_d = (_c = (_b = (_a = item2 === null || item2 === void 0 ? void 0 : item2.navigationEndpoint) === null || _a === void 0 ? void 0 : _a.browseEndpoint) === null || _b === void 0 ? void 0 : _b.browseEndpointContextSupportedConfigs) === null || _c === void 0 ? void 0 : _c.browseEndpointContextMusicConfig) === null || _d === void 0 ? void 0 : _d.pageType) === 'MUSIC_PAGE_TYPE_ARTIST' || ((_h = (_g = (_f = (_e = item2 === null || item2 === void 0 ? void 0 : item2.navigationEndpoint) === null || _e === void 0 ? void 0 : _e.browseEndpoint) === null || _f === void 0 ? void 0 : _f.browseEndpointContextSupportedConfigs) === null || _g === void 0 ? void 0 : _g.browseEndpointContextMusicConfig) === null || _h === void 0 ? void 0 : _h.pageType) === 'MUSIC_PAGE_TYPE_USER_CHANNEL'; });
return ((_j = (_h = (_g = (_f = (_e = (_d = (_c = item === null || item === void 0 ? void 0 : item.musicResponsiveListItemFlexColumnRenderer) === null || _c === void 0 ? void 0 : _c.text) === null || _d === void 0 ? void 0 : _d.runs.find((item2) => {
var _a, _b, _c, _d, _e, _f, _g, _h;
return ((_d = (_c = (_b = (_a = item2 === null || item2 === void 0 ? void 0 : item2.navigationEndpoint) === null || _a === void 0 ? void 0 : _a.browseEndpoint) === null || _b === void 0 ? void 0 : _b.browseEndpointContextSupportedConfigs) === null || _c === void 0 ? void 0 : _c.browseEndpointContextMusicConfig) === null || _d === void 0 ? void 0 : _d.pageType) === 'MUSIC_PAGE_TYPE_ARTIST' || ((_h = (_g = (_f = (_e = item2 === null || item2 === void 0 ? void 0 : item2.navigationEndpoint) === null || _e === void 0 ? void 0 : _e.browseEndpoint) === null || _f === void 0 ? void 0 : _f.browseEndpointContextSupportedConfigs) === null || _g === void 0 ? void 0 : _g.browseEndpointContextMusicConfig) === null || _h === void 0 ? void 0 : _h.pageType) === 'MUSIC_PAGE_TYPE_USER_CHANNEL';
})) === null || _e === void 0 ? void 0 : _e.navigationEndpoint) === null || _f === void 0 ? void 0 : _f.browseEndpoint) === null || _g === void 0 ? void 0 : _g.browseEndpointContextSupportedConfigs) === null || _h === void 0 ? void 0 : _h.browseEndpointContextMusicConfig) === null || _j === void 0 ? void 0 : _j.pageType) === 'MUSIC_PAGE_TYPE_ARTIST';
});
return artist_dt;
}
getLink() {
return `https://music.youtube.com/watch?v=${this.id}`;
}
}
exports.default = Music;
exports.default = Search;
//# sourceMappingURL=Search.js.map

@@ -5,6 +5,7 @@ export declare class TypeSearchData {

static ALBUM: any;
static ALL: any;
}
export declare const TypeSearch: string[];
export type TypeSearch_param = 'MUSIC' | 'VIDEO' | 'ALBUM';
export type TypeSearch_param = 'MUSIC' | 'VIDEO' | 'ALBUM' | 'ALL';
export declare function getTypeSearchParam(search: string): TypeSearchData;
//# sourceMappingURL=TypeSearch.d.ts.map

@@ -18,4 +18,8 @@ "use strict";

};
TypeSearchData.ALL = {
param: '',
ytID: ''
};
exports.TypeSearchData = TypeSearchData;
exports.TypeSearch = ['MUSIC', 'VIDEO', 'ALBUM'];
exports.TypeSearch = ['MUSIC', 'VIDEO', 'ALBUM', 'ALL'];
function getTypeSearchParam(search) {

@@ -22,0 +26,0 @@ if (exports.TypeSearch.includes(search)) {

@@ -84,27 +84,23 @@ "use strict";

function extract_dataFromPlaylist(data) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
let artists = [], date = 0, name = '', id;
for (let item of (data === null || data === void 0 ? void 0 : data.flexColumns) || []) {
if (((_c = (_b = (_a = item === null || item === void 0 ? void 0 : item.musicResponsiveListItemFlexColumnRenderer) === null || _a === void 0 ? void 0 : _a.text) === null || _b === void 0 ? void 0 : _b.runs) === null || _c === void 0 ? void 0 : _c.length) > 1) {
for (let itemtext of item.musicResponsiveListItemFlexColumnRenderer.text.runs) {
if ((_e = (_d = itemtext.navigationEndpoint) === null || _d === void 0 ? void 0 : _d.browseEndpoint) === null || _e === void 0 ? void 0 : _e.browseId) {
artists.push(new models_1.Artist({
name: itemtext.text,
id: (_g = (_f = itemtext.navigationEndpoint) === null || _f === void 0 ? void 0 : _f.browseEndpoint) === null || _g === void 0 ? void 0 : _g.browseId
}));
}
else if (itemtext.text.match(/([0-9]{4})/g)) {
date = parseInt(itemtext.text);
}
}
for (let item of ((_b = (_a = data.header.musicDetailHeaderRenderer) === null || _a === void 0 ? void 0 : _a.subtitle) === null || _b === void 0 ? void 0 : _b.runs) || []) {
// Check if the item is an artist
if (((_g = (_f = (_e = (_d = (_c = item.navigationEndpoint) === null || _c === void 0 ? void 0 : _c.browseEndpoint) === null || _d === void 0 ? void 0 : _d.browseEndpointContextSupportedConfigs) === null || _e === void 0 ? void 0 : _e.browseEndpointContextMusicConfig) === null || _f === void 0 ? void 0 : _f.pageType) === null || _g === void 0 ? void 0 : _g.includes('ARTIST')) || ((_m = (_l = (_k = (_j = (_h = item.navigationEndpoint) === null || _h === void 0 ? void 0 : _h.browseEndpoint) === null || _j === void 0 ? void 0 : _j.browseEndpointContextSupportedConfigs) === null || _k === void 0 ? void 0 : _k.browseEndpointContextMusicConfig) === null || _l === void 0 ? void 0 : _l.pageType) === null || _m === void 0 ? void 0 : _m.includes('USER'))) {
artists.push(new models_1.Artist({
name: item.text,
id: (_p = (_o = item.navigationEndpoint) === null || _o === void 0 ? void 0 : _o.browseEndpoint) === null || _p === void 0 ? void 0 : _p.browseId
}));
// Check if the item is a date
}
else if ((_l = (_k = (_j = (_h = item === null || item === void 0 ? void 0 : item.musicResponsiveListItemFlexColumnRenderer) === null || _h === void 0 ? void 0 : _h.text) === null || _j === void 0 ? void 0 : _j.runs) === null || _k === void 0 ? void 0 : _k[0]) === null || _l === void 0 ? void 0 : _l.text) {
name = item.musicResponsiveListItemFlexColumnRenderer.text.runs[0].text;
else {
if (item.text.match(/([0-9]{4})/g))
date = parseInt(item.text);
}
}
id = (_o = (_m = data === null || data === void 0 ? void 0 : data.navigationEndpoint) === null || _m === void 0 ? void 0 : _m.browseEndpoint) === null || _o === void 0 ? void 0 : _o.browseId;
return {
artworks: data.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails.map((e) => new models_1.Artwork(e)),
name,
id,
artworks: data.header.musicDetailHeaderRenderer.thumbnail.croppedSquareThumbnailRenderer.thumbnail.thumbnails.map((e) => new models_1.Artwork(e)),
name: data.header.musicDetailHeaderRenderer.title.runs[0].text,
description: (_t = (_s = (_r = (_q = data.header.musicDetailHeaderRenderer) === null || _q === void 0 ? void 0 : _q.description) === null || _r === void 0 ? void 0 : _r.runs) === null || _s === void 0 ? void 0 : _s[0]) === null || _t === void 0 ? void 0 : _t.text,
id: (_v = (_u = data.responseContext) === null || _u === void 0 ? void 0 : _u.serviceTrackingParams) === null || _v === void 0 ? void 0 : _v.find((e) => e.service === 'GFEEDBACK').params.find((e) => e.key === 'browse_id').value.split('/').pop(),
artists: artists,

@@ -111,0 +107,0 @@ date: date

{
"name": "ytmusic_api_unofficial",
"version": "1.1.0-beta.2.6.8",
"version": "1.1.0-beta.2.6.130",
"description": "A simple API to get music from YouTube Music",

@@ -5,0 +5,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc