Skip to content

Commit

Permalink
Do not display progress/success logs for local I/O
Browse files Browse the repository at this point in the history
It is super fast and just muddies the log.
  • Loading branch information
TomasHubelbauer committed Jun 3, 2024
1 parent aef847d commit 799ccb4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
13 changes: 5 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ electron.app.on('ready', async () => {
// Get rid of the lingering shadows/opacity (for the most part) - see the readme
window.reload();
await window.webContents.executeJavaScript(`document.querySelector('#lyricText').textContent = '~ ${text}';`);
console.log(`Flashed unsynchronized lyric "${line?.words}"`);
console.log(line?.words ? `Flashed unsynchronized lyric "${line?.words}"` : 'Cleared unsynchronized lyric');
}

position += .1;
Expand All @@ -84,7 +84,7 @@ electron.app.on('ready', async () => {
// Get rid of the lingering shadows/opacity (for the most part) - see the readme
window.reload();
await window.webContents.executeJavaScript(`document.querySelector('#lyricText').textContent = '${text}';`);
console.log(`Flashed synchronized lyric "${line?.words}"`);
console.log(line?.words ? `Flashed synchronized lyric "${line?.words}"` : 'Cleared synchronized lyric');
}

position += .1;
Expand Down Expand Up @@ -131,14 +131,11 @@ electron.app.on('ready', async () => {
const path = `lyrics/${artist} - ${song}.json`;
try {
await fs.promises.access(path);

console.log(`Loading lyrics for ${artist} - ${song}…`);
lyrics = JSON.parse(await fs.promises.readFile(path));
console.log(`Loaded lyrics for ${artist} - ${song}`);
}
catch (error) {
if (error.code !== 'ENOENT') {
console.log(`Failed to load lyrics for ${artist} - ${song}: ${error}`);
console.log(`Failed to load ${artist} - ${song}: ${error}`);
}

/** @type {string} */
Expand All @@ -152,7 +149,7 @@ electron.app.on('ready', async () => {
continue;
}

console.log(`Downloading lyrics for ${artist} - ${song} (${id})…`);
console.log(`Downloading ${artist} - ${song}…`);

// Download LRC (timestamped) lyrics from the unofficial Spotify Lyrics API
// Inspect the `open.spotify.com` developer tools `lyrics` network call to maintain this
Expand All @@ -163,7 +160,7 @@ electron.app.on('ready', async () => {
lyrics = { artist, song, ...data.lyrics };
await fs.promises.writeFile(path, JSON.stringify(lyrics, null, 2));

console.log(`Downloaded lyrics for ${artist} - ${song} (${id})`);
console.log(`Downloaded ${artist} - ${song}`);
}
else {
lyrics = { artist, song, error: response.status + ' ' + response.statusText };
Expand Down
3 changes: 0 additions & 3 deletions promptAuthorization.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ export default async function promptAuthorization(force = false) {

try {
await fs.promises.access(path);

console.log('Loading bearer token…');
authorization = JSON.parse(await fs.promises.readFile(path));
console.log('Loaded bearer token');
}
catch (error) {
if (error.code !== 'ENOENT') {
Expand Down

0 comments on commit 799ccb4

Please sign in to comment.