Skip to content

Commit

Permalink
feat: include pluginInfo properties in track
Browse files Browse the repository at this point in the history
  • Loading branch information
SxMAbel committed Jan 13, 2024
1 parent b223428 commit 989bd54
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions src/structures/Player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,17 @@ export interface Track {
readonly requester: unknown | null;
/** Displays the track thumbnail with optional size or null if it's a unsupported source. */
displayThumbnail(size?: Sizes): string;
/** Additional track info provided by plugins. */
pluginInfo: TrackPluginInfo;
}

export interface TrackPluginInfo {
albumName?: string;
albumUrl?: string;
artistArtworkUrl?: string;
artistUrl?: string;
isPreview?: string;
previewUrl?: string;
}

/** Unresolved tracks can't be played normally, they will resolve before playing into a Track. */
Expand Down
14 changes: 11 additions & 3 deletions src/structures/Utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-empty-function, @typescript-eslint/no-unused-vars, @typescript-eslint/no-var-requires*/
import { Manager } from "./Manager";
import { Node, NodeStats } from "./Node";
import { Player, Track, UnresolvedTrack } from "./Player";
import { Player, Track, TrackPluginInfo, UnresolvedTrack } from "./Player";
import { Queue } from "./Queue";

/** @hidden */
Expand Down Expand Up @@ -118,6 +118,14 @@ export abstract class TrackUtils {
: null;
},
requester,
pluginInfo: {
albumName: data.pluginInfo?.albumName,
albumUrl: data.pluginInfo?.albumUrl,
artistArtworkUrl: data.pluginInfo?.artistArtworkUrl,
artistUrl: data.pluginInfo?.artistUrl,
isPreview: data.pluginInfo?.isPreview,
previewUrl: data.pluginInfo?.previewUrl,
},
};

track.displayThumbnail = track.displayThumbnail.bind(track);
Expand Down Expand Up @@ -322,8 +330,8 @@ export interface TrackData {
encoded: string;
/** The detailed information of the track. */
info: TrackDataInfo;
/** Addition track info provided by plugins. */
pluginInfo: object;
/** Additional track info provided by plugins. */
pluginInfo: Record<string, string>;
}

export interface TrackDataInfo {
Expand Down

0 comments on commit 989bd54

Please sign in to comment.