diff --git a/.env.example b/.env.example index 6e437cd..0e17155 100644 --- a/.env.example +++ b/.env.example @@ -1,7 +1,7 @@ BRANDING_NAME = "FixTweet" BRANDING_NAME_DISCORD = "FixTweet by @dangeredwolf - Embed videos, polls & more!" DIRECT_MEDIA_DOMAINS = "d.fxtwitter.com,dl.fxtwitter.com,d.pxtwitter.com,d.twittpr.com,dl.pxtwitter.com,dl.twittpr.com" -MOSAIC_DOMAIN_LIST = "mosaic.pxtwitter.com" +MOSAIC_DOMAIN_LIST = "mosaic.fxtwitter.com" API_HOST = "api.fxtwitter.com" HOST_URL = "https://fxtwitter.com" REDIRECT_URL = "https://github.com/dangeredwolf/FixTweet" \ No newline at end of file diff --git a/src/api.ts b/src/api.ts index 01f3495..0ea6a54 100644 --- a/src/api.ts +++ b/src/api.ts @@ -80,14 +80,15 @@ const populateTweetProperties = async ( let mediaObject = processMedia(media); console.log('mediaObject', JSON.stringify(mediaObject)); if (mediaObject) { - apiTweet.twitter_card = 'summary_large_image'; if (mediaObject.type === 'photo') { + apiTweet.twitter_card = 'summary_large_image'; apiTweet.media = apiTweet.media || {}; apiTweet.media.photos = apiTweet.media.photos || []; apiTweet.media.photos.push(mediaObject); console.log('media', apiTweet.media); } else if (mediaObject.type === 'video' || mediaObject.type === 'gif') { + apiTweet.twitter_card = 'player'; apiTweet.media = apiTweet.media || {}; apiTweet.media.video = mediaObject as APIVideo; } @@ -98,7 +99,7 @@ const populateTweetProperties = async ( apiTweet.color = colorFromPalette(mediaList[0].ext_media_color.palette); } - if (apiTweet.media?.photos?.length || 0 > 1) { + if ((apiTweet.media?.photos?.length || 0) > 1) { let mosaic = await handleMosaic(apiTweet.media?.photos || []); if (typeof apiTweet.media !== 'undefined' && mosaic !== null) { apiTweet.media.mosaic = mosaic; diff --git a/src/status.ts b/src/status.ts index 0d21f8c..be9bcd4 100644 --- a/src/status.ts +++ b/src/status.ts @@ -68,6 +68,7 @@ export const handleStatus = async ( if (!tweet.media && tweet.quote?.media) { tweet.media = tweet.quote.media; + tweet.twitter_card = 'summary_large_image'; } let authorText = getAuthorText(tweet) || Strings.DEFAULT_AUTHOR_TEXT; @@ -87,8 +88,6 @@ export const handleStatus = async ( const { video } = tweet.media; headers.push( - `<meta name="twitter:image" content="${video.thumbnail_url}"/>`, - `<meta name="twitter:player:stream" content="${video.url}"/>`, `<meta name="twitter:player:stream:content_type" content="${video.format}"/>`, `<meta name="twitter:player:height" content="${video.height}"/>`, `<meta name="twitter:player:width" content="${video.width}"/>`, @@ -96,7 +95,8 @@ export const handleStatus = async ( `<meta name="og:video:secure_url" content="${video.url}"/>`, `<meta name="og:video:height" content="${video.height}"/>`, `<meta name="og:video:width" content="${video.width}"/>`, - `<meta name="og:video:type" content="${video.format}"/>` + `<meta name="og:video:type" content="${video.format}"/>`, + `<meta name="twitter:image" content="${video.thumbnail_url}"/>` ); } @@ -196,7 +196,8 @@ export const handleStatus = async ( headers.push( `<meta content="${tweet.author.name} (@${tweet.author.screen_name})" property="og:title"/>`, - `<meta content="${sanitizeText(newText)}" property="og:description"/>` + `<meta content="${sanitizeText(newText)}" property="og:description"/>`, + `<meta content="${siteName}" property="og:site_name"/>` ); /* Special reply handling if authorText is not overriden */