diff --git a/package.json b/package.json index 3e667818..8babdc04 100644 --- a/package.json +++ b/package.json @@ -65,12 +65,12 @@ "dependencies": { "@cliqz/adblocker-electron": "^1.22.0", "@ffmpeg/core": "^0.10.0", - "@ffmpeg/ffmpeg": "^0.9.8", + "@ffmpeg/ffmpeg": "^0.10.0", "YoutubeNonStop": "git://github.com/lawfx/YoutubeNonStop.git#v0.9.0", "async-mutex": "^0.3.1", "browser-id3-writer": "^4.4.0", "chokidar": "^3.5.1", - "custom-electron-titlebar": "^3.2.6", + "custom-electron-titlebar": "^3.2.7", "discord-rpc": "^3.2.0", "electron-debug": "^3.2.0", "electron-is": "^3.0.0", diff --git a/plugins/downloader/back.js b/plugins/downloader/back.js index ee345ab2..060245ed 100644 --- a/plugins/downloader/back.js +++ b/plugins/downloader/back.js @@ -55,7 +55,9 @@ function handle(win) { { ...nowPlayingMetadata, ...currentMetadata }; try { - const coverBuffer = songMetadata.image ? songMetadata.image.toPNG() : null; + const coverBuffer = songMetadata.image && !songMetadata.image.isEmpty() ? + songMetadata.image.toPNG() : null; + const writer = new ID3Writer(songBuffer); // Create the metadata tags diff --git a/providers/song-info.js b/providers/song-info.js index 1b119b82..08eaf944 100644 --- a/providers/song-info.js +++ b/providers/song-info.js @@ -9,18 +9,21 @@ const progressSelector = "#progress-bar"; // Grab the progress using the selector const getProgress = async (win) => { // Get current value of the progressbar element - const elapsedSeconds = await win.webContents.executeJavaScript( + return win.webContents.executeJavaScript( 'document.querySelector("' + progressSelector + '").value' ); - - return elapsedSeconds; }; // Grab the native image using the src const getImage = async (src) => { const result = await fetch(src); const buffer = await result.buffer(); - return nativeImage.createFromBuffer(buffer); + const output = nativeImage.createFromBuffer(buffer); + if (output.isEmpty() && !src.endsWith(".jpg") && src.includes(".jpg")) { // fix hidden webp files (https://github.com/th-ch/youtube-music/issues/315) + return getImage(src.slice(0, src.lastIndexOf(".jpg")+4)); + } else { + return output; + } }; // To find the paused status, we check if the title contains `-` @@ -30,7 +33,7 @@ const getPausedStatus = async (win) => { }; const getArtist = async (win) => { - return await win.webContents.executeJavaScript(` + return win.webContents.executeJavaScript(` document.querySelector(".subtitle.ytmusic-player-bar .yt-formatted-string") ?.textContent `); @@ -112,4 +115,3 @@ module.exports = registerCallback; module.exports.setupSongInfo = registerProvider; module.exports.getImage = getImage; module.exports.cleanupArtistName = cleanupArtistName; - diff --git a/yarn.lock b/yarn.lock index 36652636..9d05c2eb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -549,10 +549,10 @@ resolved "https://registry.yarnpkg.com/@ffmpeg/core/-/core-0.10.0.tgz#f6a58361b22d7c23c6f7071b9fff6d572bc3f499" integrity sha512-qunWJl5PezpXEm31tb8Qu5z37B5KVA1VYZCpXchMhuAb3X9T7PuE3SlhOwphEoRhzaOa3lpofDfzihAUMFaVPQ== -"@ffmpeg/ffmpeg@^0.9.8": - version "0.9.8" - resolved "https://registry.yarnpkg.com/@ffmpeg/ffmpeg/-/ffmpeg-0.9.8.tgz#d0292ac1e31f6a070b35e18e50dbbd79f2e2bb08" - integrity sha512-QradleJx78hHJBtI1wRsus1L1jxQB3v4h6k8c3CERI9fssm+NSSppuofmsOei7uq7iQEYq3oK9tJNAyEsRoNng== +"@ffmpeg/ffmpeg@^0.10.0": + version "0.10.0" + resolved "https://registry.yarnpkg.com/@ffmpeg/ffmpeg/-/ffmpeg-0.10.0.tgz#0bebd944d50ce11297b91883f94b2f6220b74e34" + integrity sha512-W+d0ysYTO6d4vue/0KMYrxaprh9wvmnPqh6qyHXavBWLrDcE7gI3cJ/EQVfwe9nrt2e0Pi7873P2I18VEDgRfA== dependencies: is-url "^1.2.4" node-fetch "^2.6.1" @@ -2882,10 +2882,10 @@ cssstyle@^2.2.0: dependencies: cssom "~0.3.6" -custom-electron-titlebar@^3.2.6: - version "3.2.6" - resolved "https://registry.yarnpkg.com/custom-electron-titlebar/-/custom-electron-titlebar-3.2.6.tgz#4cd064efa5020954c09732efa8c667a7ee3636e3" - integrity sha512-P3ZGEr0eouUHqhdBBXllpuy2bFhfSmp+32HQBPcwzujjIsUhQxQj/nCpJiFa4SUGAEp1ifu/icuZdDKNNX72Tw== +custom-electron-titlebar@^3.2.7: + version "3.2.7" + resolved "https://registry.yarnpkg.com/custom-electron-titlebar/-/custom-electron-titlebar-3.2.7.tgz#fb249d6180cbda074b1d392bea755fa0743012a8" + integrity sha512-KO/6e3r6YflfNUOzi5QHLwkLHBP+ICtHPo70u/kUIKR8UUkDTPb4a9i19q0uDZQcjkH6oqRvFCz9wEHeEpCgxw== dashdash@^1.12.0: version "1.14.1"