Skip to content

Commit

Permalink
domains: better support for Apple Music
Browse files Browse the repository at this point in the history
  • Loading branch information
iparamonau committed Nov 1, 2016
1 parent af9a8b1 commit 81052c0
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
2 changes: 1 addition & 1 deletion plugins/domains/beatport.com.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = {
return [{
href: "//embed.beatport.com/player/?id=" + urlMatch[2] + "&type=" + urlMatch[1],
type: CONFIG.T.text_html,
rel: CONFIG.R.player,
rel: [CONFIG.R.player, CONFIG.R.html5],
height: og.video && og.video.height || 162,
'min-width': og.video && og.video.width || 398
}, {
Expand Down
39 changes: 39 additions & 0 deletions plugins/domains/itunes.apple.com/apple.music.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module.exports = {

re: [
/^https?:\/\/(?:geo\.)?itunes\.apple\.com\/(\w{2})\/(album)(?:\/[^\/]+)?\/id(\d+)\?i=(\d+)?/i,
/^https?:\/\/(?:geo\.)?itunes\.apple\.com\/(\w{2})\/(album|playlist)(?:\/[^\/]+)?\/id(?:pl\.)?(\d+)/i
],

mixins: [
"*"
],

getLink: function(urlMatch) {

var country = urlMatch[1];
var type = urlMatch[2];
var id = urlMatch[4] || urlMatch[3];

if (urlMatch[4]) {
type = 'song';
}

return {
href: '//tools.applemusic.com/embed/v1/' + type + '/' + (type === 'playlist' ? '/pl.':'/' ) + id + '?country=' + country,
type: CONFIG.T.text_html,
rel: [CONFIG.R.html5, CONFIG.R.player],
"height": type === 'playlist' || type === 'album' ? 500 : 110
};
},

tests: [
'https://itunes.apple.com/us/album/12-12-12-concert-for-sandy/id585701590?v0=WWW-NAUS-ITSTOP100-ALBUMS&ign-mpt=uo%3D4',
'https://itunes.apple.com/us/album/id944094900?i&ls=1',
'https://geo.itunes.apple.com/us/album/trap-or-die-3/id1163301872?app=music',
'https://geo.itunes.apple.com/us/album/fake-love/id1168503200?i=1168503281&mt=1&app=music',
'https://itunes.apple.com/ca/album/greatest-feat.-kendrick-lamar/id1149503804?i=1149503816&app=music&ign-mpt=uo%3D4',
'https://itunes.apple.com/us/playlist/the-a-list-country/idpl.87bb5b36a9bd49db8c975607452bfa2b?app=music',
'https://geo.itunes.apple.com/uk/album/cozy-tapes-vol.-1-friends/id1169558406?app=music&at=1010lpzb'
]
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {

re: [
/^https?:\/\/itunes\.apple\.com(?:\/)?(\w+)?\/(album|app|movie|tv-season)(?:\/[^\/]+)?\/id(\d+)/i
/^https?:\/\/itunes\.apple\.com(?:\/)?(\w+)?\/(app|movie|tv-season)(?:\/[^\/]+)?\/id(\d+)/i
],

mixins: [
Expand All @@ -19,7 +19,6 @@ module.exports = {
getLink: function(urlMatch, options) {

var content = {
'album': 'album',
'app': 'software',
'movie': 'movie',
'tv-season': 'tvSeason'
Expand Down Expand Up @@ -50,7 +49,6 @@ module.exports = {
},

tests: [
'https://itunes.apple.com/us/album/12-12-12-concert-for-sandy/id585701590?v0=WWW-NAUS-ITSTOP100-ALBUMS&ign-mpt=uo%3D4',

// Not supported.
//'https://itunes.apple.com/us/music-video/gangnam-style/id564322420?v0=WWW-NAUS-ITSTOP100-MUSICVIDEOS&ign-mpt=uo%3D4',
Expand Down

0 comments on commit 81052c0

Please sign in to comment.