Skip to content

Commit

Permalink
Updates to lyrics view, showing writers credits
Browse files Browse the repository at this point in the history
- Fetching writers from Genius (eg. "written by Dave Grohl")
- New font PTSerif for lyrics
- Playlist in sidebar now expand when dragging tracks over
  • Loading branch information
basharovV committed Jan 20, 2024
1 parent fe7a15c commit a384d59
Show file tree
Hide file tree
Showing 11 changed files with 211 additions and 54 deletions.
Binary file added public/fonts/PTSerif-Bold.ttf
Binary file not shown.
Binary file added public/fonts/PTSerif-Regular.ttf
Binary file not shown.
1 change: 1 addition & 0 deletions src/App.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,4 +264,5 @@ interface GetLyricsResponse {
interface CurrentSongLyrics {
songId: string;
lyrics?: string;
writers?: string[];
}
5 changes: 3 additions & 2 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
import MapView from "./lib/views/MapView.svelte";
import WelcomeView from "./lib/views/WelcomeView.svelte";
import { startMenuListener } from "./window/EventListener";
import 'overlayscrollbars/overlayscrollbars.css';
startMenuListener();
startImportListener();
Expand Down Expand Up @@ -146,7 +147,7 @@
unlistenFolderWatch();
});
$: showCursorInfo = $draggedSongs.length > 0;
$: showCursorInfo = $draggedSongs.length > 0 && mouseX + mouseY > 0;
</script>

<!-- <svelte:body on:click={onPageClick} /> -->
Expand Down
16 changes: 16 additions & 0 deletions src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,19 @@ button:disabled {
font-family: "Snake";
src: url("/fonts/Snake.ttf") format("truetype");
}

@font-face {
font-family: "Lyrics";
src: url("/fonts/PTSerif-Regular.ttf") format("truetype");
}

/* Hide scrollbar for Chrome, Safari and Opera */
.hide-scrollbar::-webkit-scrollbar {
display: none;
}

/* Hide scrollbar for IE, Edge and Firefox */
.hide-scrollbar {
-ms-overflow-style: none; /* IE and Edge */
scrollbar-width: none; /* Firefox */
}
25 changes: 22 additions & 3 deletions src/data/LyricsGrabber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import type { GetLyricsResponse } from "../App";
import { fetch } from "@tauri-apps/api/http";

export async function getLyrics(songTitle: string, artist: string) {
let result = {
lyrics: null,
writers: []
}
let geniusPage;

const settings = get(userSettings);
try {
if (!settings.geniusApiKey) {
Expand All @@ -31,19 +36,33 @@ export async function getLyrics(songTitle: string, artist: string) {
const hits = geniusResult.data?.response?.hits;
if (hits?.filter(h => artist.toLowerCase() === h?.result?.artist_names?.toLowerCase()).length) {
geniusPage = hits[0]?.result?.url;
let songId = hits[0]?.result?.id;

const songResult = await fetch(
`https://api.genius.com/songs/${songId}`,
{
method: "GET",
headers: {
"Accept": "application/json",
"Authorization": `Bearer ${settings.geniusApiKey}`
}
}
);
result.writers = songResult.data?.response?.song?.writer_artists?.map(w => w?.name);

}
console.log("geniusPage", geniusPage);
} catch (err) {
console.error("Error fetching from Genius" + err);
throw new Error("Error: " + err);
}
if (geniusPage) {
const result = await invoke<GetLyricsResponse>("get_lyrics", {
const lyricsResult = await invoke<GetLyricsResponse>("get_lyrics", {
event: {
url: geniusPage
}
});
return result?.lyrics;
result.lyrics = lyricsResult?.lyrics;
}
return null;
return result;
}
12 changes: 0 additions & 12 deletions src/lib/library/Library.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -1187,10 +1187,6 @@
animation-duration: 0.5s;
animation-iteration-count: infinite;
animation-delay: 0s;
-webkit-animation-name: shorteq;
-webkit-animation-duration: 0.5s;
-webkit-animation-iteration-count: infinite;
animation-delay: 0s;
}
.eq2 {
Expand All @@ -1200,10 +1196,6 @@
animation-duration: 0.5s;
animation-iteration-count: infinite;
animation-delay: 0.17s;
-webkit-animation-name: talleq;
-webkit-animation-duration: 0.5s;
-webkit-animation-iteration-count: infinite;
animation-delay: 0.17s;
}
.eq3 {
Expand All @@ -1213,10 +1205,6 @@
animation-duration: 0.5s;
animation-iteration-count: infinite;
animation-delay: 0.34s;
-webkit-animation-name: shorteq;
-webkit-animation-duration: 0.5s;
-webkit-animation-iteration-count: infinite;
animation-delay: 0.34s;
}
}
p {
Expand Down
Loading

0 comments on commit a384d59

Please sign in to comment.