Skip to content

Commit

Permalink
feat: show # of pictures in slideshow and stop using player for images
Browse files Browse the repository at this point in the history
  • Loading branch information
okdargy committed Jan 24, 2024
1 parent d62e5f6 commit c9e533c
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 10 deletions.
9 changes: 5 additions & 4 deletions src/templates/pages/VideoResponse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function VideoResponse(data: AwemeList): JSX.Element {
},
{
name: 'twitter:card',
content: 'player'
content: `${data.video.duration !== 0 ? 'player' : 'summary_large_image'}`
},
{
name: 'twitter:site',
Expand All @@ -36,7 +36,7 @@ export function VideoResponse(data: AwemeList): JSX.Element {
},
{
name: 'og:description',
content: data.desc
content: data.video.duration !== 0 ? data.desc : null
},
{
name: `og:${data.video.duration !== 0 ? 'video' : 'image'}`,
Expand All @@ -57,12 +57,13 @@ export function VideoResponse(data: AwemeList): JSX.Element {
{
name: `og:${data.video.duration !== 0 ? 'video' : 'image'}:height`,
content: `${data.video.duration !== 0 ? data.video.height : data.video.cover.height}`
}
},
], {
likes: data.statistics.digg_count,
comments: data.statistics.comment_count,
shares: data.statistics.share_count,
unique_id: data.author.unique_id
unique_id: data.author.unique_id,
images: data.image_post_info ? data.image_post_info.images.length : 0
})
}
</>
Expand Down
39 changes: 39 additions & 0 deletions src/types/Services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export interface AwemeList {
products_info: null;
follow_up_publish_from_id: number;
disable_search_trending_bar: boolean;
image_post_info?: ImagePostInfo;
music_begin_time_in_ms: number;
music_end_time_in_ms?: number;
item_distribute_source: string;
Expand Down Expand Up @@ -598,3 +599,41 @@ export interface TikTokAPIResponseLogInfo {
export interface LogPb {
impr_id: string;
}

export interface Image {
display_image: {
uri: string;
url_list: string[];
width: number;
height: number;
url_prefix: string | null;
}
owner_watermark_image: {
uri: string;
url_list: string[];
width: number;
height: number;
url_prefix: string | null;
},
user_watermark_image: {
uri: string;
url_list: string[];
width: number;
height: number;
url_prefix: string | null;
},
thumbnail: {
uri: string;
url_list: string[];
width: number;
height: number;
url_prefix: string | null;
},
bitratre_images: string | null
}

export interface ImagePostInfo {
images: Image[];
image_post_cover: Image[];
post_extra: String
}
9 changes: 5 additions & 4 deletions src/util/MetaHelper.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
export default function MetaHelper(tags: {
name: string,
content: string,
content: string | null,
}[], alternate?: {
likes: number,
comments: number,
shares: number
unique_id: string
unique_id: string,
images: number
}): JSX.Element {
return (
<html lang="en">
<head>
{tags.map((tag) => (
<meta property={tag.name} content={tag.content} />
tag.content ? <meta property={tag.name} content={tag.content} /> : null
))}
{
alternate ? (
<link rel="alternate" href={`https://fxtiktok-rewrite.dargy.workers.dev/generate/alternate?likes=${alternate.likes}&comments=${alternate.comments}&shares=${alternate.shares}&unique_id=${encodeURIComponent(alternate.unique_id)}`} type="application/json+oembed" />
<link rel="alternate" href={`https://fxtiktok-rewrite.dargy.workers.dev/generate/alternate?likes=${alternate.likes}&comments=${alternate.comments}&shares=${alternate.shares}&unique_id=${encodeURIComponent(alternate.unique_id)}${alternate.images > 0 ? '&images=' + alternate.images : ''}`} type="application/json+oembed" />
) : null
}
</head>
Expand Down
4 changes: 2 additions & 2 deletions src/util/generateAlternate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ export default function generateAlternate(c: Context): {
provider_url: string
title: string
} {
const { likes, comments, shares, unique_id } = c.req.query()
const { likes, comments, shares, unique_id, images } = c.req.query()

return {
"version": "1.0",
"type": "link",
"author_name": `❤️ ${formatNumber(likes)} 💬 ${formatNumber(comments)} 📤 ${formatNumber(shares)}`,
"author_name": `❤️ ${formatNumber(likes)} 💬 ${formatNumber(comments)} 📤 ${formatNumber(shares)} ${images ? '🖼️ ' + images : ''}`,
"provider_name": 'fxTikTok',
"provider_url": "https://tnktok.com",
"title": `TikTok by @${unique_id}`
Expand Down

0 comments on commit c9e533c

Please sign in to comment.