Use VideoJS for google+
This commit is contained in:
parent
fe9ebfa6b1
commit
ce8ac4591e
3 changed files with 22 additions and 109 deletions
118
lib/get-info.js
118
lib/get-info.js
|
|
@ -530,6 +530,21 @@ var Getters = {
|
|||
});
|
||||
},
|
||||
|
||||
/* Google+ videos */
|
||||
gp: function (id, callback) {
|
||||
var data = {
|
||||
type: "google+",
|
||||
kind: "single",
|
||||
id: id
|
||||
};
|
||||
|
||||
mediaquery.lookup(data).then(function (video) {
|
||||
callback(null, convertMedia(video));
|
||||
}).catch(function (err) {
|
||||
callback(err.message || err);
|
||||
});
|
||||
},
|
||||
|
||||
/* ffmpeg for raw files */
|
||||
fi: function (id, cb) {
|
||||
ffmpeg.query(id, function (err, data) {
|
||||
|
|
@ -545,109 +560,6 @@ var Getters = {
|
|||
});
|
||||
},
|
||||
|
||||
/*
|
||||
* Google+ videos
|
||||
*
|
||||
* Also known as Picasa Web Albums.
|
||||
*
|
||||
*/
|
||||
gp: function (id, cb) {
|
||||
var idparts = id.split("_");
|
||||
if (idparts.length !== 3) {
|
||||
return cb("Invalid Google+ video ID");
|
||||
}
|
||||
|
||||
var options = {
|
||||
host: "picasaweb.google.com",
|
||||
path: '/data/feed/api/user/'+idparts[0]+'/albumid/'+idparts[1]+'/photoid/'+idparts[2]+'?kind=tag',
|
||||
port: 443
|
||||
};
|
||||
|
||||
urlRetrieve(https, options, function (status, res) {
|
||||
switch (status) {
|
||||
case 200:
|
||||
break; /* Request is OK, skip to handling data */
|
||||
case 400:
|
||||
return cb("Invalid request", null);
|
||||
case 403:
|
||||
return cb("Private video", null);
|
||||
case 404:
|
||||
return cb("Video not found", null);
|
||||
case 500:
|
||||
case 503:
|
||||
return cb("Service unavailable", null);
|
||||
default:
|
||||
return cb("HTTP " + status, null);
|
||||
}
|
||||
|
||||
try {
|
||||
var $ = cheerio.load(res, { xmlMode: true });
|
||||
switch ($("gphoto\\:videostatus").text()) {
|
||||
case "final":
|
||||
break; /* Incoming Fun. */
|
||||
case "pending":
|
||||
return cb("The video is still being processed.", null);
|
||||
case "failed":
|
||||
return cb("A processing error has occured and the video should be deleted.", null);
|
||||
case "ready":
|
||||
return cb("The video has been processed but still needs a thumbnail.", null);
|
||||
}
|
||||
var duration = parseInt($("gphoto\\:originalvideo").attr("duration"),10);
|
||||
var title = $("media\\:title").text();
|
||||
var videos = {};
|
||||
$('media\\:content[medium="video"]').each(function(index, element){
|
||||
var url = $(this).attr("url");
|
||||
var match = url.match(/itag=(\d+)/)
|
||||
if (!match) {
|
||||
match = url.match(/googleusercontent.*=m(\d+)$/);
|
||||
}
|
||||
|
||||
if (match && match[1]) {
|
||||
var type = match[1];
|
||||
videos[type] = {
|
||||
format: type,
|
||||
link: url
|
||||
};
|
||||
}
|
||||
});
|
||||
$ = null;
|
||||
|
||||
var direct = {};
|
||||
|
||||
for (var key in GOOGLE_PREFERENCE) {
|
||||
for (var i = 0; i < GOOGLE_PREFERENCE[key].length; i++) {
|
||||
var format = GOOGLE_PREFERENCE[key][i];
|
||||
|
||||
if (format in videos) {
|
||||
direct[key] = {
|
||||
url: videos[format].link,
|
||||
contentType: CONTENT_TYPES[format]
|
||||
};
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.keys(direct).length === 0) {
|
||||
return cb("Unable to retrieve video data from Google+. The videos " +
|
||||
"may have not finished processing yet.");
|
||||
} else if (!title) {
|
||||
return cb("Unable to retrieve title from Google+. Check that " +
|
||||
"the album exists and is shared publicly.");
|
||||
} else if (!duration) {
|
||||
return cb("Unable to retreive duration from Google+. This might be " +
|
||||
"because the video is still processing.");
|
||||
}
|
||||
|
||||
var media = new Media(id, title, duration, "gp", { gpdirect: direct });
|
||||
cb(null, media);
|
||||
} catch (e) {
|
||||
cb("Unknown error");
|
||||
Logger.errlog.log("Unknown error for Google+ ID " + id + ": " + e.stack);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/* hitbox.tv */
|
||||
hb: function (id, callback) {
|
||||
var m = id.match(/([\w-]+)/);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue