diff --git a/components/search/VideoCard.tsx b/components/search/VideoCard.tsx index 562382a..4bf8d5a 100644 --- a/components/search/VideoCard.tsx +++ b/components/search/VideoCard.tsx @@ -10,6 +10,7 @@ import { LatencyBadge } from '@/components/ui/LatencyBadge'; import { FavoriteButton } from '@/components/favorites/FavoriteButton'; import { Video } from '@/lib/types'; +import { parseVideoTitle } from '@/lib/utils/video'; interface VideoCardProps { video: Video; @@ -139,17 +140,36 @@ export const VideoCard = memo(({ {/* Info */} -
-

- {video.vod_remarks && ( - [{video.vod_remarks}] - )} - {video.vod_name} -

+
+ {(() => { + const { cleanTitle, quality } = parseVideoTitle(video.vod_name); + // Visual priority: Quality from title tag, then vod_remarks + const displayQuality = quality || video.vod_remarks; + + return ( + <> +

+ {cleanTitle} +

+ {displayQuality && ( +

+ {displayQuality} +

+ )} + {/* Hide remarks if it was used as quality to avoid duplication */} + {video.vod_remarks && video.vod_remarks !== displayQuality && ( +

+ {video.vod_remarks} +

+ )} + + ); + })()}
- - -
+ + + + ); }); diff --git a/lib/utils/video.ts b/lib/utils/video.ts new file mode 100644 index 0000000..e5c3a33 --- /dev/null +++ b/lib/utils/video.ts @@ -0,0 +1,27 @@ +/** + * Parses a video title to extract quality tags (e.g., [HD], [TS]) + * and return a cleaned title. + */ +export function parseVideoTitle(title: string): { cleanTitle: string, quality?: string } { + // Regex to match tags in brackets at the start of the title + // Example: "[HD] 利刃出鞘3" -> quality: "HD", cleanTitle: "利刃出鞘3" + // Example: "利刃出鞘3 [HD]" -> quality: "HD", cleanTitle: "利刃出鞘3" + + const bracketRegex = /\[([^\]]+)\]/g; + let quality: string | undefined; + let cleanTitle = title; + + const matches = [...title.matchAll(bracketRegex)]; + + if (matches.length > 0) { + // Take the first bracket content as quality (usually what we want) + quality = matches[0][1]; + // Remove all brackets and their content from the title + cleanTitle = title.replace(bracketRegex, '').trim(); + } + + return { + cleanTitle: cleanTitle || title, + quality + }; +} diff --git a/package-lock.json b/package-lock.json index 926346e..ed5aa40 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "kvideo", - "version": "3.6.0", + "version": "3.7.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "kvideo", - "version": "3.6.0", + "version": "3.7.0", "dependencies": { "@dnd-kit/core": "^6.3.1", "@dnd-kit/sortable": "^10.0.0", diff --git a/package.json b/package.json index 28d0d2e..d355594 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kvideo", - "version": "3.6.0", + "version": "3.7.0", "private": true, "scripts": { "dev": "next dev",