Skip to content
Snippets Groups Projects
Verified Commit 62de667f authored by Kai DeLorenzo's avatar Kai DeLorenzo :purple_heart:
Browse files

basic home page and content detail. should be enough to start widevine work

parent b36ff999
No related branches found
No related tags found
No related merge requests found
node_modules
*.js
*.js.map
!build/*
build/dev-config.json
\ No newline at end of file
## Development
1. `npm run npm-dev` or `bun run bun-dev`
2. load `BiliBiliConfig.json` into Grayjay
## Grayjay Bugs
- [ ] something
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512">
<path fill="#1ed760" d="M248 8C111.1 8 0 119.1 0 256s111.1 248 248 248 248-111.1 248-248S384.9 8 248 8Z"/>
<path d="M406.6 231.1c-5.2 0-8.4-1.3-12.9-3.9-71.2-42.5-198.5-52.7-280.9-29.7-3.6 1-8.1 2.6-12.9 2.6-13.2 0-23.3-10.3-23.3-23.6 0-13.6 8.4-21.3 17.4-23.9 35.2-10.3 74.6-15.2 117.5-15.2 73 0 149.5 15.2 205.4 47.8 7.8 4.5 12.9 10.7 12.9 22.6 0 13.6-11 23.3-23.2 23.3zm-31 76.2c-5.2 0-8.7-2.3-12.3-4.2-62.5-37-155.7-51.9-238.6-29.4-4.8 1.3-7.4 2.6-11.9 2.6-10.7 0-19.4-8.7-19.4-19.4s5.2-17.8 15.5-20.7c27.8-7.8 56.2-13.6 97.8-13.6 64.9 0 127.6 16.1 177 45.5 8.1 4.8 11.3 11 11.3 19.7-.1 10.8-8.5 19.5-19.4 19.5zm-26.9 65.6c-4.2 0-6.8-1.3-10.7-3.6-62.4-37.6-135-39.2-206.7-24.5-3.9 1-9 2.6-11.9 2.6-9.7 0-15.8-7.7-15.8-15.8 0-10.3 6.1-15.2 13.6-16.8 81.9-18.1 165.6-16.5 237 26.2 6.1 3.9 9.7 7.4 9.7 16.5s-7.1 15.4-15.2 15.4z"/>
</svg>
\ No newline at end of file
{
"name": "Spotify",
"description": "Listen to millions of songs on Spotify",
"author": "FUTO",
"authorUrl": "https://futo.org",
"platformUrl": "https://spotify.com",
"sourceUrl": "https://plugins.grayjay.app/Spotify/SpotifyConfig.json",
"repositoryUrl": "https://gitlab.futo.org/videostreaming/plugins/spotify",
"scriptUrl": "./SpotifyScript.js",
"version": 1,
"iconUrl": "./SpotifyIcon.png",
"id": "4e365633-6d3f-4267-8941-fdc36631d813",
"scriptSignature": "",
"scriptPublicKey": "",
"packages": [
"Http",
"Utilities"
],
"allowEval": false,
"allowUrls": [
"open.spotify.com",
"spclient.wg.spotify.com",
"gue1-spclient.spotify.com",
"seektables.scdn.co"
],
"authentication": {
"loginUrl": "https://accounts.spotify.com/en/login",
"cookiesToFind": ["SESSDATA"],
"userAgent": "Mozilla/5.0 (Linux; Android 12) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.6099.230 Mobile Safari/537.36"
}
}
build/SpotifyIcon.png

23.8 KiB

const SONG_REGEX = /^https:\/\/open\.spotify\.com\/track\/([a-zA-Z0-9]*)($|\/)/;
const SONG_URL_PREFIX = "https://open.spotify.com/track/";
const IMAGE_URL_PREFIX = "https://i.scdn.co/image/";
const PLATFORM = "Spotify";
// const USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0" as const
const HARDCODED_ZERO = 0;
const HARDCODED_EMPTY_STRING = "";
const local_http = http;
// const local_utility = utility
// set missing constants
Type.Order.Chronological = "Latest releases";
Type.Order.Views = "Most played";
Type.Order.Favorites = "Most favorited";
/** State */
let local_state;
//#region source methods
source.enable = enable;
source.disable = disable;
source.saveState = saveState;
source.getHome = getHome;
// source.searchSuggestions = searchSuggestions
// source.getSearchCapabilities = getSearchCapabilities
// source.search = search
// source.searchChannels = searchChannels
// source.isChannelUrl = isChannelUrl
// source.getChannel = getChannel
// source.getChannelCapabilities = getChannelCapabilities
// source.getChannelContents = getChannelContents
// source.getSearchChannelContentsCapabilities = getSearchChannelContentsCapabilities
// source.searchChannelContents = searchChannelContents
source.isContentDetailsUrl = isContentDetailsUrl;
source.getContentDetails = getContentDetails;
// source.isPlaylistUrl = isPlaylistUrl
// source.searchPlaylists = searchPlaylists
// source.getPlaylist = getPlaylist
// source.getComments = getComments
// source.getSubComments = getSubComments
// source.getLiveChatWindow = getLiveChatWindow
// source.getUserSubscriptions = getUserSubscriptions
// source.getUserPlaylists = getUserPlaylists
/*
if (IS_TESTING) {
const assert_source: SpotifySource = {
enable,
disable,
saveState,
getHome,
searchSuggestions,
search,
getSearchCapabilities,
isContentDetailsUrl,
getContentDetails,
isChannelUrl,
getChannel,
getChannelContents,
getChannelCapabilities,
searchChannelContents,
getSearchChannelContentsCapabilities,
searchChannels,
getComments,
getSubComments,
isPlaylistUrl,
getPlaylist,
searchPlaylists,
getLiveChatWindow,
getUserPlaylists,
getUserSubscriptions
}
if (source.enable === undefined) { assert_never(source.enable) }
if (source.disable === undefined) { assert_never(source.disable) }
if (source.saveState === undefined) { assert_never(source.saveState) }
if (source.getHome === undefined) { assert_never(source.getHome) }
if (source.searchSuggestions === undefined) { assert_never(source.searchSuggestions) }
if (source.search === undefined) { assert_never(source.search) }
if (source.getSearchCapabilities === undefined) { assert_never(source.getSearchCapabilities) }
if (source.isContentDetailsUrl === undefined) { assert_never(source.isContentDetailsUrl) }
if (source.getContentDetails === undefined) { assert_never(source.getContentDetails) }
if (source.isChannelUrl === undefined) { assert_never(source.isChannelUrl) }
if (source.getChannel === undefined) { assert_never(source.getChannel) }
if (source.getChannelContents === undefined) { assert_never(source.getChannelContents) }
if (source.getChannelCapabilities === undefined) { assert_never(source.getChannelCapabilities) }
if (source.searchChannelContents === undefined) { assert_never(source.searchChannelContents) }
if (source.getSearchChannelContentsCapabilities === undefined) { assert_never(source.getSearchChannelContentsCapabilities) }
if (source.searchChannels === undefined) { assert_never(source.searchChannels) }
if (source.getComments === undefined) { assert_never(source.getComments) }
if (source.getSubComments === undefined) { assert_never(source.getSubComments) }
if (source.isPlaylistUrl === undefined) { assert_never(source.isPlaylistUrl) }
if (source.getPlaylist === undefined) { assert_never(source.getPlaylist) }
if (source.searchPlaylists === undefined) { assert_never(source.searchPlaylists) }
if (source.getLiveChatWindow === undefined) { assert_never(source.getLiveChatWindow) }
if (source.getUserPlaylists === undefined) { assert_never(source.getUserPlaylists) }
if (source.getUserSubscriptions === undefined) { assert_never(source.getUserSubscriptions) }
if (IS_TESTING) {
log(assert_source)
}
}
*/
function enable(conf, settings, savedState) {
if (IS_TESTING) {
log("IS_TESTING true");
log("logging configuration");
log(conf);
log("logging settings");
log(settings);
log("logging savedState");
log(savedState);
}
if (savedState !== null) {
const state = JSON.parse(savedState);
local_state = state;
}
else {
const song_uri_id = "6XXxKsu3RJeN3ZvbMYrgQW";
const song_url = `${SONG_URL_PREFIX}${song_uri_id}`;
const song_html_regex = /<script id="session" data-testid="session" type="application\/json">({.*?})<\/script><script id="features" type="application\/json">/;
const match_result = local_http.GET(song_url, {}, false).body.match(song_html_regex);
if (match_result === null) {
throw new ScriptException("regex error");
}
const maybe_json = match_result[1];
if (maybe_json === undefined) {
throw new ScriptException("regex error");
}
const token_response = JSON.parse(maybe_json);
local_state = { bearer_token: token_response.accessToken };
}
}
function disable() {
log("BiliBili log: disabling");
}
function saveState() {
return JSON.stringify(local_state);
}
function getHome() {
const song_uri_id = "6XXxKsu3RJeN3ZvbMYrgQW";
const song_url = `${SONG_URL_PREFIX}${song_uri_id}`;
const song_metadata_response = get_song_metadata(song_uri_id);
const first_artist = song_metadata_response.artist[0];
if (first_artist === undefined) {
throw new ScriptException("missing artist");
}
//https://spclient.wg.spotify.com/metadata/4/track/e4eac7232f3d48fb965b5a03c49eb93a
const songs = [new PlatformVideo({
id: new PlatformID(PLATFORM, song_uri_id, plugin.config.id),
name: song_metadata_response.name,
author: new PlatformAuthorLink(new PlatformID(PLATFORM, first_artist.gid, plugin.config.id), first_artist.name, "https://open.spotify.com/artist/6vWDO969PvNqNYHIOW5v0m"),
url: song_url,
thumbnails: new Thumbnails(song_metadata_response.album.cover_group.image.map(function (image) {
return new Thumbnail(`${IMAGE_URL_PREFIX}${image.file_id}`, image.height);
})),
duration: song_metadata_response.duration / 1000,
viewCount: HARDCODED_ZERO,
isLive: false,
shareUrl: song_metadata_response.canonical_uri,
// readonly uploadDate?: number
})];
return new VideoPager(songs, false);
}
// https://open.spotify.com/track/6XXxKsu3RJeN3ZvbMYrgQW
function isContentDetailsUrl(url) {
return SONG_REGEX.test(url);
}
function getContentDetails(url) {
const match_result = url.match(SONG_REGEX);
if (match_result === null) {
throw new ScriptException("regex error");
}
const maybe_song_uri_id = match_result[1];
if (maybe_song_uri_id === undefined) {
throw new ScriptException("regex error");
}
const song_url = `${SONG_URL_PREFIX}${maybe_song_uri_id}`;
const song_metadata_response = get_song_metadata(maybe_song_uri_id);
const first_artist = song_metadata_response.artist[0];
if (first_artist === undefined) {
throw new ScriptException("missing artist");
}
const format = "MP4_128";
const maybe_file_id = song_metadata_response.file.find(function (file) { return file.format === format; })?.file_id;
if (maybe_file_id === undefined) {
throw new ScriptException("missing expected format");
}
const file_manifest_url_prefix = "https://gue1-spclient.spotify.com/storage-resolve/v2/files/audio/interactive/10/";
const file_manifest_params = "?product=9&alt=json";
const file_manifest = JSON.parse(local_http.GET(`${file_manifest_url_prefix}${maybe_file_id}${file_manifest_params}`, { Authorization: `Bearer ${local_state.bearer_token}` }, false).body);
log(file_manifest);
const duration = song_metadata_response.duration / 1000;
const audio_sources = file_manifest.cdnurl.map(function (url) {
return new AudioUrlSource({
//audio/mp4; codecs="mp4a.40.2
name: format,
bitrate: HARDCODED_ZERO,
container: "audio/mp4",
codecs: "mp4a.40.2",
duration,
url,
language: Language.UNKNOWN,
});
});
//https://seektables.scdn.co/seektable/4c652e57fd36f84d77af2b9d1d1332327a8fd774.json
const seektable_url_prefix = "https://seektables.scdn.co/seektable/";
const seektable_response = JSON.parse(local_http.GET(`${seektable_url_prefix}${maybe_file_id}.json`, {}, false).body);
log(seektable_response);
const get_license_url_url = "https://gue1-spclient.spotify.com/melody/v1/license_url?keysystem=com.widevine.alpha&sdk_name=harmony&sdk_version=4.41.0";
const get_license_response = JSON.parse(local_http.GET(get_license_url_url, { Authorization: `Bearer ${local_state.bearer_token}` }, false).body);
log(get_license_response);
const license_url = `https://gue1-spclient.spotify.com/${get_license_response.uri}`;
log(license_url);
return new PlatformVideoDetails({
id: new PlatformID(PLATFORM, maybe_song_uri_id, plugin.config.id),
name: song_metadata_response.name,
author: new PlatformAuthorLink(new PlatformID(PLATFORM, first_artist.gid, plugin.config.id), first_artist.name, "https://open.spotify.com/artist/6vWDO969PvNqNYHIOW5v0m"),
url: song_url,
thumbnails: new Thumbnails(song_metadata_response.album.cover_group.image.map(function (image) {
return new Thumbnail(`${IMAGE_URL_PREFIX}${image.file_id}`, image.height);
})),
duration,
viewCount: HARDCODED_ZERO,
isLive: false,
shareUrl: song_metadata_response.canonical_uri,
// readonly uploadDate?: number
description: HARDCODED_EMPTY_STRING,
video: new UnMuxVideoSourceDescriptor([], audio_sources),
// readonly live?: IVideoSource
rating: new RatingLikes(HARDCODED_ZERO)
// readonly subtitles?: ISubtitleSource[]
});
}
function get_song_metadata(song_uri_id) {
const song_metadata_url = "https://spclient.wg.spotify.com/metadata/4/track/";
const song_metadata_response = JSON.parse(local_http.GET(`${song_metadata_url}${get_gid(song_uri_id)}`, {
Authorization: `Bearer ${local_state.bearer_token}`,
Accept: "application/json"
}, false).body);
return song_metadata_response;
}
// function assert_never(value: never) {
// log(value)
// }
// function log_passthrough<T>(value: T): T {
// log(value)
// return value
// }
// https://open.spotifycdn.com/cdn/build/web-player/vendor~web-player.391a2438.js
const Z = "0123456789abcdef";
const Q = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ee = [];
ee.length = 256;
for (let ke = 0; ke < 256; ke++)
// @ts-expect-error
ee[ke] = Z[ke >> 4] + Z[15 & ke];
const te = [];
te.length = 128;
for (let ke = 0; ke < Q.length; ++ke)
te[Q.charCodeAt(ke)] = ke;
function get_gid(song_uri_id) {
return 22 === song_uri_id.length ? function (e) {
if (22 !== e.length)
return null;
const t = 2.3283064365386963e-10, n = 4294967296, i = 238328;
let o, r, a, s, c;
// @ts-expect-error
return o = 56800235584 * te[e.charCodeAt(0)] + 916132832 * te[e.charCodeAt(1)] + 14776336 * te[e.charCodeAt(2)] + 238328 * te[e.charCodeAt(3)] + 3844 * te[e.charCodeAt(4)] + 62 * te[e.charCodeAt(5)] + te[e.charCodeAt(6)],
r = o * t | 0,
o -= r * n,
// @ts-expect-error
c = 3844 * te[e.charCodeAt(7)] + 62 * te[e.charCodeAt(8)] + te[e.charCodeAt(9)],
o = o * i + c,
o -= (c = o * t | 0) * n,
r = r * i + c,
// @ts-expect-error
c = 3844 * te[e.charCodeAt(10)] + 62 * te[e.charCodeAt(11)] + te[e.charCodeAt(12)],
o = o * i + c,
o -= (c = o * t | 0) * n,
r = r * i + c,
r -= (c = r * t | 0) * n,
a = c,
// @ts-expect-error
c = 3844 * te[e.charCodeAt(13)] + 62 * te[e.charCodeAt(14)] + te[e.charCodeAt(15)],
o = o * i + c,
o -= (c = o * t | 0) * n,
r = r * i + c,
r -= (c = r * t | 0) * n,
a = a * i + c,
// @ts-expect-error
c = 3844 * te[e.charCodeAt(16)] + 62 * te[e.charCodeAt(17)] + te[e.charCodeAt(18)],
o = o * i + c,
o -= (c = o * t | 0) * n,
r = r * i + c,
r -= (c = r * t | 0) * n,
a = a * i + c,
a -= (c = a * t | 0) * n,
s = c,
// @ts-expect-error
c = 3844 * te[e.charCodeAt(19)] + 62 * te[e.charCodeAt(20)] + te[e.charCodeAt(21)],
o = o * i + c,
o -= (c = o * t | 0) * n,
r = r * i + c,
r -= (c = r * t | 0) * n,
a = a * i + c,
a -= (c = a * t | 0) * n,
s = s * i + c,
s -= (c = s * t | 0) * n,
// @ts-expect-error
c ? null : ee[s >>> 24] + ee[s >>> 16 & 255] + ee[s >>> 8 & 255] + ee[255 & s] + ee[a >>> 24] + ee[a >>> 16 & 255] + ee[a >>> 8 & 255] + ee[255 & a] + ee[r >>> 24] + ee[r >>> 16 & 255] + ee[r >>> 8 & 255] + ee[255 & r] + ee[o >>> 24] + ee[o >>> 16 & 255] + ee[o >>> 8 & 255] + ee[255 & o];
}(song_uri_id) : song_uri_id;
}
// export { get_gid };
//# sourceMappingURL=http://localhost:8080/SpotifyScript.js.map
\ No newline at end of file
{"version":3,"file":"SpotifyScript.js","sourceRoot":"http://localhost:8080/","sources":["SpotifyScript.ts"],"names":[],"mappings":"AAUA,MAAM,UAAU,GAAG,4DAA4D,CAAA;AAC/E,MAAM,eAAe,GAAG,iCAA0C,CAAA;AAClE,MAAM,gBAAgB,GAAG,0BAAmC,CAAA;AAE5D,MAAM,QAAQ,GAAG,SAAkB,CAAA;AACnC,uGAAuG;AAEvG,MAAM,cAAc,GAAG,CAAU,CAAA;AACjC,MAAM,sBAAsB,GAAG,EAAW,CAAA;AAE1C,MAAM,UAAU,GAAG,IAAI,CAAA;AACvB,gCAAgC;AAEhC,wBAAwB;AACxB,IAAI,CAAC,KAAK,CAAC,aAAa,GAAG,iBAAiB,CAAA;AAC5C,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,aAAa,CAAA;AAChC,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,gBAAgB,CAAA;AAEvC,YAAY;AACZ,IAAI,WAAkB,CAAA;AAEtB,wBAAwB;AACxB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAA;AACtB,MAAM,CAAC,OAAO,GAAG,OAAO,CAAA;AACxB,MAAM,CAAC,SAAS,GAAG,SAAS,CAAA;AAC5B,MAAM,CAAC,OAAO,GAAG,OAAO,CAAA;AAExB,+CAA+C;AAC/C,uDAAuD;AACvD,yBAAyB;AAEzB,yCAAyC;AACzC,qCAAqC;AACrC,iCAAiC;AAEjC,yDAAyD;AACzD,iDAAiD;AACjD,qFAAqF;AACrF,uDAAuD;AAEvD,MAAM,CAAC,mBAAmB,GAAG,mBAAmB,CAAA;AAChD,MAAM,CAAC,iBAAiB,G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B,mBAAmB;YACnB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAA;IACxS,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAA;AAChC,CAAC;AAED,OAAO,EACH,OAAO,EACV,CAAA"}
\ No newline at end of file
import {
FileManifestResponse,
GetLicenseResponse,
SeektableResponse,
Settings,
SongMetadataResponse,
// SpotifySource,
State
} from "./types.js"
const SONG_REGEX = /^https:\/\/open\.spotify\.com\/track\/([a-zA-Z0-9]*)($|\/)/
const SONG_URL_PREFIX = "https://open.spotify.com/track/" as const
const IMAGE_URL_PREFIX = "https://i.scdn.co/image/" as const
const PLATFORM = "Spotify" as const
// const USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0" as const
const HARDCODED_ZERO = 0 as const
const HARDCODED_EMPTY_STRING = "" as const
const local_http = http
// const local_utility = utility
// set missing constants
Type.Order.Chronological = "Latest releases"
Type.Order.Views = "Most played"
Type.Order.Favorites = "Most favorited"
/** State */
let local_state: State
//#region source methods
source.enable = enable
source.disable = disable
source.saveState = saveState
source.getHome = getHome
// source.searchSuggestions = searchSuggestions
// source.getSearchCapabilities = getSearchCapabilities
// source.search = search
// source.searchChannels = searchChannels
// source.isChannelUrl = isChannelUrl
// source.getChannel = getChannel
// source.getChannelCapabilities = getChannelCapabilities
// source.getChannelContents = getChannelContents
// source.getSearchChannelContentsCapabilities = getSearchChannelContentsCapabilities
// source.searchChannelContents = searchChannelContents
source.isContentDetailsUrl = isContentDetailsUrl
source.getContentDetails = getContentDetails
// source.isPlaylistUrl = isPlaylistUrl
// source.searchPlaylists = searchPlaylists
// source.getPlaylist = getPlaylist
// source.getComments = getComments
// source.getSubComments = getSubComments
// source.getLiveChatWindow = getLiveChatWindow
// source.getUserSubscriptions = getUserSubscriptions
// source.getUserPlaylists = getUserPlaylists
/*
if (IS_TESTING) {
const assert_source: SpotifySource = {
enable,
disable,
saveState,
getHome,
searchSuggestions,
search,
getSearchCapabilities,
isContentDetailsUrl,
getContentDetails,
isChannelUrl,
getChannel,
getChannelContents,
getChannelCapabilities,
searchChannelContents,
getSearchChannelContentsCapabilities,
searchChannels,
getComments,
getSubComments,
isPlaylistUrl,
getPlaylist,
searchPlaylists,
getLiveChatWindow,
getUserPlaylists,
getUserSubscriptions
}
if (source.enable === undefined) { assert_never(source.enable) }
if (source.disable === undefined) { assert_never(source.disable) }
if (source.saveState === undefined) { assert_never(source.saveState) }
if (source.getHome === undefined) { assert_never(source.getHome) }
if (source.searchSuggestions === undefined) { assert_never(source.searchSuggestions) }
if (source.search === undefined) { assert_never(source.search) }
if (source.getSearchCapabilities === undefined) { assert_never(source.getSearchCapabilities) }
if (source.isContentDetailsUrl === undefined) { assert_never(source.isContentDetailsUrl) }
if (source.getContentDetails === undefined) { assert_never(source.getContentDetails) }
if (source.isChannelUrl === undefined) { assert_never(source.isChannelUrl) }
if (source.getChannel === undefined) { assert_never(source.getChannel) }
if (source.getChannelContents === undefined) { assert_never(source.getChannelContents) }
if (source.getChannelCapabilities === undefined) { assert_never(source.getChannelCapabilities) }
if (source.searchChannelContents === undefined) { assert_never(source.searchChannelContents) }
if (source.getSearchChannelContentsCapabilities === undefined) { assert_never(source.getSearchChannelContentsCapabilities) }
if (source.searchChannels === undefined) { assert_never(source.searchChannels) }
if (source.getComments === undefined) { assert_never(source.getComments) }
if (source.getSubComments === undefined) { assert_never(source.getSubComments) }
if (source.isPlaylistUrl === undefined) { assert_never(source.isPlaylistUrl) }
if (source.getPlaylist === undefined) { assert_never(source.getPlaylist) }
if (source.searchPlaylists === undefined) { assert_never(source.searchPlaylists) }
if (source.getLiveChatWindow === undefined) { assert_never(source.getLiveChatWindow) }
if (source.getUserPlaylists === undefined) { assert_never(source.getUserPlaylists) }
if (source.getUserSubscriptions === undefined) { assert_never(source.getUserSubscriptions) }
if (IS_TESTING) {
log(assert_source)
}
}
*/
function enable(conf: SourceConfig, settings: Settings, savedState: string | null) {
if (IS_TESTING) {
log("IS_TESTING true")
log("logging configuration")
log(conf)
log("logging settings")
log(settings)
log("logging savedState")
log(savedState)
}
if (savedState !== null) {
const state: State = JSON.parse(savedState)
local_state = state
} else {
const song_uri_id = "6XXxKsu3RJeN3ZvbMYrgQW"
const song_url = `${SONG_URL_PREFIX}${song_uri_id}`
const song_html_regex = /<script id="session" data-testid="session" type="application\/json">({.*?})<\/script><script id="features" type="application\/json">/
const match_result = local_http.GET(song_url, {}, false).body.match(song_html_regex)
if (match_result === null) {
throw new ScriptException("regex error")
}
const maybe_json = match_result[1]
if (maybe_json === undefined) {
throw new ScriptException("regex error")
}
const token_response: { accessToken: string } = JSON.parse(maybe_json)
local_state = { bearer_token: token_response.accessToken }
}
}
function disable() {
log("BiliBili log: disabling")
}
function saveState() {
return JSON.stringify(local_state)
}
function getHome() {
const song_uri_id = "6XXxKsu3RJeN3ZvbMYrgQW"
const song_url = `${SONG_URL_PREFIX}${song_uri_id}`
const song_metadata_response: SongMetadataResponse = get_song_metadata(song_uri_id)
const first_artist = song_metadata_response.artist[0]
if (first_artist === undefined) {
throw new ScriptException("missing artist")
}
//https://spclient.wg.spotify.com/metadata/4/track/e4eac7232f3d48fb965b5a03c49eb93a
const songs = [new PlatformVideo({
id: new PlatformID(PLATFORM, song_uri_id, plugin.config.id),
name: song_metadata_response.name,
author: new PlatformAuthorLink(new PlatformID(PLATFORM, first_artist.gid, plugin.config.id), first_artist.name, "https://open.spotify.com/artist/6vWDO969PvNqNYHIOW5v0m"),
url: song_url,
thumbnails: new Thumbnails(song_metadata_response.album.cover_group.image.map(function (image) {
return new Thumbnail(`${IMAGE_URL_PREFIX}${image.file_id}`, image.height)
})),
duration: song_metadata_response.duration / 1000,
viewCount: HARDCODED_ZERO,
isLive: false,
shareUrl: song_metadata_response.canonical_uri,
// readonly uploadDate?: number
})]
return new VideoPager(songs, false)
}
// https://open.spotify.com/track/6XXxKsu3RJeN3ZvbMYrgQW
function isContentDetailsUrl(url: string) {
return SONG_REGEX.test(url)
}
function getContentDetails(url: string) {
const match_result = url.match(SONG_REGEX)
if (match_result === null) {
throw new ScriptException("regex error")
}
const maybe_song_uri_id = match_result[1]
if (maybe_song_uri_id === undefined) {
throw new ScriptException("regex error")
}
const song_url = `${SONG_URL_PREFIX}${maybe_song_uri_id}`
const song_metadata_response: SongMetadataResponse = get_song_metadata(maybe_song_uri_id)
const first_artist = song_metadata_response.artist[0]
if (first_artist === undefined) {
throw new ScriptException("missing artist")
}
const format = "MP4_128"
const maybe_file_id = song_metadata_response.file.find(function (file) { return file.format === format })?.file_id
if (maybe_file_id === undefined) {
throw new ScriptException("missing expected format")
}
const file_manifest_url_prefix = "https://gue1-spclient.spotify.com/storage-resolve/v2/files/audio/interactive/10/"
const file_manifest_params = "?product=9&alt=json"
const file_manifest: FileManifestResponse = JSON.parse(
local_http.GET(
`${file_manifest_url_prefix}${maybe_file_id}${file_manifest_params}`,
{ Authorization: `Bearer ${local_state.bearer_token}` },
false
).body
)
log(file_manifest)
const duration = song_metadata_response.duration / 1000
const audio_sources = file_manifest.cdnurl.map(function (url) {
return new AudioUrlSource({
//audio/mp4; codecs="mp4a.40.2
name: format,
bitrate: HARDCODED_ZERO,
container: "audio/mp4",
codecs: "mp4a.40.2",
duration,
url,
language: Language.UNKNOWN,
})
})
//https://seektables.scdn.co/seektable/4c652e57fd36f84d77af2b9d1d1332327a8fd774.json
const seektable_url_prefix = "https://seektables.scdn.co/seektable/"
const seektable_response: SeektableResponse = JSON.parse(
local_http.GET(
`${seektable_url_prefix}${maybe_file_id}.json`,
{},
false
).body
)
log(seektable_response)
const get_license_url_url = "https://gue1-spclient.spotify.com/melody/v1/license_url?keysystem=com.widevine.alpha&sdk_name=harmony&sdk_version=4.41.0"
const get_license_response: GetLicenseResponse = JSON.parse(
local_http.GET(
get_license_url_url,
{ Authorization: `Bearer ${local_state.bearer_token}` },
false
).body
)
log(get_license_response)
const license_url = `https://gue1-spclient.spotify.com/${get_license_response.uri}`
log(license_url)
return new PlatformVideoDetails({
id: new PlatformID(PLATFORM, maybe_song_uri_id, plugin.config.id),
name: song_metadata_response.name,
author: new PlatformAuthorLink(new PlatformID(PLATFORM, first_artist.gid, plugin.config.id), first_artist.name, "https://open.spotify.com/artist/6vWDO969PvNqNYHIOW5v0m"),
url: song_url,
thumbnails: new Thumbnails(song_metadata_response.album.cover_group.image.map(function (image) {
return new Thumbnail(`${IMAGE_URL_PREFIX}${image.file_id}`, image.height)
})),
duration,
viewCount: HARDCODED_ZERO,
isLive: false,
shareUrl: song_metadata_response.canonical_uri,
// readonly uploadDate?: number
description: HARDCODED_EMPTY_STRING,
video: new UnMuxVideoSourceDescriptor([], audio_sources),
// readonly live?: IVideoSource
rating: new RatingLikes(HARDCODED_ZERO)
// readonly subtitles?: ISubtitleSource[]
})
}
function get_song_metadata(song_uri_id: string): SongMetadataResponse {
const song_metadata_url = "https://spclient.wg.spotify.com/metadata/4/track/"
const song_metadata_response: SongMetadataResponse = JSON.parse(
local_http.GET(
`${song_metadata_url}${get_gid(song_uri_id)}`,
{
Authorization: `Bearer ${local_state.bearer_token}`,
Accept: "application/json"
},
false
).body
)
return song_metadata_response
}
// function assert_never(value: never) {
// log(value)
// }
// function log_passthrough<T>(value: T): T {
// log(value)
// return value
// }
// https://open.spotifycdn.com/cdn/build/web-player/vendor~web-player.391a2438.js
const Z = "0123456789abcdef"
const Q = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
const ee: string[] = []
ee.length = 256
for (let ke = 0; ke < 256; ke++)
// @ts-expect-error
ee[ke] = Z[ke >> 4] + Z[15 & ke]
const te: number[] = []
te.length = 128
for (let ke = 0; ke < Q.length; ++ke)
te[Q.charCodeAt(ke)] = ke
function get_gid(song_uri_id: string) {
return 22 === song_uri_id.length ? function (e) {
if (22 !== e.length)
return null
const t = 2.3283064365386963e-10
, n = 4294967296
, i = 238328
let o, r, a, s, c
// @ts-expect-error
return o = 56800235584 * te[e.charCodeAt(0)] + 916132832 * te[e.charCodeAt(1)] + 14776336 * te[e.charCodeAt(2)] + 238328 * te[e.charCodeAt(3)] + 3844 * te[e.charCodeAt(4)] + 62 * te[e.charCodeAt(5)] + te[e.charCodeAt(6)],
r = o * t | 0,
o -= r * n,
// @ts-expect-error
c = 3844 * te[e.charCodeAt(7)] + 62 * te[e.charCodeAt(8)] + te[e.charCodeAt(9)],
o = o * i + c,
o -= (c = o * t | 0) * n,
r = r * i + c,
// @ts-expect-error
c = 3844 * te[e.charCodeAt(10)] + 62 * te[e.charCodeAt(11)] + te[e.charCodeAt(12)],
o = o * i + c,
o -= (c = o * t | 0) * n,
r = r * i + c,
r -= (c = r * t | 0) * n,
a = c,
// @ts-expect-error
c = 3844 * te[e.charCodeAt(13)] + 62 * te[e.charCodeAt(14)] + te[e.charCodeAt(15)],
o = o * i + c,
o -= (c = o * t | 0) * n,
r = r * i + c,
r -= (c = r * t | 0) * n,
a = a * i + c,
// @ts-expect-error
c = 3844 * te[e.charCodeAt(16)] + 62 * te[e.charCodeAt(17)] + te[e.charCodeAt(18)],
o = o * i + c,
o -= (c = o * t | 0) * n,
r = r * i + c,
r -= (c = r * t | 0) * n,
a = a * i + c,
a -= (c = a * t | 0) * n,
s = c,
// @ts-expect-error
c = 3844 * te[e.charCodeAt(19)] + 62 * te[e.charCodeAt(20)] + te[e.charCodeAt(21)],
o = o * i + c,
o -= (c = o * t | 0) * n,
r = r * i + c,
r -= (c = r * t | 0) * n,
a = a * i + c,
a -= (c = a * t | 0) * n,
s = s * i + c,
s -= (c = s * t | 0) * n,
// @ts-expect-error
c ? null : ee[s >>> 24] + ee[s >>> 16 & 255] + ee[s >>> 8 & 255] + ee[255 & s] + ee[a >>> 24] + ee[a >>> 16 & 255] + ee[a >>> 8 & 255] + ee[255 & a] + ee[r >>> 24] + ee[r >>> 16 & 255] + ee[r >>> 8 & 255] + ee[255 & r] + ee[o >>> 24] + ee[o >>> 16 & 255] + ee[o >>> 8 & 255] + ee[255 & o]
}(song_uri_id) : song_uri_id
}
// export {
get_gid
}
This diff is collapsed.
{
"name": "grayjay-spotify-plugin",
"version": "1.0.0",
"description": "make spotify work",
"engines": {
"node": ">=20.0.0"
},
"module": "src/SpotifyScript.ts",
"scripts": {
"bun-test": "bun run build && node --test",
"test": "npm run build && node --test",
"build": "tsc && cp src/SpotifyScript.[tj]s* build && sed -i '/^export/s/^/\\/\\/ /' build/SpotifyScript.[tj]s",
"bun-release": "bun install && bun update && bun x npm-check-updates && bun run bun-test",
"npm-release": "npm install && npm update && npx npm-check-updates && npm test",
"bun-dev": "bun run build && bun x http-server build",
"npm-dev": "npm run build && npx http-server build"
},
"repository": {
"type": "git",
"url": "git+https://gitlab.futo.org/videostreaming/plugins/spotify.git"
},
"keywords": [
"spotify",
"grayjay"
],
"author": "Kai DeLorenzo",
"license": "MPL-2.0",
"bugs": {
"url": "https://gitlab.futo.org/videostreaming/plugins/spotify/issues"
},
"homepage": "https://gitlab.futo.org/videostreaming/plugins/spotify",
"peerDependencies": {
"typescript": "^5.1.3"
},
"type": "module",
"devDependencies": {
"@grayjay/plugin": "gitlab:kaidelorenzo/grayjay-plugin-types#d898f236620e6b5b4d54053c1b15be24bd68a8c1",
"@types/node": "^20.12.7",
"http-server": "^14.1.1",
"npm-check-updates": "^16.14.18"
}
}
//#region imports
import { describe, test } from "node:test"
import assert from "node:assert"
// initializes global state
import "@grayjay/plugin/source.js"
import { get_gid } from "./SpotifyScript.js"
//#endregion
describe("script module", { skip: false }, () => {
test("test disable", { skip: false }, () => {
if (source.disable === undefined) {
throw new Error("Missing disable method")
}
source.disable()
assert.strictEqual("11", (11).toString())
})
test("test get gid", { skip: false }, () => {
const song_uri_id = "6XXxKsu3RJeN3ZvbMYrgQW"
const gid = get_gid(song_uri_id)
assert.strictEqual(gid, "e4eac7232f3d48fb965b5a03c49eb93a")
})
})
import {
FileManifestResponse,
GetLicenseResponse,
SeektableResponse,
Settings,
SongMetadataResponse,
// SpotifySource,
State
} from "./types.js"
const SONG_REGEX = /^https:\/\/open\.spotify\.com\/track\/([a-zA-Z0-9]*)($|\/)/
const SONG_URL_PREFIX = "https://open.spotify.com/track/" as const
const IMAGE_URL_PREFIX = "https://i.scdn.co/image/" as const
const PLATFORM = "Spotify" as const
// const USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0" as const
const HARDCODED_ZERO = 0 as const
const HARDCODED_EMPTY_STRING = "" as const
const local_http = http
// const local_utility = utility
// set missing constants
Type.Order.Chronological = "Latest releases"
Type.Order.Views = "Most played"
Type.Order.Favorites = "Most favorited"
/** State */
let local_state: State
//#region source methods
source.enable = enable
source.disable = disable
source.saveState = saveState
source.getHome = getHome
// source.searchSuggestions = searchSuggestions
// source.getSearchCapabilities = getSearchCapabilities
// source.search = search
// source.searchChannels = searchChannels
// source.isChannelUrl = isChannelUrl
// source.getChannel = getChannel
// source.getChannelCapabilities = getChannelCapabilities
// source.getChannelContents = getChannelContents
// source.getSearchChannelContentsCapabilities = getSearchChannelContentsCapabilities
// source.searchChannelContents = searchChannelContents
source.isContentDetailsUrl = isContentDetailsUrl
source.getContentDetails = getContentDetails
// source.isPlaylistUrl = isPlaylistUrl
// source.searchPlaylists = searchPlaylists
// source.getPlaylist = getPlaylist
// source.getComments = getComments
// source.getSubComments = getSubComments
// source.getLiveChatWindow = getLiveChatWindow
// source.getUserSubscriptions = getUserSubscriptions
// source.getUserPlaylists = getUserPlaylists
/*
if (IS_TESTING) {
const assert_source: SpotifySource = {
enable,
disable,
saveState,
getHome,
searchSuggestions,
search,
getSearchCapabilities,
isContentDetailsUrl,
getContentDetails,
isChannelUrl,
getChannel,
getChannelContents,
getChannelCapabilities,
searchChannelContents,
getSearchChannelContentsCapabilities,
searchChannels,
getComments,
getSubComments,
isPlaylistUrl,
getPlaylist,
searchPlaylists,
getLiveChatWindow,
getUserPlaylists,
getUserSubscriptions
}
if (source.enable === undefined) { assert_never(source.enable) }
if (source.disable === undefined) { assert_never(source.disable) }
if (source.saveState === undefined) { assert_never(source.saveState) }
if (source.getHome === undefined) { assert_never(source.getHome) }
if (source.searchSuggestions === undefined) { assert_never(source.searchSuggestions) }
if (source.search === undefined) { assert_never(source.search) }
if (source.getSearchCapabilities === undefined) { assert_never(source.getSearchCapabilities) }
if (source.isContentDetailsUrl === undefined) { assert_never(source.isContentDetailsUrl) }
if (source.getContentDetails === undefined) { assert_never(source.getContentDetails) }
if (source.isChannelUrl === undefined) { assert_never(source.isChannelUrl) }
if (source.getChannel === undefined) { assert_never(source.getChannel) }
if (source.getChannelContents === undefined) { assert_never(source.getChannelContents) }
if (source.getChannelCapabilities === undefined) { assert_never(source.getChannelCapabilities) }
if (source.searchChannelContents === undefined) { assert_never(source.searchChannelContents) }
if (source.getSearchChannelContentsCapabilities === undefined) { assert_never(source.getSearchChannelContentsCapabilities) }
if (source.searchChannels === undefined) { assert_never(source.searchChannels) }
if (source.getComments === undefined) { assert_never(source.getComments) }
if (source.getSubComments === undefined) { assert_never(source.getSubComments) }
if (source.isPlaylistUrl === undefined) { assert_never(source.isPlaylistUrl) }
if (source.getPlaylist === undefined) { assert_never(source.getPlaylist) }
if (source.searchPlaylists === undefined) { assert_never(source.searchPlaylists) }
if (source.getLiveChatWindow === undefined) { assert_never(source.getLiveChatWindow) }
if (source.getUserPlaylists === undefined) { assert_never(source.getUserPlaylists) }
if (source.getUserSubscriptions === undefined) { assert_never(source.getUserSubscriptions) }
if (IS_TESTING) {
log(assert_source)
}
}
*/
function enable(conf: SourceConfig, settings: Settings, savedState: string | null) {
if (IS_TESTING) {
log("IS_TESTING true")
log("logging configuration")
log(conf)
log("logging settings")
log(settings)
log("logging savedState")
log(savedState)
}
if (savedState !== null) {
const state: State = JSON.parse(savedState)
local_state = state
} else {
const song_uri_id = "6XXxKsu3RJeN3ZvbMYrgQW"
const song_url = `${SONG_URL_PREFIX}${song_uri_id}`
const song_html_regex = /<script id="session" data-testid="session" type="application\/json">({.*?})<\/script><script id="features" type="application\/json">/
const match_result = local_http.GET(song_url, {}, false).body.match(song_html_regex)
if (match_result === null) {
throw new ScriptException("regex error")
}
const maybe_json = match_result[1]
if (maybe_json === undefined) {
throw new ScriptException("regex error")
}
const token_response: { accessToken: string } = JSON.parse(maybe_json)
local_state = { bearer_token: token_response.accessToken }
}
}
function disable() {
log("BiliBili log: disabling")
}
function saveState() {
return JSON.stringify(local_state)
}
function getHome() {
const song_uri_id = "6XXxKsu3RJeN3ZvbMYrgQW"
const song_url = `${SONG_URL_PREFIX}${song_uri_id}`
const song_metadata_response: SongMetadataResponse = get_song_metadata(song_uri_id)
const first_artist = song_metadata_response.artist[0]
if (first_artist === undefined) {
throw new ScriptException("missing artist")
}
//https://spclient.wg.spotify.com/metadata/4/track/e4eac7232f3d48fb965b5a03c49eb93a
const songs = [new PlatformVideo({
id: new PlatformID(PLATFORM, song_uri_id, plugin.config.id),
name: song_metadata_response.name,
author: new PlatformAuthorLink(new PlatformID(PLATFORM, first_artist.gid, plugin.config.id), first_artist.name, "https://open.spotify.com/artist/6vWDO969PvNqNYHIOW5v0m"),
url: song_url,
thumbnails: new Thumbnails(song_metadata_response.album.cover_group.image.map(function (image) {
return new Thumbnail(`${IMAGE_URL_PREFIX}${image.file_id}`, image.height)
})),
duration: song_metadata_response.duration / 1000,
viewCount: HARDCODED_ZERO,
isLive: false,
shareUrl: song_metadata_response.canonical_uri,
// readonly uploadDate?: number
})]
return new VideoPager(songs, false)
}
// https://open.spotify.com/track/6XXxKsu3RJeN3ZvbMYrgQW
function isContentDetailsUrl(url: string) {
return SONG_REGEX.test(url)
}
function getContentDetails(url: string) {
const match_result = url.match(SONG_REGEX)
if (match_result === null) {
throw new ScriptException("regex error")
}
const maybe_song_uri_id = match_result[1]
if (maybe_song_uri_id === undefined) {
throw new ScriptException("regex error")
}
const song_url = `${SONG_URL_PREFIX}${maybe_song_uri_id}`
const song_metadata_response: SongMetadataResponse = get_song_metadata(maybe_song_uri_id)
const first_artist = song_metadata_response.artist[0]
if (first_artist === undefined) {
throw new ScriptException("missing artist")
}
const format = "MP4_128"
const maybe_file_id = song_metadata_response.file.find(function (file) { return file.format === format })?.file_id
if (maybe_file_id === undefined) {
throw new ScriptException("missing expected format")
}
const file_manifest_url_prefix = "https://gue1-spclient.spotify.com/storage-resolve/v2/files/audio/interactive/10/"
const file_manifest_params = "?product=9&alt=json"
const file_manifest: FileManifestResponse = JSON.parse(
local_http.GET(
`${file_manifest_url_prefix}${maybe_file_id}${file_manifest_params}`,
{ Authorization: `Bearer ${local_state.bearer_token}` },
false
).body
)
log(file_manifest)
const duration = song_metadata_response.duration / 1000
const audio_sources = file_manifest.cdnurl.map(function (url) {
return new AudioUrlSource({
//audio/mp4; codecs="mp4a.40.2
name: format,
bitrate: HARDCODED_ZERO,
container: "audio/mp4",
codecs: "mp4a.40.2",
duration,
url,
language: Language.UNKNOWN,
})
})
//https://seektables.scdn.co/seektable/4c652e57fd36f84d77af2b9d1d1332327a8fd774.json
const seektable_url_prefix = "https://seektables.scdn.co/seektable/"
const seektable_response: SeektableResponse = JSON.parse(
local_http.GET(
`${seektable_url_prefix}${maybe_file_id}.json`,
{},
false
).body
)
log(seektable_response)
const get_license_url_url = "https://gue1-spclient.spotify.com/melody/v1/license_url?keysystem=com.widevine.alpha&sdk_name=harmony&sdk_version=4.41.0"
const get_license_response: GetLicenseResponse = JSON.parse(
local_http.GET(
get_license_url_url,
{ Authorization: `Bearer ${local_state.bearer_token}` },
false
).body
)
log(get_license_response)
const license_url = `https://gue1-spclient.spotify.com/${get_license_response.uri}`
log(license_url)
return new PlatformVideoDetails({
id: new PlatformID(PLATFORM, maybe_song_uri_id, plugin.config.id),
name: song_metadata_response.name,
author: new PlatformAuthorLink(new PlatformID(PLATFORM, first_artist.gid, plugin.config.id), first_artist.name, "https://open.spotify.com/artist/6vWDO969PvNqNYHIOW5v0m"),
url: song_url,
thumbnails: new Thumbnails(song_metadata_response.album.cover_group.image.map(function (image) {
return new Thumbnail(`${IMAGE_URL_PREFIX}${image.file_id}`, image.height)
})),
duration,
viewCount: HARDCODED_ZERO,
isLive: false,
shareUrl: song_metadata_response.canonical_uri,
// readonly uploadDate?: number
description: HARDCODED_EMPTY_STRING,
video: new UnMuxVideoSourceDescriptor([], audio_sources),
// readonly live?: IVideoSource
rating: new RatingLikes(HARDCODED_ZERO)
// readonly subtitles?: ISubtitleSource[]
})
}
function get_song_metadata(song_uri_id: string): SongMetadataResponse {
const song_metadata_url = "https://spclient.wg.spotify.com/metadata/4/track/"
const song_metadata_response: SongMetadataResponse = JSON.parse(
local_http.GET(
`${song_metadata_url}${get_gid(song_uri_id)}`,
{
Authorization: `Bearer ${local_state.bearer_token}`,
Accept: "application/json"
},
false
).body
)
return song_metadata_response
}
// function assert_never(value: never) {
// log(value)
// }
// function log_passthrough<T>(value: T): T {
// log(value)
// return value
// }
// https://open.spotifycdn.com/cdn/build/web-player/vendor~web-player.391a2438.js
const Z = "0123456789abcdef"
const Q = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
const ee: string[] = []
ee.length = 256
for (let ke = 0; ke < 256; ke++)
// @ts-expect-error
ee[ke] = Z[ke >> 4] + Z[15 & ke]
const te: number[] = []
te.length = 128
for (let ke = 0; ke < Q.length; ++ke)
te[Q.charCodeAt(ke)] = ke
function get_gid(song_uri_id: string) {
return 22 === song_uri_id.length ? function (e) {
if (22 !== e.length)
return null
const t = 2.3283064365386963e-10
, n = 4294967296
, i = 238328
let o, r, a, s, c
// @ts-expect-error
return o = 56800235584 * te[e.charCodeAt(0)] + 916132832 * te[e.charCodeAt(1)] + 14776336 * te[e.charCodeAt(2)] + 238328 * te[e.charCodeAt(3)] + 3844 * te[e.charCodeAt(4)] + 62 * te[e.charCodeAt(5)] + te[e.charCodeAt(6)],
r = o * t | 0,
o -= r * n,
// @ts-expect-error
c = 3844 * te[e.charCodeAt(7)] + 62 * te[e.charCodeAt(8)] + te[e.charCodeAt(9)],
o = o * i + c,
o -= (c = o * t | 0) * n,
r = r * i + c,
// @ts-expect-error
c = 3844 * te[e.charCodeAt(10)] + 62 * te[e.charCodeAt(11)] + te[e.charCodeAt(12)],
o = o * i + c,
o -= (c = o * t | 0) * n,
r = r * i + c,
r -= (c = r * t | 0) * n,
a = c,
// @ts-expect-error
c = 3844 * te[e.charCodeAt(13)] + 62 * te[e.charCodeAt(14)] + te[e.charCodeAt(15)],
o = o * i + c,
o -= (c = o * t | 0) * n,
r = r * i + c,
r -= (c = r * t | 0) * n,
a = a * i + c,
// @ts-expect-error
c = 3844 * te[e.charCodeAt(16)] + 62 * te[e.charCodeAt(17)] + te[e.charCodeAt(18)],
o = o * i + c,
o -= (c = o * t | 0) * n,
r = r * i + c,
r -= (c = r * t | 0) * n,
a = a * i + c,
a -= (c = a * t | 0) * n,
s = c,
// @ts-expect-error
c = 3844 * te[e.charCodeAt(19)] + 62 * te[e.charCodeAt(20)] + te[e.charCodeAt(21)],
o = o * i + c,
o -= (c = o * t | 0) * n,
r = r * i + c,
r -= (c = r * t | 0) * n,
a = a * i + c,
a -= (c = a * t | 0) * n,
s = s * i + c,
s -= (c = s * t | 0) * n,
// @ts-expect-error
c ? null : ee[s >>> 24] + ee[s >>> 16 & 255] + ee[s >>> 8 & 255] + ee[255 & s] + ee[a >>> 24] + ee[a >>> 16 & 255] + ee[a >>> 8 & 255] + ee[255 & a] + ee[r >>> 24] + ee[r >>> 16 & 255] + ee[r >>> 8 & 255] + ee[255 & r] + ee[o >>> 24] + ee[o >>> 16 & 255] + ee[o >>> 8 & 255] + ee[255 & o]
}(song_uri_id) : song_uri_id
}
export {
get_gid
}
export type Settings = unknown
export type SpotifySource = Required<Source<
{ readonly something: "unknown" },
"unknown",
"POSTS",
"POSTS",
"POSTS"
>>
export type State = {
readonly bearer_token: string
}
export type SongMetadataResponse = {
readonly name: string
/** in milliseconds */
readonly duration: number
readonly album: {
readonly cover_group: {
readonly image: {
readonly file_id: string
readonly height: number
}[]
}
}
readonly artist: {
gid: string
name: string
}[]
readonly date: {
readonly day: number
readonly month: number
readonly year: number
}
readonly canonical_uri: string
readonly file: {
readonly file_id: string
readonly format: "MP4_128" | "AAC_24"
}[]
}
export type FileManifestResponse = {
readonly cdnurl: string[]
}
export type SeektableResponse = {
readonly timescale: 44100
readonly encoder_delay_samples: 1024
readonly index_range: [number, number]
readonly init_range: [number, number]
readonly offset: number
readonly padding_samples: number
readonly pssh: string
readonly pssh_widevine: string
readonly seektable_version: string
readonly segments: [number, number][]
}
export type GetLicenseResponse = {
readonly expires: number
readonly uri: string
}
{
"exclude": ["build"],
"compilerOptions": {
/* Visit https://aka.ms/tsconfig to read more about this file */
/* Projects */
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */
"target": "esnext", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
"moduleDetection": "force", /* Control what method is used to detect module-format JS files. */
/* Modules */
"module": "esnext", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
"moduleResolution": "bundler", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
"typeRoots": ["node_modules/@types", "node_modules/@grayjay"], /* Specify multiple folders that act like './node_modules/@types'. */
// "types": ["grayjay-plugin-types"], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
// "resolveJsonModule": true, /* Enable importing .json files. */
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
/* JavaScript Support */
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
/* Emit */
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
"sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
// "outDir": "./", /* Specify an output folder for all emitted files. */
// "removeComments": true, /* Disable emitting comments. */
// "noEmit": true, /* Disable emitting files from a compilation. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
"sourceRoot": "http://localhost:8080", /* Specify the root path for debuggers to find the reference source code. */
"mapRoot": "http://localhost:8080", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
// "newLine": "crlf", /* Set the newline character for emitting files. */
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
/* Interop Constraints */
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
"noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
"noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
"exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
"noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
"noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
"noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
"noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
"noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
"allowUnusedLabels": false, /* Disable error reporting for unused labels. */
"allowUnreachableCode": false, /* Disable error reporting for unreachable code. */
/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment