Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for pakartot.lt #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions connectors/pakartot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* Chrome-Last.fm-Scrobbler pakartot.lt Connector
*
* Juozas Masiulis --- http://www.euphorbium.lt ---
* juozas.masiulis[at]euphorbium[dot]lt
*
*/

/********* Configuration: ***********/

// changes to the DOM in this container will trigger an update.
LFM_WATCHED_CONTAINER = "div.jp-info";

// function that returns title of current song
function LFM_TRACK_TITLE() {
return $(".jp-player-title>a").text();
}

// function that returns artist of current song
function LFM_TRACK_ARTIST() {
return $(".jp-player-artist>a").text();
}

// function that returns album of current song
function LFM_TRACK_ALBUM() {
return $("a.playerBarAlbum").text();
}

// function that returns duration of current song in seconds
// called at begining of song
function LFM_TRACK_DURATION() {
durationArr = $("div.jp-current-time").html().split(":")[1].split(":");
return parseInt(durationArr[0])*60 + parseInt(durationArr[1]);
}


/********* Connector: ***********/

var LFM_lastTrack = "";
var LFM_isWaiting = 0;

function LFM_updateNowPlaying(){
// Acquire data from page
title = LFM_TRACK_TITLE();
artist = LFM_TRACK_ARTIST();
duration = LFM_TRACK_DURATION();
newTrack = title + " " + artist;
// Update scrobbler if necessary
if (newTrack != "" && newTrack != LFM_lastTrack){
if (duration == 0) {
// Nasty workaround for delayed duration visiblity with skipped tracks.
setTimeout(LFM_updateNowPlaying, 5000);
return 0;
}
console.log("submitting a now playing request. artist: "+artist+", title: "+title+", duration: "+duration);
LFM_lastTrack = newTrack;
chrome.runtime.sendMessage({type: 'validate', artist: artist, track: title}, function(response) {
if (response != false) {
chrome.runtime.sendMessage({type: 'nowPlaying', artist: artist, track: title, duration: duration});
} else { // on failure send nowPlaying 'unknown song'
chrome.runtime.sendMessage({type: 'nowPlaying', duration: duration});
}
});
}
LFM_isWaiting = 0;
}

// Run at startup
$(function(){
console.log("pakartot module starting up");

$(LFM_WATCHED_CONTAINER).live('DOMSubtreeModified', function(e) {
//console.log("Live watcher called");
if ($(LFM_WATCHED_CONTAINER).length > 0) {
if(LFM_isWaiting == 0){
LFM_isWaiting = 1;
setTimeout(LFM_updateNowPlaying, 10000);
}
return;
}
});

$(window).unload(function() {
chrome.runtime.sendMessage({type: 'reset'});
return true;
});
});


/**
* Listen for requests from scrobbler.js
*/
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
switch(request.type) {

// background calls this to see if the script is already injected
case 'ping':
sendResponse(true);
break;
}
}
);
52 changes: 41 additions & 11 deletions core/connectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,19 @@ define(function() {
js: ['connectors/61.js']
},

//{
// label: 'Google Play Music',
// matches: ['*://play.google.com/music/*', '*://play-music.sandbox.google.com/music/*'],
// js: ['connectors/googlemusic.js']
//},

{
label: 'Google Play Music',
matches: ['*://play.google.com/music/*'],
js: ['connectors/googlemusic.js']
js: ['connectors/v2/googlemusic.js'],
version: 2
},

// {
// label: 'Google Play Music',
// matches: ['*://play.google.com/music/*'],
// js: ['connectors/v2/googlemusic.js'],
// version: 2
// },

{
label: 'MySpace',
matches: ['*://myspace.com/*'],
Expand Down Expand Up @@ -104,7 +104,7 @@ define(function() {

{
label: 'Bandcamp',
matches: ['*://*.bandcamp.com/*'],
matches: ['*://*.bandcamp.com/*', '*://bandcamp.com/discover'],
js: ['connectors/bandcamp.js']
},

Expand All @@ -120,6 +120,12 @@ define(function() {
js: ['connectors/pandora.js']
},

{
label: 'pakartot',
matches: ['*://www.pakartot.lt/*'],
js: ['connectors/pakartot.js']
},

{
label: 'Deezer',
matches: ['*://www.deezer.com/*'],
Expand All @@ -134,7 +140,7 @@ define(function() {

{
label: 'Amazon',
matches: ['*://www.amazon.com/gp/dmusic/*/player*', '*://www.amazon.de/gp/dmusic/*/player*', '*://www.amazon.es/gp/dmusic/*/player*', '*://www.amazon.co.uk/gp/dmusic/*/player*'],
matches: ['*://www.amazon.com/gp/dmusic/cloudplayer/*', '*://www.amazon.de/gp/dmusic/cloudplayer/*', '*://www.amazon.es/gp/dmusic/cloudplayer/*', '*://www.amazon.co.uk/gp/dmusic/cloudplayer/*'],
js: ['connectors/amazon.js']
},

Expand Down Expand Up @@ -208,7 +214,7 @@ define(function() {

{
label: 'Plug.dj',
matches: ['http://plug.dj/*'],
matches: ['*://plug.dj/*'],
js: ['connectors/plugdj.js']
},

Expand Down Expand Up @@ -421,6 +427,30 @@ define(function() {
label: 'Soundozer',
matches: ['*://soundozer.com/*'],
js: ['connectors/soundozer.js']
},

{
label: '163 Music',
matches: ['*://music.163.com/*'],
js: ['connectors/163music.js']
},

{
label: 'blinkboxMusic',
matches: ['*://www.blinkboxmusic.com/*'],
js: ['connectors/blinkboxmusic.js']
},

{
label: 'luooMusic',
matches: ['*://www.luoo.net/*'],
js: ['connectors/luoo.js']
},

{
label: 'ambientsleepingpill',
matches: ['*://*.ambientsleepingpill.com/'],
js: ['connectors/ambientsleepingpill.js']
}
];
});