Skip to content

Instantly share code, notes, and snippets.

@iolate
Created January 6, 2017 18:25
Show Gist options
  • Save iolate/d6af2f076fa8674c366077215477b26e to your computer and use it in GitHub Desktop.
Save iolate/d6af2f076fa8674c366077215477b26e to your computer and use it in GitHub Desktop.
BeardedSpice MediaStrategy for Soribada
//
// Soribada.js
// BeardedSpice
//
// Created by iolate <[email protected]> on 2016. 12. 28..
// Copyright © 2016 GPL v3 http://www.gnu.org/licenses/gpl.html
//
// http://www.soribada.com/
//
BSStrategy = {
version: 1,
displayName: "Soribada",
accepts: {
method: "predicateOnTab",
format: "%K LIKE[c] '*www.soribada.com*'",
args: ["URL"]
},
isPlaying: function () { return !S.app.player.player.getIsPaused(); },
toggle: function () { document.querySelector('#play').click(); },
previous: function () { document.querySelector('#prev').click(); },
next: function () { document.querySelector('#next').click(); },
pause: function () { S.app.player.player.pause(); },
favorite: function () { document.querySelector('#favorite').click(); },
trackInfo: function () {
var song = S.app.player.model.attributes.songs[S.app.player.model.attributes.position];
return {
'track': song.attributes['Name'],
'album': song.attributes["Album"].Name,
'artist': song.attributes['Artists'].Artist.map(function(a) {return a.Name;}).join(', '),
'image': S.app.player.model.attributes['cover'],
'favorited': song.attributes['favorite'],
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment