1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-08-03 00:18:31 +00:00

3.5.433. Fix link info for clips. Add it for videos. Minor dark theme tweak.

This commit is contained in:
SirStendec 2017-03-01 22:02:21 -05:00
parent df7f5d6ba0
commit ac8250928c
6 changed files with 41 additions and 14 deletions

View file

@ -18,7 +18,8 @@ var FFZ = window.FrankerFaceZ,
LINK = /(?:https?:\/\/)?(?:[-a-zA-Z0-9@:%_\+~#=]+\.)+[a-z]{2,6}\b(?:[-a-zA-Z0-9@:%_\+.~#?&\/\/=()]*)/g,
CLIP_URL = /(?:https?:\/\/)?clips\.twitch\.tv\/(\w+)\/(\w+)/,
CLIP_URL = /^(?:https?:\/\/)?clips\.twitch\.tv\/(\w+?\/?\w*?)(?:\/edit)?(?:[\?#]|$)/,
VIDEO_URL = /^(?:https?:\/\/)?(?:www\.)twitch\.tv\/(?:\w+\/v|videos)\/(\w+)$/,
LINK_SPLIT = /^(?:(https?):\/\/)?(?:(.*?)@)?([^\/:]+)(?::(\d+))?(.*?)(?:\?(.*?))?(?:\#(.*?))?$/,
YOUTUBE_CHECK = /^(?:https?:\/\/)?(?:m\.|www\.)?youtu(?:be\.com|\.be)\/(?:v\/|watch\/|.*?(?:embed|watch).*?v=)?([a-zA-Z0-9\-_]+)$/,
@ -1032,11 +1033,12 @@ FFZ.prototype.render_token = function(render_links, warn_links, render_bits, tok
this._link_data[href] = true;
var success = load_link_data.bind(this, href),
clip_info = CLIP_URL.exec(href);
clip_info = CLIP_URL.exec(href),
video_info = VIDEO_URL.exec(href);
if ( clip_info ) {
var clips = utils.ember_lookup('service:clips');
clips && clips.getClipInfo(clip_info[1] + '/' + clip_info[2]).then(function(data) {
clips && clips.getClipInfo(clip_info[1]).then(function(data) {
success(true, {
image: data.previewImage,
image_iframe: false,
@ -1046,6 +1048,17 @@ FFZ.prototype.render_token = function(render_links, warn_links, render_bits, tok
});
});
} else if ( video_info ) {
utils.api.get("videos/" + video_info[1], undefined, {version: 5})
.then(function(data) {
success(true, {
image: data.preview.large,
image_iframe: false,
html: '<span class="ffz-clip-title">' + utils.sanitize(data.title) + ' [' + utils.time_to_string(data.length) + ']</span>' +
'Channel: ' + utils.sanitize(data.channel.display_name) +
'<br>Game: ' + utils.sanitize(data.game)
})});
} else
this.ws_send("get_link", href, success);
}