Revert "Allow serving HEVC for Telegram since it supports it"

This reverts commit 71c73e503c.
This commit is contained in:
dangered wolf 2024-03-11 20:53:58 -04:00
parent 5771af2df3
commit df109e84c5
No known key found for this signature in database
GPG key ID: 41E4D37680ED8B58
2 changed files with 5 additions and 7 deletions

View file

@ -1,7 +1,5 @@
import { Context } from "hono";
/* Help populate API response for media */
export const processMedia = (c: Context, media: TweetMedia): APIPhoto | APIVideo | null => {
export const processMedia = (media: TweetMedia): APIPhoto | APIVideo | null => {
if (media.type === 'photo') {
return {
type: 'photo',
@ -13,7 +11,7 @@ export const processMedia = (c: Context, media: TweetMedia): APIPhoto | APIVideo
} else if (media.type === 'video' || media.type === 'animated_gif') {
/* Find the variant with the highest bitrate */
const bestVariant = media.video_info?.variants?.reduce?.((a, b) =>
(c.req.header('User-Agent')?.includes('Telegram') || !a.url.includes('/hevc/')) && (a.bitrate ?? 0) > (b.bitrate ?? 0) ? a : b
!a.url.includes('/hevc/') && (a.bitrate ?? 0) > (b.bitrate ?? 0) ? a : b
);
return {
url: bestVariant?.url || '',

View file

@ -171,7 +171,7 @@ export const buildAPITwitterStatus = async (
/* Populate status media */
mediaList.forEach(media => {
const mediaObject = processMedia(c, media);
const mediaObject = processMedia(media);
if (mediaObject) {
apiStatus.media.all = apiStatus.media?.all ?? [];
apiStatus.media?.all?.push(mediaObject);
@ -234,7 +234,7 @@ export const buildAPITwitterStatus = async (
if (card.media) {
if (card.media.videos) {
card.media.videos.forEach(video => {
const mediaObject = processMedia(c, video) as APIVideo;
const mediaObject = processMedia(video) as APIVideo;
if (mediaObject) {
apiStatus.media.all = apiStatus.media?.all ?? [];
apiStatus.media?.all?.push(mediaObject);
@ -245,7 +245,7 @@ export const buildAPITwitterStatus = async (
}
if (card.media.photos) {
card.media.photos.forEach(photo => {
const mediaObject = processMedia(c, photo) as APIPhoto;
const mediaObject = processMedia(photo) as APIPhoto;
if (mediaObject) {
apiStatus.media.all = apiStatus.media?.all ?? [];
apiStatus.media?.all?.push(mediaObject);