From 631dd4c64586c3a3c5c8a964ccb9ede666755571 Mon Sep 17 00:00:00 2001 From: alexesprit Date: Wed, 11 Dec 2019 21:47:12 +0300 Subject: [PATCH] Fix spotify connector Add more ad URLs to skip. Ref https://github.com/web-scrobbler/web-scrobbler/issues/1599#issuecomment-564667965. --- src/connectors/spotify.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/connectors/spotify.js b/src/connectors/spotify.js index c1b13e2aae..038c8e72f8 100644 --- a/src/connectors/spotify.js +++ b/src/connectors/spotify.js @@ -1,5 +1,12 @@ 'use strict'; +const adUrls = [ + 'utm_source=display', + 'ad.doubleclick.net', + 'spotify:playlist', + 'shrt.spotify.com' +]; + Connector.playerSelector = '.Root__now-playing-bar'; Connector.artistSelector = '.track-info__artists a'; @@ -20,15 +27,14 @@ Connector.isScrobblingAllowed = () => !isAdPlaying(); Connector.isPodcast = () => artistUrlIncludes('/show/'); -/* - * When ad is playing, artist URL is like "https://shrt.spotify.com/XXX", - * otherwise URL leads to: - * a) an artist page https://open.spotify.com/artist/YYY; - * b) a podcast page https://open.spotify.com/show/ZZZ. - */ - function isAdPlaying() { - return artistUrlIncludes('shrt.spotify.com'); + for (const adUrl of adUrls) { + if (artistUrlIncludes(adUrl)) { + return true; + } + } + + return false; } function artistUrlIncludes(str) {