Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge master into hooks-patches #1665

Merged
merged 35 commits into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
c63790a
feat: add path for void linux (#1534)
apprehensions Mar 23, 2022
761ab44
fix: patch part of menu hook (#1529)
CharlieS1103 Mar 24, 2022
55c0eb0
fix: `fullAppDisplay` album info & background (#1543)
huhridge Mar 25, 2022
91d5486
upgrade: Go 1.18 (#1547)
Moulick Mar 26, 2022
eb3adee
fix: menu hook and menu item hook patches (#1548)
CharlieS1103 Mar 26, 2022
a6966fb
chore(shuffle+): updated api (#1559)
huhridge Mar 30, 2022
19628ea
fix(fullAppDisplay): background for full screen display on a vertical…
kwerdenker Mar 30, 2022
a82586b
chore: restructure install.sh (#1535)
apprehensions Mar 30, 2022
0a89573
fix: `New Releases` custom app for Spotify 1.1.81+ (#1563)
th3an7 Apr 6, 2022
be4a441
add: go formatting to the pipeline (#1574)
afonsojramos Apr 7, 2022
7b45e7e
chore: add print for files with bad formatting
afonsojramos Apr 7, 2022
b058b05
fix: specific version fetching in install script (#1578)
afonsojramos Apr 11, 2022
b53b825
chore: enhance specific version fetch (#1582)
afonsojramos Apr 11, 2022
52f577f
chore: added community funding option
afonsojramos Apr 11, 2022
91f95e4
fix: readme links (#1584)
roythearsonist Apr 12, 2022
49f1580
chore: add bash_profile fallback for bash (#1583)
afonsojramos Apr 12, 2022
c68ca66
fix(windows): add missing prefs message (#1571)
CharlieS1103 Apr 14, 2022
647da75
fix(new-releases): switch to `wg://` protocol (#1590)
th3an7 Apr 17, 2022
a5b535a
fix(lyrics): switch to `wg://` protocol (#1587)
rxri Apr 18, 2022
524e985
fix: Fix hooks for Spotify 1.1.83 (#1600)
itsmeow Apr 22, 2022
7e81937
Fix (New-Releases) : Cards Being Displayed Incorrectly (#1606)
Exhigh Apr 24, 2022
8af0be5
fix(devtools): use new method to enable devtools (#1613)
rxri Apr 24, 2022
e352d67
Update css-map.json with latest main-trackInfo-* (#1610)
JulienMaille Apr 24, 2022
427e9c6
fix(devtools): overwrite homePath if snap detected (#1614)
rxri Apr 24, 2022
cb29966
fix: modify filePath from .config to .cache (#1618)
Kafva Apr 25, 2022
ff18628
fix(keyboardShortcut): update selector (#1617)
ajiou Apr 25, 2022
249cf69
feat(restart): check if process is running (#1623)
kyrie25 Apr 28, 2022
6e832e2
fix: Lyrics Plus not showing full lyrics (#1627)
kyrie25 Apr 29, 2022
b294683
fix(lyrics-plus): add null check (#1630)
kyrie25 Apr 29, 2022
916fb62
fix(lyrics-plus): switch to `wg://` protocol for colors (#1631)
huhridge Apr 29, 2022
1b7c6a9
fix(wrapper): adapt few functions to `wg://` protocol (#1632)
huhridge Apr 29, 2022
5a5088f
fix: adapt urls in custom app & extensions to `wg://` protocol (#1633)
huhridge Apr 29, 2022
ef8da6b
chore(lyrics-plus): use DOMParser to parse the genius (#1636)
ajiou May 3, 2022
604fbd0
fix(devtools): patch another location (#1647)
rxri May 4, 2022
bff9c7c
fix(sidebar-config): get elements by classname (#1654)
jeroentvb May 8, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# These are supported funding model platforms

patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
open_collective: spicetify
ko_fi: khanhnguyenxuan
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
custom: ["https://www.paypal.me/khanhas"]
5 changes: 5 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ jobs:
- name: Build
run: go build .

- name: Format
run: |
gofmt -s -l .
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then exit 1; fi

release:
name: Release
strategy:
Expand Down
32 changes: 5 additions & 27 deletions CustomApps/lyrics-plus/ProviderGenius.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,34 +76,12 @@ const ProviderGenius = (function () {
return null;
}

let lyrics = body.match(/<div class="lyrics">(.+?)<\/div>/s);
if (lyrics) {
return lyrics[1];
}

let lyricsSections = body.match(/<div class="Lyrics__Container.+?>.+?<\/div>/gs);
if (lyricsSections) {
lyrics = "";
for (const section of lyricsSections) {
const fragment = section.match(/<div class="Lyrics__Container.+?>(.+?)<\/div>/s);
if (fragment) {
lyrics += fragment[1];
}
}
return lyrics;
}
let lyrics = "";
const parser = new DOMParser();
const htmlDoc = parser.parseFromString(body, "text/html");
const lyricsDiv = htmlDoc.querySelectorAll('div[data-lyrics-container="true"]');

lyricsSections = body.match(/<div ([\w-]+=[\w"]+ )+class="Lyrics__Container.+?>.+?<\/div>/gs);
if (lyricsSections) {
lyrics = "";
for (const section of lyricsSections) {
const fragment = section.match(/<div ([\w-]+=[\w"]+ )+class="Lyrics__Container.+?>(.+?)<\/div>/s);
if (fragment) {
lyrics += fragment[2];
}
}
return lyrics;
}
lyricsDiv.forEach((i) => (lyrics += i.innerHTML + "<br>"));

if (!lyrics?.length) {
console.warn("forceError");
Expand Down
8 changes: 4 additions & 4 deletions CustomApps/lyrics-plus/Providers.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const Providers = {
copyright: null,
};

const baseURL = "hm://lyrics/v1/track/";
const baseURL = "wg://lyrics/v1/track/";
const id = info.uri.split(":")[2];
let body;
try {
Expand All @@ -20,7 +20,7 @@ const Providers = {

const lines = body.lines;
if (!lines || !lines.length) {
return { error: "No lyric", uri: info.uri };
return { error: "No lyrics", uri: info.uri };
}

if (typeof lines[0].time === "number") {
Expand Down Expand Up @@ -58,7 +58,7 @@ const Providers = {
throw "";
}
} catch {
result.error = "No lyric";
result.error = "No lyrics";
return result;
}

Expand Down Expand Up @@ -90,7 +90,7 @@ const Providers = {
try {
list = await ProviderNetease.findLyrics(info);
} catch {
result.error = "No lyric";
result.error = "No lyrics";
return result;
}

Expand Down
2 changes: 1 addition & 1 deletion CustomApps/lyrics-plus/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class LyricsContainer extends react.Component {
async fetchColors(uri) {
let prominent = 0;
try {
const colors = await CosmosAsync.get(`hm://colorextractor/v1/extract-presets?uri=${uri}&format=json`);
const colors = await CosmosAsync.get(`wg://colorextractor/v1/extract-presets?uri=${uri}&format=json`);
prominent = colors.entries[0].color_swatches[4].color;
} catch {
prominent = 0;
Expand Down
37 changes: 28 additions & 9 deletions CustomApps/new-releases/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,12 @@ class Grid extends react.Component {
react.createElement(
"div",
{
className: "main-gridContainer-gridContainer",
className: "main-gridContainer-gridContainer main-gridContainer-fixedWidth",
style: {
"--minimumColumnWidth": "180px",
"--column-width": "minmax(var(--minimumColumnWidth),1fr)",
"--column-count": "auto-fill",
"--grid-gap": "24px",
},
},
separatedByDate[date].map((card) => react.createElement(Card, card.props))
Expand Down Expand Up @@ -154,9 +157,12 @@ class Grid extends react.Component {
react.createElement(
"div",
{
className: "main-gridContainer-gridContainer",
className: "main-gridContainer-gridContainer main-gridContainer-fixedWidth",
style: {
"--minimumColumnWidth": "180px",
"--column-width": "minmax(var(--minimumColumnWidth),1fr)",
"--column-count": "auto-fill",
"--grid-gap": "24px",
},
},
separatedByDate[date]
Expand Down Expand Up @@ -224,19 +230,20 @@ async function getArtistList() {
const body = await CosmosAsync.get("sp://core-collection/unstable/@/list/artists/all?responseFormat=protobufJson", {
policy: { list: { link: true, name: true } },
});
count(true);
return body.item;
}

async function getArtistEverything(artist) {
const uid = artist.link.replace("spotify:artist:", "");
const body = await CosmosAsync.get(`hm://artist/v3/${uid}/desktop/entity?format=json`);
const body = await CosmosAsync.get(`wg://artist/v3/${uid}/desktop/entity?format=json`);
const releases = body?.releases;
const items = [];
const types = [
[CONFIG.album, releases?.albums?.releases, Spicetify.Locale.get("album")],
[CONFIG["appears-on"], releases?.appears_on?.releases, Spicetify.Locale.get("artist.appears-on")],
[CONFIG.compilations, releases?.compilations?.releases, Spicetify.Locale.get("compilation")],
[CONFIG["single-ep"], releases?.singles?.releases, Spicetify.Locale.get("single") + "/" + Spicetify.Locale.get("ep")],
[CONFIG.album, releases.albums?.releases, Spicetify.Locale.get("album")],
[CONFIG["appears-on"], releases.appears_on?.releases, Spicetify.Locale.get("artist.appears-on")],
[CONFIG.compilations, releases.compilations?.releases, Spicetify.Locale.get("compilation")],
[CONFIG["single-ep"], releases.singles?.releases, Spicetify.Locale.get("single") + "/" + Spicetify.Locale.get("ep")],
];
for (const type of types) {
if (type[0] && type[1]) {
Expand Down Expand Up @@ -281,13 +288,25 @@ function metaFromTrack(artist, track) {
return null;
}

var count = (function () {
var counter = 0;
return function (reset = false) {
return reset ? (counter = 0) : counter++;
};
})();

async function fetchTracks() {
let artistList = await getArtistList();
Spicetify.showNotification(`Fetching releases from ${artistList.length} artists`);

const requests = artistList.map(async (obj) => {
const artist = obj.artistMetadata;

return await getArtistEverything(artist);
return await getArtistEverything(artist).catch((err) => {
console.debug("Could not fetch all releases - error code: " + err.status);
if ((err.status = 500)) {
console.debug(`Missing releases from ${count()} artists`);
}
});
});

return await Promise.all(requests);
Expand Down
2 changes: 1 addition & 1 deletion CustomApps/reddit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ async function fetchPlaylist(post) {
async function fetchAlbum(post) {
const arg = post.uri.split(":")[2];
try {
const metadata = await Spicetify.CosmosAsync.get(`hm://album/v1/album-app/album/${arg}/desktop`);
const metadata = await Spicetify.CosmosAsync.get(`wg://album/v1/album-app/album/${arg}/desktop`);
return {
type: typesLocale.album,
uri: post.uri,
Expand Down
4 changes: 2 additions & 2 deletions Extensions/bookmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@

const fetchAlbum = async (uri) => {
const base62 = uri.split(":")[2];
const res = await CosmosAsync.get(`hm://album/v1/album-app/album/${base62}/desktop`);
const res = await CosmosAsync.get(`wg://album/v1/album-app/album/${base62}/desktop`);
return {
uri,
title: res.name,
Expand All @@ -474,7 +474,7 @@

const fetchArtist = async (uri) => {
const base62 = uri.split(":")[2];
const res = await CosmosAsync.get(`hm://artist/v1/${base62}/desktop?format=json`);
const res = await CosmosAsync.get(`wg://artist/v1/${base62}/desktop?format=json`);
return {
uri,
title: res.info.name,
Expand Down
26 changes: 20 additions & 6 deletions Extensions/fullAppDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,10 @@ body.video-full-screen.video-full-screen--hide-ui {

async getAlbumDate(uri) {
const id = uri.replace("spotify:album:", "");
const albumInfo = await Spicetify.CosmosAsync.get(`hm://album/v1/album-app/album/${id}/desktop`);

const albumDate = new Date(albumInfo.year, (albumInfo.month || 1) - 1, albumInfo.day || 0);
const albumInfo = await Spicetify.CosmosAsync.get(`https://api.spotify.com/v1/albums/${id}`);

const albumDate = new Date(albumInfo.release_date);
const recentDate = new Date();
recentDate.setMonth(recentDate.getMonth() - 6);
return albumDate.toLocaleString("default", albumDate > recentDate ? { year: "numeric", month: "short" } : { year: "numeric" });
Expand Down Expand Up @@ -419,25 +420,38 @@ body.video-full-screen.video-full-screen--hide-ui {
const { innerWidth: width, innerHeight: height } = window;
this.back.width = width;
this.back.height = height;
const dim = width > height ? width : height;

const ctx = this.back.getContext("2d");
ctx.imageSmoothingEnabled = false;
ctx.filter = `blur(30px) brightness(0.6)`;
const blur = 30;

const x = -blur * 2;

let y, dim;

if (width > height) {
dim = width;
y = x - (width - height) / 2;
} else {
dim = height;
y = x;
}

const size = dim + 4 * blur;

if (!CONFIG.enableFade) {
ctx.globalAlpha = 1;
ctx.drawImage(nextImg, -blur * 2, -blur * 2 - (width - height) / 2, dim + 4 * blur, dim + 4 * blur);
ctx.drawImage(nextImg, x, y, size, size);
return;
}

let factor = 0.0;
const animate = () => {
ctx.globalAlpha = 1;
ctx.drawImage(prevImg, -blur * 2, -blur * 2 - (width - height) / 2, dim + 4 * blur, dim + 4 * blur);
ctx.drawImage(prevImg, x, y, size, size);
ctx.globalAlpha = Math.sin((Math.PI / 2) * factor);
ctx.drawImage(nextImg, -blur * 2, -blur * 2 - (width - height) / 2, dim + 4 * blur, dim + 4 * blur);
ctx.drawImage(nextImg, x, y, size, size);

if (factor < 1.0) {
factor += 0.016;
Expand Down
2 changes: 1 addition & 1 deletion Extensions/keyboardShortcut.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
}

function clickQueueButton() {
document.querySelector("div.ExtraControls div.control-button-wrapper > button").click();
document.querySelector(".main-nowPlayingBar-right .control-button-wrapper > button").click();
}

function clickNavigatingBackButton() {
Expand Down
14 changes: 6 additions & 8 deletions Extensions/popupLyrics.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @ts-check

// NAME: Popup Lyrics
// AUTHOR: khanhas
// Netease API parser and UI from https://github.com/mantou132/Spotify-Lyrics
Expand Down Expand Up @@ -81,13 +79,13 @@ function PopupLyrics() {

class LyricProviders {
static async fetchSpotify(info) {
const baseURL = "hm://lyrics/v1/track/";
const baseURL = "wg://lyrics/v1/track/";
const id = info.uri.split(":")[2];
const body = await CosmosAsync.get(baseURL + id);

const lines = body.lines;
if (!lines || !lines.length || typeof lines[0].time !== "number") {
return { error: "No lyric" };
return { error: "No lyrics" };
}

const lyrics = lines.map((a) => ({
Expand Down Expand Up @@ -154,7 +152,7 @@ function PopupLyrics() {
}));
return { lyrics };
} else {
return { error: "No lyric" };
return { error: "No lyrics" };
}
} catch (err) {
return { error: err.message };
Expand Down Expand Up @@ -185,7 +183,7 @@ function PopupLyrics() {
let lyricStr = meta.lrc;

if (!lyricStr || !lyricStr.lyric) {
return { error: "No lyric" };
return { error: "No lyrics" };
}
lyricStr = lyricStr.lyric;

Expand Down Expand Up @@ -401,7 +399,7 @@ function PopupLyrics() {
}
}
if (error || !sharedData.lyrics) {
sharedData = { error: "No lyric" };
sharedData = { error: "No lyrics" };
}
}

Expand Down Expand Up @@ -719,7 +717,7 @@ function PopupLyrics() {
drawText(lyricCtx, error, "red");
}
} else if (!lyrics) {
drawText(lyricCtx, "No lyric");
drawText(lyricCtx, "No lyrics");
} else if (audio.duration && lyrics.length) {
renderLyrics(lyricCtx, lyrics, audio.currentTime);
} else if (!audio.duration || lyrics.length === 0) {
Expand Down
6 changes: 3 additions & 3 deletions Extensions/shuffle+.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
*/
const fetchAlbum = async (uri) => {
const arg = uri.split(":")[2];
const res = await Spicetify.CosmosAsync.get(`hm://album/v1/album-app/album/${arg}/desktop`);
const res = await Spicetify.CosmosAsync.get(`wg://album/v1/album-app/album/${arg}/desktop`);
const items = [];
for (const disc of res.discs) {
const availables = disc.tracks.filter((track) => track.playable);
Expand All @@ -231,7 +231,7 @@
* @returns {Promise<string[]>}
*/
const fetchArtist = async (uriBase62) => {
const res = await Spicetify.CosmosAsync.get(`hm://artist/v1/${uriBase62}/desktop?format=json`);
const res = await Spicetify.CosmosAsync.get(`wg://artist/v1/${uriBase62}/desktop?format=json`);
return res.top_tracks.tracks.map((item) => item.uri);
};

Expand All @@ -242,7 +242,7 @@
*/
const fetchDiscography = async (uriBase62) => {
Spicetify.showNotification(`Fetching albums list...`);
let res = await Spicetify.CosmosAsync.get(`hm://artist/v1/${uriBase62}/desktop?format=json`);
let res = await Spicetify.CosmosAsync.get(`wg://artist/v1/${uriBase62}/desktop?format=json`);
let albums = res.releases.albums.releases;
const tracks = [];
for (const album of albums) {
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ Supports Windows, MacOS and Linux.
- Inject Custom apps
- Remove bloated components to improve performance

#### [Installation](https://spicetify.app/docs/getting-started/simple-installation)
#### [Basic Usage](https://spicetify.app/docs/getting-started/basic-usage)
#### [Installation](https://spicetify.app/docs/getting-started)
#### [Basic Usage](https://spicetify.app/docs/getting-started#basic-usage)
#### [Customization](https://spicetify.app/docs/development/customization)
#### [Extensions](https://spicetify.app/docs/getting-started/extensions)
#### [Custom Apps](https://spicetify.app/docs/getting-started/custom-apps)
#### [FAQ](https://spicetify.app/docs/faq)
5 changes: 4 additions & 1 deletion css-map.json
Original file line number Diff line number Diff line change
Expand Up @@ -1732,5 +1732,8 @@
"es9mguuOfkp6pBe1Bjlw": "x-toggle-indicator",
"Js64TOfWtHksI6TQ6knT": "x-toggle-indicatorWrapper",
"n8tsDTs8wDH73kejYfXs": "x-toggle-input",
"JWYoNAyrIIdW30u4PSGE": "x-toggle-wrapper"
"JWYoNAyrIIdW30u4PSGE": "x-toggle-wrapper",
"KKJUKKP3FyKKKdRjWDVj": "main-trackInfo-container",
"tyIiSOWsTxiyox1_LW7F": "main-trackInfo-name",
"M6PIsRD7BGqgMv0WZ_Sv": "main-trackInfo-artists"
}
Loading