diff --git a/src/status.ts b/src/status.ts
index 34cc550..29fbeab 100644
--- a/src/status.ts
+++ b/src/status.ts
@@ -49,10 +49,11 @@ export const handleStatus = async (
if (flags?.direct && tweet.media) {
let redirectUrl: string | null = null;
- if (tweet.media.video) {
- redirectUrl = tweet.media.video.url;
+ if (tweet.media.videos) {
+ const { videos } = tweet.media;
+ redirectUrl = (videos[(mediaNumber || 1) - 1] || videos[0]).url;
} else if (tweet.media.photos) {
- const photos = tweet.media.photos;
+ const { photos } = tweet.media;
redirectUrl = (photos[(mediaNumber || 1) - 1] || photos[0]).url;
}
if (redirectUrl) {
@@ -68,7 +69,7 @@ export const handleStatus = async (
let authorText = getAuthorText(tweet) || Strings.DEFAULT_AUTHOR_TEXT;
const engagementText = authorText.replace(/ {4}/g, ' ');
- const siteName = Constants.BRANDING_NAME;
+ let siteName = Constants.BRANDING_NAME;
let newText = tweet.text;
const headers = [
@@ -102,14 +103,15 @@ export const handleStatus = async (
}
/* Video renderer */
- if (tweet.media?.video) {
+ if (tweet.media?.videos) {
authorText = newText || '';
if (tweet?.translation) {
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
disliking videos that are too large lol */
@@ -123,6 +125,24 @@ export const handleStatus = async (
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(``);
+
headers.push(
``,
``,
@@ -160,15 +180,13 @@ export const handleStatus = async (
authorText =
authorText === Strings.DEFAULT_AUTHOR_TEXT
? photoCounter
- : `${authorText} ― ${photoCounter}`;
+ : `${authorText}${authorText ? ' ― ' : ''}${photoCounter}`;
- let siteName = `${Constants.BRANDING_NAME} - ${photoCounter}`;
+ siteName = `${Constants.BRANDING_NAME} - ${photoCounter}`;
if (engagementText) {
siteName = `${Constants.BRANDING_NAME} - ${engagementText} - ${photoCounter}`;
}
-
- headers.push(``);
}
headers.push(
diff --git a/src/strings.ts b/src/strings.ts
index bb3b0dd..55cd7b7 100644
--- a/src/strings.ts
+++ b/src/strings.ts
@@ -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_INTL: `═ ↘️ {source} ➡️ {destination} ═════`,
PHOTO_COUNT: `Photo {number} of {total}`,
+ VIDEO_COUNT: `Video {number} of {total}`,
SINGULAR_DAY_LEFT: 'day left',
PLURAL_DAYS_LEFT: 'days left',