mirror of
https://github.com/CompeyDev/fxtwitter-docker.git
synced 2025-04-19 11:24:00 +01:00
Multi-video embed code added
This commit is contained in:
parent
c5d6b36dc9
commit
bec8015064
2 changed files with 29 additions and 10 deletions
|
@ -49,10 +49,11 @@ export const handleStatus = async (
|
||||||
|
|
||||||
if (flags?.direct && tweet.media) {
|
if (flags?.direct && tweet.media) {
|
||||||
let redirectUrl: string | null = null;
|
let redirectUrl: string | null = null;
|
||||||
if (tweet.media.video) {
|
if (tweet.media.videos) {
|
||||||
redirectUrl = tweet.media.video.url;
|
const { videos } = tweet.media;
|
||||||
|
redirectUrl = (videos[(mediaNumber || 1) - 1] || videos[0]).url;
|
||||||
} else if (tweet.media.photos) {
|
} else if (tweet.media.photos) {
|
||||||
const photos = tweet.media.photos;
|
const { photos } = tweet.media;
|
||||||
redirectUrl = (photos[(mediaNumber || 1) - 1] || photos[0]).url;
|
redirectUrl = (photos[(mediaNumber || 1) - 1] || photos[0]).url;
|
||||||
}
|
}
|
||||||
if (redirectUrl) {
|
if (redirectUrl) {
|
||||||
|
@ -68,7 +69,7 @@ export const handleStatus = async (
|
||||||
|
|
||||||
let authorText = getAuthorText(tweet) || Strings.DEFAULT_AUTHOR_TEXT;
|
let authorText = getAuthorText(tweet) || Strings.DEFAULT_AUTHOR_TEXT;
|
||||||
const engagementText = authorText.replace(/ {4}/g, ' ');
|
const engagementText = authorText.replace(/ {4}/g, ' ');
|
||||||
const siteName = Constants.BRANDING_NAME;
|
let siteName = Constants.BRANDING_NAME;
|
||||||
let newText = tweet.text;
|
let newText = tweet.text;
|
||||||
|
|
||||||
const headers = [
|
const headers = [
|
||||||
|
@ -102,14 +103,15 @@ export const handleStatus = async (
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Video renderer */
|
/* Video renderer */
|
||||||
if (tweet.media?.video) {
|
if (tweet.media?.videos) {
|
||||||
authorText = newText || '';
|
authorText = newText || '';
|
||||||
|
|
||||||
if (tweet?.translation) {
|
if (tweet?.translation) {
|
||||||
authorText = tweet.translation?.text || '';
|
authorText = tweet.translation?.text || '';
|
||||||
}
|
}
|
||||||
|
|
||||||
const { video } = tweet.media;
|
const { videos } = tweet.media;
|
||||||
|
const video = videos[(mediaNumber || 1) - 1];
|
||||||
|
|
||||||
/* Multiplying by 0.5 is an ugly hack to fix Discord
|
/* Multiplying by 0.5 is an ugly hack to fix Discord
|
||||||
disliking videos that are too large lol */
|
disliking videos that are too large lol */
|
||||||
|
@ -123,6 +125,24 @@ export const handleStatus = async (
|
||||||
sizeMultiplier = 2;
|
sizeMultiplier = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const videoCounter = Strings.VIDEO_COUNT.format({
|
||||||
|
number: String(videos.indexOf(video) + 1),
|
||||||
|
total: String(videos.length)
|
||||||
|
});
|
||||||
|
|
||||||
|
authorText =
|
||||||
|
authorText === Strings.DEFAULT_AUTHOR_TEXT
|
||||||
|
? videoCounter
|
||||||
|
: `${authorText}${authorText ? ' ― ' : ''}${videoCounter}`;
|
||||||
|
|
||||||
|
let siteName = `${Constants.BRANDING_NAME} - ${videoCounter}`;
|
||||||
|
|
||||||
|
if (engagementText) {
|
||||||
|
siteName = `${Constants.BRANDING_NAME} - ${engagementText} - ${videoCounter}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
headers.push(`<meta property="og:site_name" content="${siteName}"/>`);
|
||||||
|
|
||||||
headers.push(
|
headers.push(
|
||||||
`<meta name="twitter:player:stream:content_type" content="${video.format}"/>`,
|
`<meta name="twitter:player:stream:content_type" content="${video.format}"/>`,
|
||||||
`<meta name="twitter:player:height" content="${video.height * sizeMultiplier}"/>`,
|
`<meta name="twitter:player:height" content="${video.height * sizeMultiplier}"/>`,
|
||||||
|
@ -160,15 +180,13 @@ export const handleStatus = async (
|
||||||
authorText =
|
authorText =
|
||||||
authorText === Strings.DEFAULT_AUTHOR_TEXT
|
authorText === Strings.DEFAULT_AUTHOR_TEXT
|
||||||
? photoCounter
|
? photoCounter
|
||||||
: `${authorText} ― ${photoCounter}`;
|
: `${authorText}${authorText ? ' ― ' : ''}${photoCounter}`;
|
||||||
|
|
||||||
let siteName = `${Constants.BRANDING_NAME} - ${photoCounter}`;
|
siteName = `${Constants.BRANDING_NAME} - ${photoCounter}`;
|
||||||
|
|
||||||
if (engagementText) {
|
if (engagementText) {
|
||||||
siteName = `${Constants.BRANDING_NAME} - ${engagementText} - ${photoCounter}`;
|
siteName = `${Constants.BRANDING_NAME} - ${engagementText} - ${photoCounter}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
headers.push(`<meta property="og:site_name" content="${siteName}"/>`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
headers.push(
|
headers.push(
|
||||||
|
|
|
@ -72,6 +72,7 @@ This is caused by Twitter API downtime or a new bug. Try again in a little while
|
||||||
TRANSLATE_TEXT: `═ ↘️ Translated from {language} ═════`,
|
TRANSLATE_TEXT: `═ ↘️ Translated from {language} ═════`,
|
||||||
TRANSLATE_TEXT_INTL: `═ ↘️ {source} ➡️ {destination} ═════`,
|
TRANSLATE_TEXT_INTL: `═ ↘️ {source} ➡️ {destination} ═════`,
|
||||||
PHOTO_COUNT: `Photo {number} of {total}`,
|
PHOTO_COUNT: `Photo {number} of {total}`,
|
||||||
|
VIDEO_COUNT: `Video {number} of {total}`,
|
||||||
|
|
||||||
SINGULAR_DAY_LEFT: 'day left',
|
SINGULAR_DAY_LEFT: 'day left',
|
||||||
PLURAL_DAYS_LEFT: 'days left',
|
PLURAL_DAYS_LEFT: 'days left',
|
||||||
|
|
Loading…
Add table
Reference in a new issue