diff --git a/plugins/multi-scrobbler/src/services/BaseService.ts b/plugins/multi-scrobbler/src/services/BaseService.ts index da49b80..0f42698 100644 --- a/plugins/multi-scrobbler/src/services/BaseService.ts +++ b/plugins/multi-scrobbler/src/services/BaseService.ts @@ -2,6 +2,17 @@ import { ServiceClient, Track } from "../../../defs"; import Constants from "../constants"; import { incrementApiCall, recordServiceError } from "../utils/debug"; +const USER_AGENTS = [ + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36", + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36", + "Mozilla/5.0 (Macintosh; Intel Mac OS X 14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36", + "Mozilla/5.0 (Macintosh; Intel Mac OS X 14_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Safari/605.1.15", + "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:127.0) Gecko/20100101 Firefox/127.0", + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36", + "Mozilla/5.0 (X11; Linux x86_64; rv:127.0) Gecko/20100101 Firefox/127.0", + "Mozilla/5.0 (iPhone; CPU iPhone OS 17_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Mobile/15E148 Safari/604.1", +]; + export abstract class BaseService implements ServiceClient { protected retryCount = 0; protected lastError = 0; @@ -54,7 +65,7 @@ export abstract class BaseService implements ServiceClient { const response = await fetch(url, { ...options, headers: { - "User-Agent": "Vendetta Multi-Service Scrobbler/3.0.0", + "User-Agent": USER_AGENTS[Math.floor(Math.random() * USER_AGENTS.length)], ...options.headers, }, }); diff --git a/plugins/multi-scrobbler/src/services/ListenBrainzService.ts b/plugins/multi-scrobbler/src/services/ListenBrainzService.ts index b78ab2d..abbfe36 100644 --- a/plugins/multi-scrobbler/src/services/ListenBrainzService.ts +++ b/plugins/multi-scrobbler/src/services/ListenBrainzService.ts @@ -3,11 +3,6 @@ import { currentSettings } from ".."; import Constants from "../constants"; import { BaseService } from "./BaseService"; -interface ListenBrainzResponse { - listens?: ListenBrainzListen[]; - error?: string; -} - interface ListenBrainzListen { listened_at: number; track_metadata: { @@ -32,10 +27,6 @@ interface ListenBrainzListen { playing_now?: boolean; } -interface ListenBrainzPlayingNowResponse { - listens: ListenBrainzListen[]; -} - export class ListenBrainzService extends BaseService { getServiceName(): string { return "ListenBrainz"; @@ -179,15 +170,10 @@ export class ListenBrainzService extends BaseService { } } - // Try to get album art from MusicBrainz or other sources - const albumArt: string | null = null; + // Try to get album art from Cover Art Archive + let albumArt: string | null = null; if (latestListen.track_metadata.additional_info?.release_mbid) { - try { - // We could fetch cover art from Cover Art Archive, but for now we'll leave it null - // albumArt = `https://coverartarchive.org/release/${latestListen.track_metadata.additional_info.release_mbid}/front`; - } catch (error) { - this.logVerbose("Failed to fetch album art:", error); - } + albumArt = `https://coverartarchive.org/release/${latestListen.track_metadata.additional_info.release_mbid}/front`; } const track: Track = {