<commit_before>// State for event handlers
var state = 'init';

// Used only to remember last song title
var clipTitle = '';  

// Timeout to scrobble track ater minimum time passes
var scrobbleTimeout = null;

// Glabal constant for the song container ....
var CONTAINER_SELECTOR = '#playerSongInfo';


$(function(){   
	$(CONTAINER_SELECTOR).live('DOMSubtreeModified', function(e) {

		if ($(CONTAINER_SELECTOR).length > 0) {
			updateNowPlaying();
			return;    
		}

   });
   
   console.log("Last.fm Scrobbler: starting Google Music connector")
   
   // first load
   updateNowPlaying();
});

/**
 * Called every time we load a new song
 */ 
function updateNowPlaying(){
    var parsedInfo = parseInfo();
    artist   = parsedInfo['artist']; 	//global
    track    = parsedInfo['track'];	//global
    duration = parsedInfo['duration']; 	//global
	
    if (artist == '' || track == '' || duration == 0) {return;}
    
    // check if the same track is being played and we have been called again
    // if the same track is being played we return
    if (clipTitle == track) {
	return;
    }
    clipTitle = track;
    
    chrome.extension.sendRequest({type: 'validate', artist: artist, track: track}, function(response) {
	if (response != false) {
	    chrome.extension.sendRequest({type: 'nowPlaying', artist: artist, track: track, duration: duration});
	}
         // on failure send nowPlaying 'unknown song'
         else {
            chrome.extension.sendRequest({type: 'nowPlaying', duration: duration});
         }
    });
}


function parseInfo() {
    var artist   = '';
    var track    = '';
    var duration = 0;

    // Get artist and song names
    var artistParent = $("div#player-artist");
    var trackParent = $("div#playerSongTitle");
    var durationValue = $("span#duration").text();
    
    try {
        if (null != artistParent) {
            artist = $("div.fade-out-content", artistParent).html();
            artist = artist.replace(/^\s+|\s+$/g,'');
        }
        if (null != trackParent) {
            track = $("div.fade-out-content", trackParent).html();<commit_msg>Addresses Issue #166 ampersand issue Google Music<commit_after>// State for event handlers
var state = 'init';

// Used only to remember last song title
var clipTitle = '';  

// Timeout to scrobble track ater minimum time passes
var scrobbleTimeout = null;

// Glabal constant for the song container ....
var CONTAINER_SELECTOR = '#playerSongInfo';


$(function(){   
	$(CONTAINER_SELECTOR).live('DOMSubtreeModified', function(e) {

		if ($(CONTAINER_SELECTOR).length > 0) {
			updateNowPlaying();
			return;    
		}

   });
   
   console.log("Last.fm Scrobbler: starting Google Music connector")
   
   // first load
   updateNowPlaying();
});

/**
 * Called every time we load a new song
 */ 
function updateNowPlaying(){
    var parsedInfo = parseInfo();
    artist   = parsedInfo['artist']; 	//global
    track    = parsedInfo['track'];	//global
    duration = parsedInfo['duration']; 	//global
	
    if (artist == '' || track == '' || duration == 0) {return;}
    
    // check if the same track is being played and we have been called again
    // if the same track is being played we return
    if (clipTitle == track) {
	return;
    }
    clipTitle = track;
    
    chrome.extension.sendRequest({type: 'validate', artist: artist, track: track}, function(response) {
	if (response != false) {
	    chrome.extension.sendRequest({type: 'nowPlaying', artist: artist, track: track, duration: duration});
	}
         // on failure send nowPlaying 'unknown song'
         else {
            chrome.extension.sendRequest({type: 'nowPlaying', duration: duration});
         }
    });
}


function parseInfo() {
    var artist   = '';
    var track    = '';
    var duration = 0;

    // Get artist and song names
    var artistParent = $("div#player-artist");
    var trackParent = $("div#playerSongTitle");
    var durationValue = $("span#duration").text();
    
    try {
        if (null != artistParent) {
            artist = $("div.fade-out-content", artistParent).text();
            artist = artist.replace(/^\s+|\s+$/g,'');
        }
        if (null != trackParent) {
            track = $("div.fade-out-content", trackParent).text();
{'fraction_non_alphanumeric': 0.14403195488721804, 'fraction_numerical': 0.0021146616541353382, 'mean_word_length': 2.7374890254609308, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1493232', 'n_tokens_mistral': 1303, 'n_tokens_neox': 1226, 'n_words': 361}