ytmusic_api_unofficial
Version:
A simple API to get music from YouTube Music
151 lines • 11.8 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.THUMBNAIL_RENDERER = exports.THUMBNAILS = exports.THUMBNAIL = exports.SUBTITLE3 = exports.SUBTITLE2 = exports.SUBTITLE_RUN = exports.SUBTITLE_RUNS = exports.SUBTITLE = exports.TEXT_RUN_TEXT = exports.TEXT_RUN = exports.TEXT_RUNS = exports.TITLE_TEXT = exports.TITLE = exports.TOGGLED_BUTTON = exports.ICON_TYPE = exports.NAVIGATION_VIDEO_TYPE = exports.NAVIGATION_WATCH_PLAYLIST_ID = exports.WATCH_PID = exports.NAVIGATION_PLAYLIST_ID = exports.QUEUE_VIDEO_ID = exports.NAVIGATION_VIDEO_ID = exports.WATCH_PLAYLIST_ID = exports.PLAYLIST_ID = exports.WATCH_VIDEO_ID = exports.PAGE_TYPE = exports.NAVIGATION_BROWSE_ID = exports.NAVIGATION_BROWSE = exports.PLAY_BUTTON = exports.OVERLAY_RENDERER = exports.TOGGLE_MENU = exports.MENU_SERVICE = exports.MENU_LIKE_STATUS = exports.MENU_ITEMS = exports.MENU = exports.GRID_ITEMS = exports.GRID = exports.MUSIC_SHELF = exports.ITEM_SECTION = exports.RESPONSIVE_HEADER = exports.TWO_COLUMN_TAB = exports.SECTION_LIST_ITEM = exports.SECTION_LIST = exports.SECTION = exports.SINGLE_COLUMN_TAB = exports.SINGLE_COLUMN = exports.TWO_COLUMN_RENDERER = exports.TAB_1_CONTENT = exports.TAB_CONTENT = exports.RUN_TEXT = exports.CONTENT = void 0;
exports.HEADER_CHART_THUMBNAIL = exports.HEADER_CHART_TITLE = exports.CHARTS_SHELF_PLAYLISTID = exports.CHARTS_SHELF_RENDERER = exports.PLAYLIST_SHELF_HEADER_RENDERER = exports.ALBUM_SHELF_HEADER_RENDERER = exports.ALBUM_SHELF_RENDERER = exports.ALBUM_SHELF_RENDERER_ARTIST = exports.PLAYLIST_SHELF_RENDERER_ARTIST = exports.PLAYLIST_SHELF_RENDERER = exports.SUBSCRIBE_BUTTON = exports.LONGTEXT_RUNS = exports.FRAMEWORK_MUTATIONS = exports.CARD_SHELF_TITLE = exports.CAROUSEL_TITLE = exports.CAROUSEL_CONTENTS = exports.IMMERSIVE_CAROUSEL = exports.CAROUSEL = exports.DESCRIPTION_PLAYLIST = exports.DESCRIPTION = exports.DESCRIPTION_SHELF = exports.HEADER_PLAYLIST_THUMBNAIL = exports.HEADER_ARTIST_THUMBNAIL = exports.HEADER_PLAYLIST_TITLE = exports.HEADER_ARTIST_TITLE = exports.HEADER_ARTIST = exports.HEADER_MUSIC_VISUAL = exports.HEADER_SIDE = exports.HEADER_EDITABLE_DETAIL = exports.EDITABLE_PLAYLIST_DETAIL_HEADER = exports.HEADER_DETAIL = exports.HEADER = exports.MULTI_SELECT = exports.MENU_RADIO_PLAYLIST_ID = exports.MENU_PLAYLIST_ID = exports.SECTION_LIST_CONTINUATION = exports.TASTE_PROFILE_ARTIST = exports.TASTE_PROFILE_ITEMS = exports.MNIR = exports.MTRIR = exports.MRLIR = exports.MMRIR = exports.CATEGORY_PARAMS = exports.CATEGORY_TITLE = exports.SUBTITLE_BADGE_LABEL = exports.BADGE_LABEL = exports.BADGE_PATH = exports.FEEDBACK_TOKEN = exports.THUMBNAIL_CROPPED = exports.THUMBNAIL_OVERLAY = void 0;
exports.ALBUM_LINK = exports.HEADER_CHART_DESCRIPTION = void 0;
exports.nav = nav;
exports.findObjectByKey = findObjectByKey;
exports.findObjectsByKey = findObjectsByKey;
exports.CONTENT = ["contents", 0];
exports.RUN_TEXT = ["runs", 0, "text"];
exports.TAB_CONTENT = ["tabs", 0, "tabRenderer", "content"];
exports.TAB_1_CONTENT = ["tabs", 1, "tabRenderer", "content"];
exports.TWO_COLUMN_RENDERER = ["contents", "twoColumnBrowseResultsRenderer"];
exports.SINGLE_COLUMN = ["contents", "singleColumnBrowseResultsRenderer"];
exports.SINGLE_COLUMN_TAB = [...exports.SINGLE_COLUMN, ...exports.TAB_CONTENT];
exports.SECTION = ["sectionListRenderer"];
exports.SECTION_LIST = [...exports.SECTION, "contents"];
exports.SECTION_LIST_ITEM = [...exports.SECTION, ...exports.CONTENT];
exports.TWO_COLUMN_TAB = [...exports.TWO_COLUMN_RENDERER];
exports.RESPONSIVE_HEADER = ["musicResponsiveHeaderRenderer"];
exports.ITEM_SECTION = ["itemSectionRenderer", ...exports.CONTENT];
exports.MUSIC_SHELF = ["musicShelfRenderer"];
exports.GRID = ["gridRenderer"];
exports.GRID_ITEMS = [...exports.GRID, "items"];
exports.MENU = ["menu", "menuRenderer"];
exports.MENU_ITEMS = [...exports.MENU, "items"];
exports.MENU_LIKE_STATUS = [...exports.MENU, "topLevelButtons", 0, "likeButtonRenderer", "likeStatus"];
exports.MENU_SERVICE = ["menuServiceItemRenderer", "serviceEndpoint"];
exports.TOGGLE_MENU = "toggleMenuServiceItemRenderer";
exports.OVERLAY_RENDERER = ["musicItemThumbnailOverlayRenderer", "content", "musicPlayButtonRenderer"];
exports.PLAY_BUTTON = ["overlay", ...exports.OVERLAY_RENDERER];
exports.NAVIGATION_BROWSE = ["navigationEndpoint", "browseEndpoint"];
exports.NAVIGATION_BROWSE_ID = [...exports.NAVIGATION_BROWSE, "browseId"];
exports.PAGE_TYPE = ["browseEndpointContextSupportedConfigs", "browseEndpointContextMusicConfig", "pageType"];
exports.WATCH_VIDEO_ID = ["watchEndpoint", "videoId"];
exports.PLAYLIST_ID = ["playlistId"];
exports.WATCH_PLAYLIST_ID = ["watchEndpoint", ...exports.PLAYLIST_ID];
exports.NAVIGATION_VIDEO_ID = ["navigationEndpoint", ...exports.WATCH_VIDEO_ID];
exports.QUEUE_VIDEO_ID = ["queueAddEndpoint", "queueTarget", "videoId"];
exports.NAVIGATION_PLAYLIST_ID = ["navigationEndpoint", ...exports.WATCH_PLAYLIST_ID];
exports.WATCH_PID = ["watchPlaylistEndpoint", ...exports.PLAYLIST_ID];
exports.NAVIGATION_WATCH_PLAYLIST_ID = ["navigationEndpoint", ...exports.WATCH_PID];
exports.NAVIGATION_VIDEO_TYPE = ["watchEndpoint", "watchEndpointMusicSupportedConfigs", "watchEndpointMusicConfig", "musicVideoType",];
exports.ICON_TYPE = ["icon", "iconType"];
exports.TOGGLED_BUTTON = ["toggleButtonRenderer", "isToggled"];
exports.TITLE = ["title", "runs", 0];
exports.TITLE_TEXT = ["title", ...exports.RUN_TEXT];
exports.TEXT_RUNS = ["text", "runs"];
exports.TEXT_RUN = [...exports.TEXT_RUNS, 0];
exports.TEXT_RUN_TEXT = [...exports.TEXT_RUN, "text"];
exports.SUBTITLE = ["subtitle", ...exports.RUN_TEXT];
exports.SUBTITLE_RUNS = ["subtitle", "runs"];
exports.SUBTITLE_RUN = [...exports.SUBTITLE_RUNS, 0];
exports.SUBTITLE2 = [...exports.SUBTITLE_RUNS, 2, "text"];
exports.SUBTITLE3 = [...exports.SUBTITLE_RUNS, 4, "text"];
exports.THUMBNAIL = ["thumbnail", "thumbnails"];
exports.THUMBNAILS = ["thumbnail", "musicThumbnailRenderer", ...exports.THUMBNAIL];
exports.THUMBNAIL_RENDERER = ["thumbnailRenderer", "musicThumbnailRenderer", ...exports.THUMBNAIL];
exports.THUMBNAIL_OVERLAY = ["thumbnailOverlay", ...exports.OVERLAY_RENDERER, "playNavigationEndpoint", ...exports.WATCH_PID];
exports.THUMBNAIL_CROPPED = ["thumbnail", "croppedSquareThumbnailRenderer", ...exports.THUMBNAIL];
exports.FEEDBACK_TOKEN = ["feedbackEndpoint", "feedbackToken"];
exports.BADGE_PATH = [0, "musicInlineBadgeRenderer", "accessibilityData", "accessibilityData", "label"];
exports.BADGE_LABEL = ["badges", ...exports.BADGE_PATH];
exports.SUBTITLE_BADGE_LABEL = ["subtitleBadges", ...exports.BADGE_PATH];
exports.CATEGORY_TITLE = ["musicNavigationButtonRenderer", "buttonText", ...exports.RUN_TEXT];
exports.CATEGORY_PARAMS = ["musicNavigationButtonRenderer", "clickCommand", "browseEndpoint", "params"];
exports.MMRIR = "musicMultiRowListItemRenderer";
exports.MRLIR = "musicResponsiveListItemRenderer";
exports.MTRIR = "musicTwoRowItemRenderer";
exports.MNIR = "menuNavigationItemRenderer";
exports.TASTE_PROFILE_ITEMS = ["contents", "tastebuilderRenderer", "contents"];
exports.TASTE_PROFILE_ARTIST = ["title", "runs"];
exports.SECTION_LIST_CONTINUATION = ["continuationContents", "sectionListContinuation"];
exports.MENU_PLAYLIST_ID = [...exports.MENU_ITEMS, 0, exports.MNIR, ...exports.NAVIGATION_WATCH_PLAYLIST_ID];
exports.MENU_RADIO_PLAYLIST_ID = [...exports.MENU_ITEMS, 0, exports.MNIR, "navigationEndpoint", "watchEndpoint", "playlistId"];
exports.MULTI_SELECT = ["musicMultiSelectMenuItemRenderer"];
exports.HEADER = ["header"];
exports.HEADER_DETAIL = [...exports.HEADER];
exports.EDITABLE_PLAYLIST_DETAIL_HEADER = ["musicEditablePlaylistDetailHeaderRenderer"];
exports.HEADER_EDITABLE_DETAIL = [...exports.HEADER, ...exports.EDITABLE_PLAYLIST_DETAIL_HEADER];
exports.HEADER_SIDE = [...exports.HEADER, "musicSideAlignedItemRenderer"];
exports.HEADER_MUSIC_VISUAL = [...exports.HEADER, "musicVisualHeaderRenderer"];
exports.HEADER_ARTIST = [...exports.HEADER, "musicImmersiveHeaderRenderer"];
exports.HEADER_ARTIST_TITLE = [...exports.HEADER_ARTIST, ...exports.TITLE_TEXT];
exports.HEADER_PLAYLIST_TITLE = [...exports.HEADER_DETAIL, ...exports.TITLE_TEXT];
exports.HEADER_ARTIST_THUMBNAIL = [...exports.HEADER_ARTIST, ...exports.THUMBNAILS];
exports.HEADER_PLAYLIST_THUMBNAIL = [...exports.HEADER_DETAIL];
exports.DESCRIPTION_SHELF = ["musicDescriptionShelfRenderer"];
exports.DESCRIPTION = ["description", ...exports.RUN_TEXT];
exports.DESCRIPTION_PLAYLIST = ["description", ...exports.DESCRIPTION_SHELF, "description", "runs"];
exports.CAROUSEL = ["musicCarouselShelfRenderer"];
exports.IMMERSIVE_CAROUSEL = ["musicImmersiveCarouselShelfRenderer"];
exports.CAROUSEL_CONTENTS = [...exports.CAROUSEL, "contents"];
exports.CAROUSEL_TITLE = [...exports.HEADER, "musicCarouselShelfBasicHeaderRenderer", ...exports.TITLE];
exports.CARD_SHELF_TITLE = [...exports.HEADER, "musicCardShelfHeaderBasicRenderer", ...exports.TITLE_TEXT];
exports.FRAMEWORK_MUTATIONS = ["frameworkUpdates", "entityBatchUpdate", "mutations"];
exports.LONGTEXT_RUNS = ["longBylineText", "runs"];
exports.SUBSCRIBE_BUTTON = ["subscriptionButton", "subscribeButtonRenderer"];
exports.PLAYLIST_SHELF_RENDERER = [...exports.TWO_COLUMN_TAB, "secondaryContents", ...exports.SECTION_LIST_ITEM, "musicPlaylistShelfRenderer"];
exports.PLAYLIST_SHELF_RENDERER_ARTIST = [...exports.SINGLE_COLUMN_TAB, ...exports.SECTION_LIST_ITEM, "musicPlaylistShelfRenderer"];
exports.ALBUM_SHELF_RENDERER_ARTIST = [...exports.SINGLE_COLUMN_TAB, ...exports.SECTION_LIST_ITEM, "gridRenderer"];
exports.ALBUM_SHELF_RENDERER = [...exports.TWO_COLUMN_TAB, "secondaryContents", ...exports.SECTION_LIST_ITEM, "musicShelfRenderer"];
exports.ALBUM_SHELF_HEADER_RENDERER = [...exports.TWO_COLUMN_TAB, ...exports.TAB_CONTENT, ...exports.SECTION_LIST, 0, ...exports.RESPONSIVE_HEADER];
exports.PLAYLIST_SHELF_HEADER_RENDERER = [...exports.TWO_COLUMN_TAB, ...exports.TAB_CONTENT, ...exports.SECTION_LIST, 0, ...exports.RESPONSIVE_HEADER];
exports.CHARTS_SHELF_RENDERER = [...exports.PLAYLIST_SHELF_RENDERER, "contents"];
exports.CHARTS_SHELF_PLAYLISTID = [...exports.PLAYLIST_SHELF_RENDERER, ...exports.PLAYLIST_ID];
exports.HEADER_CHART_TITLE = [...exports.TWO_COLUMN_TAB, ...exports.TAB_CONTENT, ...exports.SECTION_LIST_ITEM, ...exports.RESPONSIVE_HEADER, ...exports.TITLE_TEXT];
exports.HEADER_CHART_THUMBNAIL = [...exports.TWO_COLUMN_TAB, ...exports.TAB_CONTENT, ...exports.SECTION_LIST_ITEM, ...exports.RESPONSIVE_HEADER, ...exports.THUMBNAILS];
exports.HEADER_CHART_DESCRIPTION = [...exports.TWO_COLUMN_TAB, ...exports.TAB_CONTENT, ...exports.SECTION_LIST_ITEM, ...exports.RESPONSIVE_HEADER, "description", ...exports.DESCRIPTION_SHELF, ...exports.DESCRIPTION];
exports.ALBUM_LINK = ["microformat", "microformatDataRenderer", "urlCanonical"];
function nav(root, items, none_if_absent = false, skip_if_absent = false) {
try {
for (const k of items) {
root = root[k];
}
}
catch (e) {
if (none_if_absent) {
return null;
}
else if (skip_if_absent) {
return root;
}
throw new Error(`Unable to find '${items}' on ${JSON.stringify(root)}, exception: ${e}`);
}
return root;
}
function findObjectByKey(objectList, key, nested = null, isKey = false) {
for (let item of objectList) {
if (nested) {
item = item[nested];
}
if (item && key in item) {
return isKey ? item[key] : item;
}
}
return null;
}
function findObjectsByKey(objectList, key, nested) {
const objects = [];
for (let item of objectList) {
if (nested) {
item = item[nested];
}
if (key in item) {
objects.push(item);
}
}
return objects;
}
//# sourceMappingURL=responseBuilder.js.map