Improve youtube matching, fix google service name

This commit is contained in:
Jonathan Cremin 2015-01-12 22:06:06 +00:00
parent e97db5b9e2
commit a2f95a98b2
2 changed files with 3 additions and 4 deletions

View file

@ -45,7 +45,7 @@ module.exports.lookupId = function(id, type) {
var promises = [];
item.topicDetails.topicIds.forEach(function(topicId) {
promises.push(freebase.get(topicId).then(function(topic) {
return topic.property["/music/recording/song"] ? topic : false;
return (topic.property["/music/recording/song"] ? topic : (topic.property["/music/recording/tracks"] ? topic : false));
}, function(err) {
console.log(err)
}));
@ -54,12 +54,11 @@ module.exports.lookupId = function(id, type) {
for (var key in topics) {
var topic = topics[key];
if (topic) {
console.log(topic.property['/music/recording/song'])
return {
id: id,
service: "youtube",
type: "track",
name: topic.property['/music/recording/song'].values[0].text,
name: topic.property['/music/recording/song'] ? topic.property['/music/recording/song'].values[0].text : topic.property["/music/recording/tracks"].values[0].text,
artist: {name: topic.property['/music/recording/artist'].values[0].text},
album: {name: ""},
streamUrl: "https://youtu.be/" + id,