Add html titles, improve youtube track matching
This commit is contained in:
parent
6decb7e8e3
commit
4d4c078220
3 changed files with 19 additions and 13 deletions
|
@ -29,22 +29,28 @@ module.exports.search = function(data) {
|
|||
query = data.artist.name + " " + data.name;
|
||||
album = data.name;
|
||||
} else if (type == "track") {
|
||||
query = data.artist.name + data.name;
|
||||
query = data.artist.name + " " + data.name;
|
||||
album = data.album.name
|
||||
}
|
||||
|
||||
var path = "/search?part=snippet&q=" + encodeURIComponent(query) + "&type=video&videoCaption=any&key=" + credentials.key;
|
||||
|
||||
request.get(apiRoot + path, function(res) {
|
||||
var result = res.body.items[0];
|
||||
deferred.resolve({
|
||||
service: "youtube",
|
||||
type: "video",
|
||||
id: result.id.videoId,
|
||||
name: result.snippet.title,
|
||||
streamUrl: "https://www.youtube.com/watch?v=" + result.id.videoId,
|
||||
purchaseUrl: null,
|
||||
artwork: result.snippet.thumbnails.medium.url,
|
||||
});
|
||||
|
||||
if (!result) {
|
||||
deferred.resolve({service:"youtube", type: "video"});
|
||||
} else {
|
||||
deferred.resolve({
|
||||
service: "youtube",
|
||||
type: "video",
|
||||
id: result.id.videoId,
|
||||
name: result.snippet.title,
|
||||
streamUrl: "https://www.youtube.com/watch?v=" + result.id.videoId,
|
||||
purchaseUrl: null,
|
||||
artwork: result.snippet.thumbnails.medium.url,
|
||||
});
|
||||
}
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
|
|
|
@ -29,7 +29,7 @@ module.exports = function(req, res, next) {
|
|||
|
||||
req.db.matches.findOne({_id:serviceId + itemId}).then(function(doc) {
|
||||
if (doc) {
|
||||
res.render(type, {page: type, items: doc.items});
|
||||
res.render(type, {page: type, title: doc.items[0].name + " by " + doc.items[0].artist.name, items: doc.items});
|
||||
} else {
|
||||
Q.timeout(services[serviceId].lookupId(itemId, type), 5000).then(function(item) {
|
||||
for (var id in services) {
|
||||
|
@ -58,7 +58,7 @@ module.exports = function(req, res, next) {
|
|||
items.unshift(item);
|
||||
req.db.matches.save({_id:serviceId + itemId, items:items});
|
||||
cache[serviceId][type + "-" + itemId] = items;
|
||||
res.render(type, {page: type, items: items});
|
||||
res.render(type, {page: type, title: item.name + " by " + item.artist.name, items: items});
|
||||
});
|
||||
}, function(error) {
|
||||
if (error.code == "ETIMEDOUT") {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<title>Match Audio</title>
|
||||
<title><% if (locals.title) { %><%= title %> - <% } %>Match Audio</title>
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="shortcut icon" href="/images/favicon.png">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue