Add support for youtube api v2 keys because v3 is a butt
This commit is contained in:
parent
a26df3c92c
commit
2efd3f0db2
|
|
@ -36,7 +36,9 @@ var defaults = {
|
||||||
},
|
},
|
||||||
"mail-from" : "some.user@gmail.com",
|
"mail-from" : "some.user@gmail.com",
|
||||||
"domain" : "http://localhost",
|
"domain" : "http://localhost",
|
||||||
"ytapikey" : ""
|
"ytv3apikey" : "",
|
||||||
|
"enable-ytv3" : false,
|
||||||
|
"ytv2devkey" : ""
|
||||||
}
|
}
|
||||||
|
|
||||||
function save(cfg, file) {
|
function save(cfg, file) {
|
||||||
|
|
|
||||||
25
get-info.js
25
get-info.js
|
|
@ -34,7 +34,7 @@ module.exports = function (Server) {
|
||||||
var Getters = {
|
var Getters = {
|
||||||
/* youtube.com */
|
/* youtube.com */
|
||||||
yt: function (id, callback) {
|
yt: function (id, callback) {
|
||||||
if(Server.cfg["ytapikey"]) {
|
if(Server.cfg["enable-ytv3"] && Server.cfg["ytv3apikey"]) {
|
||||||
Getters["ytv3"](id, callback);
|
Getters["ytv3"](id, callback);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -48,12 +48,18 @@ module.exports = function (Server) {
|
||||||
timeout: 1000
|
timeout: 1000
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if(Server.cfg["ytv2devkey"]) {
|
||||||
|
options.headers = {
|
||||||
|
"X-Gdata-Key": "key=" + Server.cfg["ytv2devkey"]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
urlRetrieve(https, options, function (status, data) {
|
urlRetrieve(https, options, function (status, data) {
|
||||||
if(status === 404) {
|
if(status === 404) {
|
||||||
callback("Video not found", null);
|
callback("Video not found", null);
|
||||||
return;
|
return;
|
||||||
} else if(status === 403) {
|
} else if(status === 403) {
|
||||||
callbacK("Private video", null);
|
callback("Private video", null);
|
||||||
return;
|
return;
|
||||||
} else if(status !== 200) {
|
} else if(status !== 200) {
|
||||||
callback(true, null);
|
callback(true, null);
|
||||||
|
|
@ -154,11 +160,18 @@ module.exports = function (Server) {
|
||||||
timeout: 1000
|
timeout: 1000
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if(Server.cfg["ytv2devkey"]) {
|
||||||
|
options.headers = {
|
||||||
|
"X-Gdata-Key": "key=" + Server.cfg["ytv2devkey"]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
urlRetrieve(https, options, function (status, data) {
|
urlRetrieve(https, options, function (status, data) {
|
||||||
if(status === 404) {
|
if(status === 404) {
|
||||||
callback("Playlist not found", null);
|
callback("Playlist not found", null);
|
||||||
return;
|
return;
|
||||||
} else if(status === 403) {
|
} else if(status === 403) {
|
||||||
|
console.log(options.path);
|
||||||
callback("Playlist is private", null);
|
callback("Playlist is private", null);
|
||||||
return;
|
return;
|
||||||
} else if(status !== 200) {
|
} else if(status !== 200) {
|
||||||
|
|
@ -209,6 +222,12 @@ module.exports = function (Server) {
|
||||||
timeout: 1000
|
timeout: 1000
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if(Server.cfg["ytv2devkey"]) {
|
||||||
|
options.headers = {
|
||||||
|
"X-Gdata-Key": "key=" + Server.cfg["ytv2devkey"]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
urlRetrieve(https, options, function (status, data) {
|
urlRetrieve(https, options, function (status, data) {
|
||||||
if(status !== 200) {
|
if(status !== 200) {
|
||||||
callback(true, null);
|
callback(true, null);
|
||||||
|
|
@ -254,7 +273,7 @@ module.exports = function (Server) {
|
||||||
callback("Video not found", null);
|
callback("Video not found", null);
|
||||||
return;
|
return;
|
||||||
} else if(status === 403) {
|
} else if(status === 403) {
|
||||||
callbacK("Private video", null);
|
callback("Private video", null);
|
||||||
return;
|
return;
|
||||||
} else if(status !== 200) {
|
} else if(status !== 200) {
|
||||||
callback(true, null);
|
callback(true, null);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue