mirror of https://github.com/calzoneman/sync.git
Add vidme support (#568)
This commit is contained in:
parent
056b2a48ea
commit
6f56862307
|
@ -2,7 +2,7 @@
|
|||
"author": "Calvin Montgomery",
|
||||
"name": "CyTube",
|
||||
"description": "Online media synchronizer and chat",
|
||||
"version": "3.17.1",
|
||||
"version": "3.17.2",
|
||||
"repository": {
|
||||
"url": "http://github.com/calzoneman/sync"
|
||||
},
|
||||
|
|
|
@ -14,6 +14,7 @@ TYPE_MAP =
|
|||
hb: HitboxPlayer
|
||||
us: UstreamPlayer
|
||||
im: ImgurPlayer
|
||||
vm: VideoJSPlayer
|
||||
|
||||
window.loadMediaPlayer = (data) ->
|
||||
try
|
||||
|
|
|
@ -39,6 +39,12 @@ MediaRefresherModule.prototype.onPreMediaChange = function (data, cb) {
|
|||
pl._refreshing = false;
|
||||
cb(null, ChannelModule.PASSTHROUGH);
|
||||
});
|
||||
case "vm":
|
||||
pl._refreshing = true;
|
||||
return this.initVidme(data, function () {
|
||||
pl._refreshing = false;
|
||||
cb(null, ChannelModule.PASSTHROUGH);
|
||||
});
|
||||
default:
|
||||
return cb(null, ChannelModule.PASSTHROUGH);
|
||||
}
|
||||
|
@ -220,4 +226,58 @@ MediaRefresherModule.prototype.initGooglePlus = function (media, cb) {
|
|||
});
|
||||
};
|
||||
|
||||
MediaRefresherModule.prototype.initVidme = function (data, cb) {
|
||||
var self = this;
|
||||
self.refreshVidme(data, cb);
|
||||
|
||||
/*
|
||||
* Refresh every 55 minutes.
|
||||
* The expiration is 1 hour, but refresh 5 minutes early to be safe
|
||||
*/
|
||||
self._interval = setInterval(function () {
|
||||
self.refreshVidme(data);
|
||||
}, 55 * 60 * 1000);
|
||||
};
|
||||
|
||||
MediaRefresherModule.prototype.refreshVidme = function (media, cb) {
|
||||
var self = this;
|
||||
|
||||
if (self.dead || self.channel.dead) {
|
||||
self.unload();
|
||||
return;
|
||||
}
|
||||
|
||||
self.channel.refCounter.ref("MediaRefresherModule::refreshVidme");
|
||||
InfoGetter.getMedia(media.id, "vm", function (err, data) {
|
||||
if (self.dead || self.channel.dead) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (err) {
|
||||
self.channel.logger.log("[mediarefresher] Vidme refresh failed: " + err);
|
||||
self.channel.refCounter.unref("MediaRefresherModule::refreshVidme");
|
||||
if (cb) {
|
||||
process.nextTick(cb);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (media !== self._media) {
|
||||
self.channel.refCounter.unref("MediaRefresherModule::refreshVidme");
|
||||
if (cb) {
|
||||
process.nextTick(cb);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
self.channel.logger.log("[mediarefresher] Refreshed Vidme video with ID " +
|
||||
media.id);
|
||||
media.meta = data.meta;
|
||||
self.channel.refCounter.unref("MediaRefresherModule::refreshVidme");
|
||||
if (cb) {
|
||||
process.nextTick(cb);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = MediaRefresherModule;
|
||||
|
|
|
@ -10,6 +10,7 @@ var ffmpeg = require("./ffmpeg");
|
|||
var mediaquery = require("cytube-mediaquery");
|
||||
var YouTube = require("cytube-mediaquery/lib/provider/youtube");
|
||||
var Vimeo = require("cytube-mediaquery/lib/provider/vimeo");
|
||||
var Vidme = require("cytube-mediaquery/lib/provider/vidme");
|
||||
|
||||
/*
|
||||
* Preference map of quality => youtube formats.
|
||||
|
@ -547,6 +548,20 @@ var Getters = {
|
|||
var media = new Media(id, title, "--:--", "hb");
|
||||
callback(false, media);
|
||||
},
|
||||
|
||||
/* vid.me */
|
||||
vm: function (id, callback) {
|
||||
if (!/^[\w-]+$/.test(id)) {
|
||||
process.nextTick(callback, "Invalid vid.me ID");
|
||||
return;
|
||||
}
|
||||
|
||||
Vidme.lookup(id).then(video => {
|
||||
const media = new Media(video.id, video.title, video.duration,
|
||||
"vm", video.meta);
|
||||
process.nextTick(callback, false, media);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
|
|
@ -1272,7 +1272,8 @@
|
|||
rt: RTMPPlayer,
|
||||
hb: HitboxPlayer,
|
||||
us: UstreamPlayer,
|
||||
im: ImgurPlayer
|
||||
im: ImgurPlayer,
|
||||
vm: VideoJSPlayer
|
||||
};
|
||||
|
||||
window.loadMediaPlayer = function(data) {
|
||||
|
|
|
@ -1354,6 +1354,13 @@ function parseMediaLink(url) {
|
|||
};
|
||||
}
|
||||
|
||||
if((m = url.match(/vid\.me\/([\w-]+)/))) {
|
||||
return {
|
||||
id: m[1],
|
||||
type: "vm"
|
||||
};
|
||||
}
|
||||
|
||||
/* Shorthand URIs */
|
||||
// To catch Google Plus by ID alone
|
||||
if ((m = url.match(/^(?:gp:)?(\d{21}_\d{19}_\d{19})/))) {
|
||||
|
|
Loading…
Reference in New Issue