Comparing version 0.0.97 to 0.0.99
@@ -5,3 +5,3 @@ import { get_continuations, get_validated_continuations, resend_request_until_valid, validate_response, } from "../continuations.js"; | ||
import { fetch_library_contents, parse_library_artist, parse_library_songs, parse_toast, } from "../parsers/library.js"; | ||
import { parse_playlist_items } from "../parsers/playlists.js"; | ||
import { parse_playlist_items, validate_playlist_id } from "../parsers/playlists.js"; | ||
import { j, jo } from "../util.js"; | ||
@@ -176,3 +176,3 @@ import { get_playlist } from "./playlist.js"; | ||
target: { | ||
playlistId, | ||
playlistId: validate_playlist_id(playlistId), | ||
}, | ||
@@ -179,0 +179,0 @@ }, |
@@ -7,2 +7,15 @@ import { get_continuations } from "../continuations.js"; | ||
import { request_json } from "./_request.js"; | ||
/** | ||
* Gets a "queue" or "watch playlist" for a track or playlist | ||
* | ||
* This function returns all the information required to create a queue from a | ||
* singular track or a playlist | ||
* @param videoId the track ID to create a queue for | ||
* | ||
* If `playlistId` is also specified, this should be a track within the given | ||
* playlist. | ||
* @param playlistId the playlist ID to create a queue for | ||
* @param options | ||
* @returns | ||
*/ | ||
export async function get_queue(videoId, playlistId, options = {}) { | ||
@@ -75,2 +88,3 @@ const { limit = 10, continuation: _continuation = null, radio = false, shuffle = false, autoplay = false, params, signal, } = options; | ||
playlistId: null, | ||
playlistName: null, | ||
tracks: [], | ||
@@ -96,3 +110,3 @@ lyrics: null, | ||
const results = j(renderer, "content.playlistPanelRenderer"); | ||
queue.playlist = jo(results, "title"); | ||
queue.playlist = queue.playlistName = jo(results, "title"); | ||
queue.playlistId = jo(results, "playlistId"); | ||
@@ -145,3 +159,11 @@ queue.author = { | ||
} | ||
export async function get_queue_ids(videoIds, options = {}) { | ||
/** | ||
* Gets the QueueTrack metadata for the specified `videoId`s | ||
* @param videoIds track IDs to look queues for | ||
* @param options | ||
* @returns a list of QueueTracks for each videoId | ||
*/ | ||
export async function get_queue_tracks(videoIds, options = {}) { | ||
if (videoIds.length === 0) | ||
return []; | ||
const response = await request_json("music/get_queue", { | ||
@@ -155,1 +177,6 @@ data: { | ||
} | ||
/** | ||
* @function | ||
* @deprecated use `get_queue_tracks` | ||
*/ | ||
export const get_queue_ids = get_queue_tracks; |
@@ -6,3 +6,3 @@ { | ||
"name": "libmuse", | ||
"version": "0.0.97", | ||
"version": "0.0.99", | ||
"description": "A library to interact with the YouTube Music (InnerTube) api.", | ||
@@ -9,0 +9,0 @@ "tags": [ |
@@ -190,3 +190,3 @@ "use strict"; | ||
target: { | ||
playlistId, | ||
playlistId: (0, playlists_js_1.validate_playlist_id)(playlistId), | ||
}, | ||
@@ -193,0 +193,0 @@ }, |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.get_queue_ids = exports.get_queue = void 0; | ||
exports.get_queue_ids = exports.get_queue_tracks = exports.get_queue = void 0; | ||
const continuations_js_1 = require("../continuations.js"); | ||
@@ -10,2 +10,15 @@ const nav_js_1 = require("../nav.js"); | ||
const _request_js_1 = require("./_request.js"); | ||
/** | ||
* Gets a "queue" or "watch playlist" for a track or playlist | ||
* | ||
* This function returns all the information required to create a queue from a | ||
* singular track or a playlist | ||
* @param videoId the track ID to create a queue for | ||
* | ||
* If `playlistId` is also specified, this should be a track within the given | ||
* playlist. | ||
* @param playlistId the playlist ID to create a queue for | ||
* @param options | ||
* @returns | ||
*/ | ||
async function get_queue(videoId, playlistId, options = {}) { | ||
@@ -78,2 +91,3 @@ const { limit = 10, continuation: _continuation = null, radio = false, shuffle = false, autoplay = false, params, signal, } = options; | ||
playlistId: null, | ||
playlistName: null, | ||
tracks: [], | ||
@@ -99,3 +113,3 @@ lyrics: null, | ||
const results = (0, util_js_1.j)(renderer, "content.playlistPanelRenderer"); | ||
queue.playlist = (0, util_js_1.jo)(results, "title"); | ||
queue.playlist = queue.playlistName = (0, util_js_1.jo)(results, "title"); | ||
queue.playlistId = (0, util_js_1.jo)(results, "playlistId"); | ||
@@ -149,3 +163,11 @@ queue.author = { | ||
exports.get_queue = get_queue; | ||
async function get_queue_ids(videoIds, options = {}) { | ||
/** | ||
* Gets the QueueTrack metadata for the specified `videoId`s | ||
* @param videoIds track IDs to look queues for | ||
* @param options | ||
* @returns a list of QueueTracks for each videoId | ||
*/ | ||
async function get_queue_tracks(videoIds, options = {}) { | ||
if (videoIds.length === 0) | ||
return []; | ||
const response = await (0, _request_js_1.request_json)("music/get_queue", { | ||
@@ -159,2 +181,7 @@ data: { | ||
} | ||
exports.get_queue_ids = get_queue_ids; | ||
exports.get_queue_tracks = get_queue_tracks; | ||
/** | ||
* @function | ||
* @deprecated use `get_queue_tracks` | ||
*/ | ||
exports.get_queue_ids = get_queue_tracks; |
@@ -86,3 +86,2 @@ import { AlbumHeader } from "../parsers/albums.js"; | ||
export interface BaseTimedLyrics { | ||
lyrics: string; | ||
source: string; | ||
@@ -93,5 +92,7 @@ timed: boolean; | ||
timed: false; | ||
lyrics: string | null; | ||
} | ||
export interface TimedLyrics extends BaseTimedLyrics { | ||
timed: true; | ||
lyrics: string; | ||
timed_lyrics: { | ||
@@ -98,0 +99,0 @@ line: string; |
@@ -5,19 +5,81 @@ import { QueueTrack } from "../parsers/queue.js"; | ||
export interface QueueOptions extends PaginationOptions { | ||
/** | ||
* Whether to create a radio for a playlist or video. | ||
* This is a list of tracks that are similar to the given content | ||
*/ | ||
radio?: boolean; | ||
/** | ||
* Whether to return the playlist tracks in shuffled mode | ||
*/ | ||
shuffle?: boolean; | ||
/** | ||
* Return additional tracks that should play after the selected content has | ||
* finished playing | ||
*/ | ||
autoplay?: boolean; | ||
/** | ||
* An additional string that influences what kind of personalized radio is | ||
* played. This is usually got from the `chips` attribute returned by | ||
* `get_queue` | ||
*/ | ||
params?: string; | ||
} | ||
/** | ||
* A chip for a personalised queue for a specific mood or genre. This allows | ||
* to play a different radio for a queue based on the listener's preference | ||
*/ | ||
export interface QueueChip { | ||
/** | ||
* The display label of the personalised queue | ||
*/ | ||
title: string; | ||
/** | ||
* The playlistID that this queue is based on | ||
*/ | ||
playlistId: string; | ||
/** | ||
* A token to pass to `get_queue` to get this specific queue | ||
*/ | ||
params: string; | ||
} | ||
/** | ||
* A description of a "queue" or "watch playlist" for a track or playlist | ||
* | ||
* This is usually returned by `get_queue` @function | ||
*/ | ||
export interface Queue { | ||
/** | ||
* Chips for personalised queues based on a specific mood or criterion | ||
*/ | ||
chips: QueueChip[]; | ||
/** | ||
* The ID of the playlist this queue is referring to | ||
*/ | ||
playlistId: string | null; | ||
/** | ||
* @deprecated use `playlistName` | ||
*/ | ||
playlist: string | null; | ||
/** | ||
* The name of the playlist this queue is referring to | ||
*/ | ||
playlistName: string | null; | ||
/** | ||
* A list of tracks composing this queue | ||
*/ | ||
tracks: QueueTrack[]; | ||
/** | ||
* Pointer to get lyrics for the first queue track | ||
*/ | ||
lyrics: string | null; | ||
/** | ||
* Pointer to get related information for the first queue track | ||
*/ | ||
related: string | null; | ||
/** | ||
* The author of the queue. | ||
* | ||
* This is usually only set for playlist queues, and referrs to the creator of | ||
* the playlist. | ||
*/ | ||
author: { | ||
@@ -27,3 +89,15 @@ name: string | null; | ||
} | null; | ||
/** | ||
* A pointer to get the next tracks of the queue | ||
*/ | ||
continuation: string | null; | ||
/** | ||
* The "current" track to jump to when playing this queue. | ||
* | ||
* This is set when you passed both `videoId` and `playlistId` to `get_queue` | ||
* and referrs to a track inside the playlist the listener wants to click, for | ||
* example when they clicked on a specific track in a playlist, `get_queue` | ||
* will return all playlist tracks but set this property so that you can | ||
* quickly jump to the required track. | ||
*/ | ||
current: { | ||
@@ -35,3 +109,27 @@ videoId: string; | ||
} | ||
/** | ||
* Gets a "queue" or "watch playlist" for a track or playlist | ||
* | ||
* This function returns all the information required to create a queue from a | ||
* singular track or a playlist | ||
* @param videoId the track ID to create a queue for | ||
* | ||
* If `playlistId` is also specified, this should be a track within the given | ||
* playlist. | ||
* @param playlistId the playlist ID to create a queue for | ||
* @param options | ||
* @returns | ||
*/ | ||
export declare function get_queue(videoId: string | null, playlistId?: string | null, options?: QueueOptions): Promise<Queue>; | ||
export declare function get_queue_ids(videoIds: string[], options?: AbortOptions): Promise<QueueTrack[]>; | ||
/** | ||
* Gets the QueueTrack metadata for the specified `videoId`s | ||
* @param videoIds track IDs to look queues for | ||
* @param options | ||
* @returns a list of QueueTracks for each videoId | ||
*/ | ||
export declare function get_queue_tracks(videoIds: string[], options?: AbortOptions): Promise<QueueTrack[]>; | ||
/** | ||
* @function | ||
* @deprecated use `get_queue_tracks` | ||
*/ | ||
export declare const get_queue_ids: typeof get_queue_tracks; |
@@ -5,12 +5,48 @@ import { VideoType } from "./playlists.js"; | ||
export declare function parse_queue_playlist(results: any): QueueTrack[]; | ||
/** | ||
* An object showing information about a track to be represented in a queue | ||
*/ | ||
export interface QueueTrack extends SongRuns { | ||
/** | ||
* The video ID of the track | ||
*/ | ||
videoId: string; | ||
/** | ||
* The name of the track | ||
*/ | ||
title: string; | ||
/** | ||
* The duration (in words) of the track, for example "1:34" | ||
*/ | ||
duration: string | null; | ||
/** | ||
* The duration in seconds of the track, parsed from `duration` | ||
*/ | ||
duration_seconds: number | null; | ||
/** | ||
* The thumbnails of the track | ||
*/ | ||
thumbnails: Thumbnail[]; | ||
/** | ||
* Feedback tokens to use while adding/removing this track from the library | ||
*/ | ||
feedbackTokens: MenuTokens | null; | ||
/** | ||
* Whether or not this track is liked/disliked by the listener | ||
*/ | ||
likeStatus: LikeStatus | null; | ||
/** | ||
* The metadata type of this track | ||
*/ | ||
videoType: VideoType | null; | ||
/** | ||
* Whether this track is explicit or not | ||
*/ | ||
isExplicit: boolean; | ||
/** | ||
* The counterpart of the track. | ||
* | ||
* If this track is a video, the counterpart refers to the audio-only version | ||
* of the song or vice versa. | ||
*/ | ||
counterpart: QueueTrack | null; | ||
@@ -17,0 +53,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
992698
20821