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
|
vm: VideoJSPlayer
|
||||||
hl: HLSPlayer
|
hl: HLSPlayer
|
||||||
sb: VideoJSPlayer
|
sb: VideoJSPlayer
|
||||||
|
tc: VideoJSPlayer
|
||||||
|
|
||||||
window.loadMediaPlayer = (data) ->
|
window.loadMediaPlayer = (data) ->
|
||||||
try
|
try
|
||||||
|
|
|
@ -385,6 +385,8 @@ function preprocessConfig(cfg) {
|
||||||
if (cfg["twitch-client-id"]) {
|
if (cfg["twitch-client-id"]) {
|
||||||
require("cytube-mediaquery/lib/provider/twitch-vod").setClientID(
|
require("cytube-mediaquery/lib/provider/twitch-vod").setClientID(
|
||||||
cfg["twitch-client-id"]);
|
cfg["twitch-client-id"]);
|
||||||
|
require("cytube-mediaquery/lib/provider/twitch-clip").setClientID(
|
||||||
|
cfg["twitch-client-id"]);
|
||||||
} else {
|
} else {
|
||||||
LOGGER.warn("No Twitch Client ID set. Twitch VOD links will " +
|
LOGGER.warn("No Twitch Client ID set. Twitch VOD links will " +
|
||||||
"not work. See twitch-client-id in config.template.yaml and " +
|
"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 Streamable = require("cytube-mediaquery/lib/provider/streamable");
|
||||||
var GoogleDrive = require("cytube-mediaquery/lib/provider/googledrive");
|
var GoogleDrive = require("cytube-mediaquery/lib/provider/googledrive");
|
||||||
var TwitchVOD = require("cytube-mediaquery/lib/provider/twitch-vod");
|
var TwitchVOD = require("cytube-mediaquery/lib/provider/twitch-vod");
|
||||||
|
var TwitchClip = require("cytube-mediaquery/lib/provider/twitch-clip");
|
||||||
import { LoggerFactory } from '@calzoneman/jsli';
|
import { LoggerFactory } from '@calzoneman/jsli';
|
||||||
|
|
||||||
const LOGGER = LoggerFactory.getLogger('get-info');
|
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 */
|
/* ustream.tv */
|
||||||
us: function (id, callback) {
|
us: function (id, callback) {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -244,6 +244,8 @@
|
||||||
return id;
|
return id;
|
||||||
case "sb":
|
case "sb":
|
||||||
return "https://streamable.com/" + id;
|
return "https://streamable.com/" + id;
|
||||||
|
case "tc":
|
||||||
|
return "https://clips.twitch.tv/" + id;
|
||||||
default:
|
default:
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -1519,7 +1519,8 @@
|
||||||
im: ImgurPlayer,
|
im: ImgurPlayer,
|
||||||
vm: VideoJSPlayer,
|
vm: VideoJSPlayer,
|
||||||
hl: HLSPlayer,
|
hl: HLSPlayer,
|
||||||
sb: VideoJSPlayer
|
sb: VideoJSPlayer,
|
||||||
|
tc: VideoJSPlayer
|
||||||
};
|
};
|
||||||
|
|
||||||
window.loadMediaPlayer = function(data) {
|
window.loadMediaPlayer = function(data) {
|
||||||
|
|
|
@ -54,6 +54,8 @@ function formatURL(data) {
|
||||||
return data.id;
|
return data.id;
|
||||||
case "sb":
|
case "sb":
|
||||||
return "https://streamable.com/" + data.id;
|
return "https://streamable.com/" + data.id;
|
||||||
|
case "tc":
|
||||||
|
return "https://clips.twitch.tv/" + data.id;
|
||||||
default:
|
default:
|
||||||
return "#";
|
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+)/))) {
|
if((m = url.match(/twitch\.tv\/(?:.*?)\/([cv])\/(\d+)/))) {
|
||||||
return {
|
return {
|
||||||
id: m[1] + m[2],
|
id: m[1] + m[2],
|
||||||
|
|
Loading…
Reference in New Issue