Improve matching and metadata extraction

This commit is contained in:
Jonathan Cremin 2015-01-27 21:32:28 +00:00
parent 7c1b8aa771
commit e4a856e228
6 changed files with 74 additions and 36 deletions

View file

@ -2,6 +2,7 @@
var parse = require('url').parse;
var freebase = require('./freebase');
var querystring = require('querystring');
var moment = require('moment');
var Promise = require('bluebird');
var request = require('superagent');
require('superagent-bluebird-promise');
@ -37,7 +38,7 @@ module.exports.parseUrl = function(url) {
module.exports.lookupId = function(id, type) {
var path = "/videos?part=snippet%2CtopicDetails&id=" + id + "&key=" + credentials.key;
var path = "/videos?part=snippet%2CtopicDetails%2CcontentDetails&id=" + id + "&key=" + credentials.key;
return request.get(apiRoot + path).promise().then(function(res) {
var item = res.body.items[0];
@ -65,11 +66,13 @@ module.exports.lookupId = function(id, type) {
} else if (topic.property["/type/object/type"].values.some(function(value) {
return value.text == "Musical Recording";
})) {
if (!match.name) {
match.album = {name: topic.property["/music/recording/releases"].values[0].text};
//if (moment.duration(item.contentDetails.duration).asSeconds() < 900) {
match.name = topic.property["/type/object/name"].values[0].text;
match.type = "track";
}
if (topic.property["/music/recording/releases"]) {
match.type = "album";
match.album.name = topic.property["/music/recording/releases"].values[0].text;
}
//}
} else if (topic.property["/type/object/type"].values.some(function(value) {
return value.text == "Musical Album";
})) {