mirror of https://github.com/calzoneman/sync.git
Add twitch clip support (#659)
This commit is contained in:
parent
995ab142e3
commit
e9c519c6e2
|
@ -18,6 +18,7 @@ TYPE_MAP =
|
|||
vm: VideoJSPlayer
|
||||
hl: HLSPlayer
|
||||
sb: VideoJSPlayer
|
||||
tc: VideoJSPlayer
|
||||
|
||||
window.loadMediaPlayer = (data) ->
|
||||
try
|
||||
|
|
|
@ -385,6 +385,8 @@ function preprocessConfig(cfg) {
|
|||
if (cfg["twitch-client-id"]) {
|
||||
require("cytube-mediaquery/lib/provider/twitch-vod").setClientID(
|
||||
cfg["twitch-client-id"]);
|
||||
require("cytube-mediaquery/lib/provider/twitch-clip").setClientID(
|
||||
cfg["twitch-client-id"]);
|
||||
} else {
|
||||
LOGGER.warn("No Twitch Client ID set. Twitch VOD links will " +
|
||||
"not work. See twitch-client-id in config.template.yaml and " +
|
||||
|
|
|
@ -12,6 +12,7 @@ var Vidme = require("cytube-mediaquery/lib/provider/vidme");
|
|||
var Streamable = require("cytube-mediaquery/lib/provider/streamable");
|
||||
var GoogleDrive = require("cytube-mediaquery/lib/provider/googledrive");
|
||||
var TwitchVOD = require("cytube-mediaquery/lib/provider/twitch-vod");
|
||||
var TwitchClip = require("cytube-mediaquery/lib/provider/twitch-clip");
|
||||
import { LoggerFactory } from '@calzoneman/jsli';
|
||||
|
||||
const LOGGER = LoggerFactory.getLogger('get-info');
|
||||
|
@ -391,6 +392,25 @@ var Getters = {
|
|||
});
|
||||
},
|
||||
|
||||
/* twitch clip */
|
||||
tc: function (id, callback) {
|
||||
var m = id.match(/^([A-Za-z]+)$/);
|
||||
if (m) {
|
||||
id = m[1];
|
||||
} else {
|
||||
process.nextTick(callback, "Invalid Twitch VOD ID");
|
||||
return;
|
||||
}
|
||||
|
||||
TwitchClip.lookup(id).then(video => {
|
||||
const media = new Media(video.id, video.title, video.duration,
|
||||
"tc", video.meta);
|
||||
process.nextTick(callback, false, media);
|
||||
}).catch(function (err) {
|
||||
callback(err.message || err, null);
|
||||
});
|
||||
},
|
||||
|
||||
/* ustream.tv */
|
||||
us: function (id, callback) {
|
||||
/**
|
||||
|
|
|
@ -244,6 +244,8 @@
|
|||
return id;
|
||||
case "sb":
|
||||
return "https://streamable.com/" + id;
|
||||
case "tc":
|
||||
return "https://clips.twitch.tv/" + id;
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -1519,7 +1519,8 @@
|
|||
im: ImgurPlayer,
|
||||
vm: VideoJSPlayer,
|
||||
hl: HLSPlayer,
|
||||
sb: VideoJSPlayer
|
||||
sb: VideoJSPlayer,
|
||||
tc: VideoJSPlayer
|
||||
};
|
||||
|
||||
window.loadMediaPlayer = function(data) {
|
||||
|
|
|
@ -54,6 +54,8 @@ function formatURL(data) {
|
|||
return data.id;
|
||||
case "sb":
|
||||
return "https://streamable.com/" + data.id;
|
||||
case "tc":
|
||||
return "https://clips.twitch.tv/" + data.id;
|
||||
default:
|
||||
return "#";
|
||||
}
|
||||
|
@ -1284,6 +1286,13 @@ function parseMediaLink(url) {
|
|||
};
|
||||
}
|
||||
|
||||
if ((m = url.match(/clips\.twitch\.tv\/([A-Za-z]+)/))) {
|
||||
return {
|
||||
id: m[1],
|
||||
type: "tc"
|
||||
};
|
||||
}
|
||||
|
||||
if((m = url.match(/twitch\.tv\/(?:.*?)\/([cv])\/(\d+)/))) {
|
||||
return {
|
||||
id: m[1] + m[2],
|
||||
|
|
Loading…
Reference in New Issue