Skip to content

Commit

Permalink
Add Yggdrasil Radio support (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wykks committed Aug 29, 2015
1 parent 4ba4ac1 commit b4032c8
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Supported Sites
* [themusicninja.com](themusicninja.com)
* [tunein.com](http://tunein.com)
* [vk.com](http://vk.com)
* [yggdrasilradio.net](http://yggdrasilradio.net)
* [youtube.com](http://youtube.com)
* [youtube.com/tv](http://youtube.com/tv)
* [zaycev.fm](http://zaycev.fm)
Expand Down
8 changes: 8 additions & 0 deletions data/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,14 @@ <h1 data-l10n-id="nav_sites"></h1>
<td><img alt="No" src="ico/cross.png"></td>
<td><img alt="No" src="ico/cross.png"></td>
</tr>
<tr>
<td><a target="_blank" href="http://yggdrasilradio.net">yggdrasilradio.net</a></td>
<td><img alt="Yes" src="ico/tick.png"></td>
<td><img alt="Yes" src="ico/tick.png"></td>
<td><img alt="Yes" src="ico/tick.png"></td>
<td><img alt="Yes" src="ico/tick.png"></td>
<td><img alt="Yes" src="ico/tick.png"></td>
</tr>
<tr>
<td><a target="_blank" href="http://youtube.com">youtube.com</a></td>
<td><img alt="Possibly" src="ico/magnifier.png"></td>
Expand Down
34 changes: 34 additions & 0 deletions data/websites-support/websites/yggdrasilradio.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
var YggdrasilRadioTrackListener = function() { };
YggdrasilRadioTrackListener.prototype = new Common.WebsiteTrackListener();

YggdrasilRadioTrackListener.prototype.isPlaying = function() {
return true;
};

YggdrasilRadioTrackListener.prototype.findSelector = function() {
this.selector = undefined;
};

YggdrasilRadioTrackListener.prototype.scrapPlayData = function() {
this.artistName = $('#currartist').text();
this.trackName = $('#currtitle').text();
return true;
};

YggdrasilRadioTrackListener.prototype.scrapAlbumName = function() {
return $('#curranime').text(); //Not really the album name (anime name), but still usefull
};

YggdrasilRadioTrackListener.prototype.scrapAlbumArt = function() {
if ($('#art > a').length) {
return 'http://yggdrasilradio.net' + $('#art > a').attr('href');
} else {
return "";
}
};

YggdrasilRadioTrackListener.prototype.scrapDuration = function() {
return $('#currduration').text();
};

Common.runTrackListenerInterval(new YggdrasilRadioTrackListener());
7 changes: 4 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pageMod.PageMod(
{
ss.storage[message.key] = message.value;
});

worker.port.on("writeFile", function(message)
{
nowPlayingIO.writeFile(message.filename, message.text).then(function()
Expand All @@ -55,7 +55,7 @@ pageMod.PageMod(
{
nowPlayingIO.removeFile(filename);
});

worker.port.on("localization", function(key)
{
worker.port.emit('l10n'+key, _(key));
Expand All @@ -82,7 +82,7 @@ function createMusicWebsiteWorker(includes, script, attachTo)
onAttach: onAttachNowPlaying
};
if (typeof attachTo !== 'undefined')
param.attachTo = attachTo;
param.attachTo = attachTo;
pageMod.PageMod(param);
}

Expand Down Expand Up @@ -132,6 +132,7 @@ createMusicWebsiteWorker(/.*synchtu.be\/r\/Playhouse.*/, "synchtube.js", "top");
createMusicWebsiteWorker("*.themusicninja.com", "themusicninja.js", "top");
createMusicWebsiteWorker("*.tunein.com", "tunein.js", "top");
createMusicWebsiteWorker("*.vk.com", "vk.js", "top");
createMusicWebsiteWorker(/.*yggdrasilradio.net\/nowplaying.php/, "yggdrasilradio.js", "frame");
createMusicWebsiteWorker("*.youtube.com", "youtube.js", "top");
createMusicWebsiteWorker("*.zaycev.fm", "zaycev.js", "top");
// Chinese sites
Expand Down

0 comments on commit b4032c8

Please sign in to comment.