mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
Merge pull request #252 from Araxeus/fix-download-idtag-if-not-playing
Fix downloader metadata if not currently playing
This commit is contained in:
@ -38,7 +38,7 @@ const getArtist = async (win) => {
|
||||
artistName.textContent;
|
||||
}
|
||||
`
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Fill songInfo with empty values
|
||||
@ -57,8 +57,8 @@ const songInfo = {
|
||||
|
||||
const handleData = async (responseText, win) => {
|
||||
let data = JSON.parse(responseText);
|
||||
songInfo.title = data?.videoDetails?.title;
|
||||
songInfo.artist = await getArtist(win) || data?.videoDetails?.author;
|
||||
songInfo.title = data.videoDetails?.media?.song || data?.videoDetails?.title;
|
||||
songInfo.artist = data.videoDetails?.media?.artist || await getArtist(win) || cleanupArtistName(data?.videoDetails?.author);
|
||||
songInfo.views = data?.videoDetails?.viewCount;
|
||||
songInfo.imageSrc = data?.videoDetails?.thumbnail?.thumbnails?.pop()?.url;
|
||||
songInfo.songDuration = data?.videoDetails?.lengthSeconds;
|
||||
@ -102,5 +102,20 @@ const registerProvider = (win) => {
|
||||
return registerCallback;
|
||||
};
|
||||
|
||||
const suffixesToRemove = [' - Topic', 'VEVO'];
|
||||
function cleanupArtistName(artist) {
|
||||
if (!artist) {
|
||||
return artist;
|
||||
}
|
||||
for (const suffix of suffixesToRemove) {
|
||||
if (artist.endsWith(suffix)) {
|
||||
return artist.slice(0, -suffix.length);
|
||||
}
|
||||
}
|
||||
return artist;
|
||||
}
|
||||
|
||||
module.exports = registerProvider;
|
||||
module.exports.getImage = getImage;
|
||||
module.exports.cleanupArtistName = cleanupArtistName;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user