-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathmusicbrainz.js
More file actions
55 lines (49 loc) · 2.1 KB
/
musicbrainz.js
File metadata and controls
55 lines (49 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
(function () {
if (!window.__servarrEngines) window.__servarrEngines = { list: [], helpers: {} };
var Def = window.__servarrEngines.helpers.DefaultEngine;
function getHref(sel, doc) {
// Fall back to just selecting the link if we don't find it with `:has`, for browser support
var a = doc.querySelector(sel) || doc.querySelector(sel.replace(/:has\([^)]+\)/g, ''));
return (a && a.href) || '';
}
var Artist = Def({
id: 'musicbrainz',
key: 'musicbrainz-artist',
urlIncludes: ['musicbrainz.org/artist'],
siteType: 'lidarr',
containerSelector: '.artistheader > h1',
insertWhere: 'prepend',
iconStyle: 'width: 26px; margin: 0 5px -4px 0;',
getSearch: function (_el, doc) {
var href = getHref('.artistheader > h1 a:has(bdi)', doc);
return href ? href.replace('https://musicbrainz.org', '').replace('/artist/', 'lidarr:') : '';
}
});
var ReleaseGroup = Def({
id: 'musicbrainz',
key: 'musicbrainz-release-group',
urlIncludes: ['musicbrainz.org/release-group'],
siteType: 'lidarr',
containerSelector: '.rgheader > h1',
insertWhere: 'prepend',
iconStyle: 'width: 26px; margin: 0 5px -4px 0;',
getSearch: function (_el, doc) {
var href = getHref('.rgheader > h1 a:has(bdi)', doc);
return href ? href.replace('https://musicbrainz.org', '').replace('/release-group/', 'lidarr:') : '';
}
});
var Release = Def({
id: 'musicbrainz',
key: 'musicbrainz-release',
urlIncludes: ['musicbrainz.org/release'],
siteType: 'lidarr',
containerSelector: '.releaseheader > h1',
insertWhere: 'prepend',
iconStyle: 'width: 26px; margin: 0 5px -4px 0;',
getSearch: function (_el, doc) {
var href = getHref('.releaseheader > h1 a:has(bdi)', doc);
return href ? href.replace('https://musicbrainz.org', '').replace('/release/', 'lidarr:') : '';
}
});
window.__servarrEngines.list.push(Artist, ReleaseGroup, Release);
})();