Skip to content

Commit

Permalink
use username if track title is not in "artist - track" format
Browse files Browse the repository at this point in the history
  • Loading branch information
Titus Ramczykowski committed Sep 2, 2012
1 parent e8a588e commit 8cfcd08
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions soundcloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,32 @@
var trackInfo = function(context) {
var player = $(context);
var title;
if ($(context).parent().hasClass('playlist-player')) {

if ($(context).parent().hasClass('playlist-player'))
title = $('.tracks li.playing .info a').text().trim();
}

if(!title)
title = $('.soundTitle__title', player).text().trim();

if(!title)
title = $('.info-header h3 a, .info-header h1 em', player).text().trim();

return title.split(" - ");
trackInfo = title.split(" - ");

if(!trackInfo[1])
return [artist(context),title];

return trackInfo;
};

var artist = function(context) {
var node = $('.info-header .user-name', context);
if (node.length)
return node[0].text;

node = $('.soundTitle__username', context);
if (node.length)
return node[0].text;
};

var duration = function(context) {
Expand Down

0 comments on commit 8cfcd08

Please sign in to comment.