mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
feat: Support disabling scrobbling for non-music content (#1665)
Co-authored-by: JellyBrick <shlee1503@naver.com>
This commit is contained in:
@ -6,6 +6,12 @@ import { backend } from './main';
|
||||
|
||||
export interface ScrobblerPluginConfig {
|
||||
enabled: boolean,
|
||||
/**
|
||||
* Attempt to scrobble other video types (e.g. Podcasts, normal YouTube videos)
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
scrobble_other_media: boolean,
|
||||
scrobblers: {
|
||||
lastfm: {
|
||||
/**
|
||||
@ -64,6 +70,7 @@ export interface ScrobblerPluginConfig {
|
||||
|
||||
export const defaultConfig: ScrobblerPluginConfig = {
|
||||
enabled: false,
|
||||
scrobble_other_media: true,
|
||||
scrobblers: {
|
||||
lastfm: {
|
||||
enabled: false,
|
||||
|
||||
@ -51,6 +51,11 @@ export const backend = createBackend<{
|
||||
clearTimeout(scrobbleTimer);
|
||||
if (!songInfo.isPaused) {
|
||||
const configNonnull = this.config!;
|
||||
// Scrobblers normally have no trouble working with official music videos
|
||||
if (!configNonnull.scrobble_other_media && (songInfo.mediaType !== 'AUDIO' && songInfo.mediaType !== 'ORIGINAL_MUSIC_VIDEO')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Scrobble when the song is halfway through, or has passed the 4-minute mark
|
||||
const scrobbleTime = Math.min(Math.ceil(songInfo.songDuration / 2), 4 * 60);
|
||||
if (scrobbleTime > (songInfo.elapsedSeconds ?? 0)) {
|
||||
|
||||
@ -79,6 +79,15 @@ export const onMenu = async ({
|
||||
const config = await getConfig();
|
||||
|
||||
return [
|
||||
{
|
||||
label: t('plugins.scrobbler.menu.scrobble-other-media'),
|
||||
type: 'checkbox',
|
||||
checked: Boolean(config.scrobble_other_media),
|
||||
click(item) {
|
||||
config.scrobble_other_media = item.checked;
|
||||
setConfig(config);
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Last.fm',
|
||||
submenu: [
|
||||
|
||||
Reference in New Issue
Block a user