-
-
Notifications
You must be signed in to change notification settings - Fork 538
Connector API changes
Connector.scrobbleInfoStyle
is now an object containing various different selectors and their styles.
For convenience, it is now also a setter that only overrides conflicting styles, keeping default styles for anything else.
Replaced Connector.isScrobblingAllowed
with Connector.scrobblingDisallowedReason
.
-
Connector.isScrobblingAllowed
used to return true when scrobbling allowed, and false when not. -
Connector.scrobblingDisallowedReason
returns a string with reason for not allowing when disallowing, and null when allowing scrobble. - By default, always returns null (allowing the scrobble)
Added Connector.isLoved
which says whether a song is liked/loved on the website the user is scrobbling from. Depending on settings, liking/unliking may also love/unlove in scrobbling service.
Added Connector.loveButtonSelector
helper for Connector.isLoved
that points to an element that serves as a like/love button, indicating Connector.isLoved
is false
.
Added Connector.unloveButtonSelector
helper for Connector.isLoved
that points to an element that serves as a unlike/unlove button, indicating Connector.isLoved
is true
.
Added Util.fetchFromServiceWorker
function that allows connectors to fetch from service worker, bypassing things like CORS restrictions and adblockers.
Added Connector.getChannelId
which gives a unique channel ID the user can block from scrobbling.
Added Connector.getChannelLabel
which gives channel label for the channel ID.
Added Connector.channelLabelSelector
helper which points to an element which has the label as its innerText.
Added Connector.getChannelInfo
which gets both channelId and channelLabel. By default, this just uses getChannelLabel and getChannelId.
Added info box that is injected to DOM showing what's scrobbling
Added Connector.scrobbleInfoLocationSelector
which determines where the info box is injected. If none is specified, info box is not injected.
Added Connector.scrobbleInfoStyle
which determines the styling that is applied to the info box wrapper.
Moved to a new and stricter ESLint configuration.
Added Util.getInfoBoxText
, which is for internal use.
Added [] to the list of japanese brackets for youtube parsing and made the check lazy.
Added Music Video to the list of ways to write MV/PV on japanese music videos.
Util.debugLog
now only logs when an option is enabled by the user. As a result, Util.debugLog
is no longer instant, and instead the function adds the log to a queue, that then checks a Promise before printing.
Fixed Util.throttle
.
Fixed edge case in Util.extractImageUrlFromSelectors
.
Removed jQuery.
Moved connectors and connector API to TypeScript.
Upgraded @web-scrobbler/metadata-filter to version 3.0.1.
Util.normalizeUrl
now supports root-relative URLs.
Added Util.getOriginUrl
which gets origin URL from a DOM element, falling back to window location if it fails.
Added Util.removeRecordSide
which removes leading track numbers.
Fixed Util.getAttrFromSelectors
to handle nulls.
Fixed rules to not remove MV/PV from youtube titles if they are part of a word.
Fixed Util.parseYtVideoDescription
.
Added 『』 and 「」 to parsing of Japanese youtube titles.
Added rule to remove hyphens preceding brackets in Japanese youtube titles.
Added rules to remove MV/PV, and 東方/オリジナル from youtube titles.
Added 【】 to parsing of Japanese youtube titles only if no other brackets match.
Added tilde ~
to the list of separators.
Updated metadata-filter to version 1.1.0.
Added en dash –
and em dash —
to the list of separators.
Updated Util.stringToSeconds
to be more robust. Most notably, input no longer has to be trimmed for the function to work.
Added a new filter to Util.processYtVideoTitle
that removes CD/Vinyl track numbers from titles.
Added a new util function Util.isElementVisible
which checks if an element matching a given selector is visible.
Added a Util.splitArtistAlbum
function which splits an "Artist - Album" string to an object containing artist and album names.
jQuery usage is deprecated. The jQuery dependency will be removed in a next major version.
Added support for MediaSession API. This support can be enabled by calling Connector.useMediaSessionApi
function.
Added new util functions:
-
Util.getAttrFromSelectors
which returns an attribute value of an element matching a given selector. -
Util.hasElementClass
which checks if an element matching a given selector has a given class.
These functions are supposed to be used in new connectors. New connectors should also use DOM API instead of jQuery.
Added a new Util.getSecondsFromSelectors
function to extract seconds from an element matching a given selector.
Added a new function to check if a current track is a podcast:
Connector.isPodcast = () => {
// ...
};
The core has a new (optional) feature to skip podcasts, and it's uses the value returned by this function to detect if a track is podcast actually.
Default implementation of the function returns false
; override this function for more complex behavior only.
If you implement a connector for a website contains podcasts only, make sure to return true
always:
Connector.isPodcast = () => true;
Added the Connector.getTrackInfo
function. This function is useful in cases when a track info is placed in a single source; so you can return the track info by accessing this source once:
// Called first
Connector.getTrack = () => {
return ...;
};
// Called after the `Connector.getTrack` function.
Connector.getTrackInfo = () => {
const [artist, album] = getArtistAlbum();
return { artist, album };
};
// All three properties will be applied.
Removed Util.makeEmptyArtistTrack
function. The result of this function was used as a fallback value in the overriden Connector.getArtistTrack
functions. Now you can freely return null
in the Connector.getArtistTrack
function and similar ones.
Added the id
property for supported websites. Read below how to assign IDs for new connectors.
Added the Util.extractImageUrlFromSelectors
function to get image URL from elements.
Added the Util.processSoundCloudTrack
function to process track names for SoundCloud-based websites.
Remaining time is now used to calculate song duration if it's missing.
Improved Connector API to allow developers to write new connectors much easier:
- Added support for arrays of selectors. Now you can define multiple selectors:
// The text of first non-empty element will be used.
Connector.artistSelector = [".artist", '[data="artist"]'];
- Added support for pause button selector:
// If the element matches `.pause-icon` selector is visible,
// the connnector sets playing state to paused.
Connector.pauseButtonSelector = ".pause-icon";
- Added support for albumArtist property:
Connector.albumArtistSelector = '.albumArtist';
// or
Connector.getAlbumArtist = () => {
return $('[data="albumArtist"]).attr('content');
};
- Updated behaviour of default getters. Previously, if some selector is defined, and the respective getter wasn't overriden, the getter returned the text of all elements matched the selector. Now the getter returns the text of first non-empty element matched by the selector:
<!-- Website code -->
<div class="player">
<span class="artist">Artist name</span>
</div>
<div class="miniplayer">
<span class="artist">Artist name</span>
</div>
// Connector code
Connector.artistSelector = ".artist";
// Previous behaviour: artist is "ArtistArtist"
// Current behaviour: artist is "Artist"
All getters use Util.getTextFromSelectors
function by default. Feel free to use this function in your connectors.
Reorganized usage of metadata filters:
- The
Connector.filter
property is now for internal use; - The
Connector.applyFilter
function should be called to apply your own filters.
Changed configuring of custom metadata filters:
- Use the
Connector.applyFilter
function to apply your own metadata filter; - Use the
Connector.filter
property to apply YouTube or Remastered filter; - Use the
MetadataFilter.extend
function to merge two metadata filters.
Extended Connector API. Added two new functions:
-
Connector.injectScript
, which allows to inject a custom script into a page and setup event listener. -
Connector.onScriptEvent
, which is called when the custom script sends an event. This function is supposed to be overriden.
Added a Connector.onReady
function. This function is called when a conector is injected and is ready to listen website changes.
Added a Connector.isTrackArtDefault
function.
Renamed the Connector.trackArtImageSelector
property to Connector.trackArtSelector
.
Added a Connector.isScrobblingAllowed
function. This function is similar to the Connector.isStateChangeAllowed
one,
but it also resets the connector state to prevent scrobbling a now playng song.
Removed underscore
dependency.
Added an ability to define time info. This could be useful for websites which provide time info in a single element.
This is possible by using a Connector.getTimeInfo
function and a Connector.timeInfoSelector
property.
Allowed connectors to reset the connector state via a Connector.resetState
function.
Moved all helper functions to a new Util
module.
Added initial support for custom metadata filters. You can create a new filter using MetadataFilter
constructor.
Added a Connector.filter
property to apply custom filters.
Added a Connector.splitArtistTrack
function to split a given string to an ArtistTrack object.
Added a Connector.isStateChangeAllowed
function to ignore certain connector states.
Added support for track arts via a Connector.trackArtImageSelector
property or a Connector.getTrackArt
function.
Added initial support for v2 connectors via a Connector
object.