mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-15 04:11:47 +00:00
Made the suffixes configurable and added VEVO suffix to remove
This commit is contained in:
@ -40,6 +40,7 @@ const defaultConfig = {
|
|||||||
api_root: "http://ws.audioscrobbler.com/2.0/",
|
api_root: "http://ws.audioscrobbler.com/2.0/",
|
||||||
api_key: "04d76faaac8726e60988e14c105d421a", // api key registered by @semvis123
|
api_key: "04d76faaac8726e60988e14c105d421a", // api key registered by @semvis123
|
||||||
secret: "a5d2a36fdf64819290f6982481eaffa2",
|
secret: "a5d2a36fdf64819290f6982481eaffa2",
|
||||||
|
suffixesToRemove: [' - Topic', 'VEVO'] // removes suffixes of the artist name, for better recognition
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@ -10,6 +10,20 @@ const defaultSettings = {
|
|||||||
api_root: "http://ws.audioscrobbler.com/2.0/",
|
api_root: "http://ws.audioscrobbler.com/2.0/",
|
||||||
api_key: "04d76faaac8726e60988e14c105d421a", // api key registered by @semvis123
|
api_key: "04d76faaac8726e60988e14c105d421a", // api key registered by @semvis123
|
||||||
secret: "a5d2a36fdf64819290f6982481eaffa2",
|
secret: "a5d2a36fdf64819290f6982481eaffa2",
|
||||||
|
suffixesToRemove: [' - Topic', 'VEVO']
|
||||||
|
}
|
||||||
|
|
||||||
|
const cleanupArtistName = (config, artist) => {
|
||||||
|
let { suffixesToRemove } = config;
|
||||||
|
if (suffixesToRemove === undefined){
|
||||||
|
suffixesToRemove = defaultSettings.suffixesToRemove;
|
||||||
|
config.suffixesToRemove = suffixesToRemove;
|
||||||
|
setOptions('last-fm', config);
|
||||||
|
}
|
||||||
|
for (suffix of suffixesToRemove){
|
||||||
|
artist = artist.replace(suffix,'');
|
||||||
|
}
|
||||||
|
return artist
|
||||||
}
|
}
|
||||||
|
|
||||||
const createFormData = (params) => {
|
const createFormData = (params) => {
|
||||||
@ -94,7 +108,7 @@ const addScrobble = async (songInfo, config) => {
|
|||||||
await getAndSetSessionKey(config);
|
await getAndSetSessionKey(config);
|
||||||
data = {
|
data = {
|
||||||
track: songInfo.title,
|
track: songInfo.title,
|
||||||
artist: songInfo.artist?.replace(' - Topic', ''),
|
artist: songInfo.artist,
|
||||||
api_key: config.api_key,
|
api_key: config.api_key,
|
||||||
sk: config.session_key,
|
sk: config.session_key,
|
||||||
format: 'json',
|
format: 'json',
|
||||||
@ -120,7 +134,7 @@ const setNowPlaying = async (songInfo, config) => {
|
|||||||
await getAndSetSessionKey(config);
|
await getAndSetSessionKey(config);
|
||||||
data = {
|
data = {
|
||||||
track: songInfo.title,
|
track: songInfo.title,
|
||||||
artist: songInfo.artist?.replace(' - Topic', ''),
|
artist: songInfo.artist,
|
||||||
api_key: config.api_key,
|
api_key: config.api_key,
|
||||||
sk: config.session_key,
|
sk: config.session_key,
|
||||||
format: 'json',
|
format: 'json',
|
||||||
@ -159,6 +173,7 @@ const lastfm = async (win, config) => {
|
|||||||
|
|
||||||
registerCallback( songInfo => {
|
registerCallback( songInfo => {
|
||||||
clearTimeout(scrobbleTimer);
|
clearTimeout(scrobbleTimer);
|
||||||
|
songInfo.artist = cleanupArtistName(config, songInfo.artist);
|
||||||
if (!songInfo.isPaused) {
|
if (!songInfo.isPaused) {
|
||||||
setNowPlaying(songInfo, config);
|
setNowPlaying(songInfo, config);
|
||||||
let scrobbleTime = Math.min(Math.ceil(songInfo.songDuration/2), 4*60);
|
let scrobbleTime = Math.min(Math.ceil(songInfo.songDuration/2), 4*60);
|
||||||
|
|||||||
Reference in New Issue
Block a user