mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-09-16 18:06:55 +00:00
4.20.17
* Added: Download link for clips. Requires the current user to be an editor of the channel to appear. * Added: Option to hide the Unfollow button from channels to prevent accidentally unfollowing. * Added: Option to add Schedule, Videos, and Clips links to live channel pages. * Fixed: Metadata not rendering on video and clips pages. * Removed: Outdated channel appearance settings that no longer have any effect.
This commit is contained in:
parent
3d88836a0e
commit
2f105eb3c4
8 changed files with 223 additions and 12 deletions
|
@ -12,6 +12,8 @@ import {duration_to_string, durationForURL} from 'utilities/time';
|
|||
import Tooltip from 'utilities/tooltip';
|
||||
import Module from 'utilities/module';
|
||||
|
||||
const CLIP_URL = /^https:\/\/[^/]+\.twitch\.tv\/.+?\.mp4$/;
|
||||
|
||||
export default class Metadata extends Module {
|
||||
constructor(...args) {
|
||||
super(...args);
|
||||
|
@ -23,6 +25,19 @@ export default class Metadata extends Module {
|
|||
this.should_enable = true;
|
||||
this.definitions = {};
|
||||
|
||||
this.settings.add('metadata.clip-download', {
|
||||
default: true,
|
||||
|
||||
ui: {
|
||||
path: 'Channel > Metadata >> Clips',
|
||||
title: 'Add a Download button for editors to clip pages.',
|
||||
description: 'This adds a download button beneath the player on clip pages (the main site, not on `clips.twitch.tv`) for broadcasters and their editors.',
|
||||
component: 'setting-check-box'
|
||||
},
|
||||
|
||||
changed: () => this.updateMetadata('clip-download')
|
||||
});
|
||||
|
||||
this.settings.add('metadata.player-stats', {
|
||||
default: false,
|
||||
|
||||
|
@ -228,6 +243,45 @@ export default class Metadata extends Module {
|
|||
}
|
||||
}
|
||||
|
||||
this.definitions['clip-download'] = {
|
||||
button: true,
|
||||
inherit: true,
|
||||
|
||||
setup(data) {
|
||||
if ( ! this.settings.get('metadata.clip-download') )
|
||||
return;
|
||||
|
||||
const Player = this.resolve('site.player'),
|
||||
player = Player.current;
|
||||
if ( ! player )
|
||||
return;
|
||||
|
||||
const sink = player.mediaSinkManager || player.core?.mediaSinkManager,
|
||||
src = sink?.video?.src;
|
||||
|
||||
if ( ! src || ! CLIP_URL.test(src) )
|
||||
return;
|
||||
|
||||
const user = this.resolve('site').getUser?.(),
|
||||
is_self = user?.id == data.channel.id;
|
||||
|
||||
if ( is_self || data.getUserSelfImmediate(data.refresh)?.isEditor )
|
||||
return src;
|
||||
},
|
||||
|
||||
label(src) {
|
||||
if ( src )
|
||||
return this.i18n.t('metadata.clip-download', 'Download');
|
||||
},
|
||||
|
||||
icon: 'ffz-i-download',
|
||||
|
||||
click(src) {
|
||||
const link = createElement('a', {target: '_blank', href: src});
|
||||
link.click();
|
||||
}
|
||||
}
|
||||
|
||||
this.definitions['player-stats'] = {
|
||||
button: true,
|
||||
inherit: true,
|
||||
|
@ -507,6 +561,12 @@ export default class Metadata extends Module {
|
|||
return destroy();
|
||||
|
||||
try {
|
||||
const ref_fn = () => refresh_fn(key);
|
||||
data = {
|
||||
...data,
|
||||
refresh: ref_fn
|
||||
};
|
||||
|
||||
// Process the data if a setup method is defined.
|
||||
if ( def.setup )
|
||||
data = await def.setup.call(this, data);
|
||||
|
@ -515,7 +575,7 @@ export default class Metadata extends Module {
|
|||
const refresh = maybe_call(def.refresh, this, data);
|
||||
if ( refresh )
|
||||
timers[key] = setTimeout(
|
||||
() => refresh_fn(key),
|
||||
ref_fn,
|
||||
typeof refresh === 'number' ? refresh : 1000
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue