release: v0.4.0

This commit is contained in:
2026-05-18 05:11:57 +08:00
parent b758391861
commit da5bd01535
147 changed files with 8876 additions and 6941 deletions

View File

@@ -1,3 +1,4 @@
import { buildImageUrl, buildWebUrl, buildSearchUrl, buildDetailUrl } from './tmdb-api';
// Native fetch available in Node 20+
import { getDb } from '../database/database';
import { localTimestamp } from '../utils/time';
@@ -95,7 +96,7 @@ async function fetchFromTMDB(keyword: string, tmdbToken: string): Promise<Conten
let tvResults: any[] = [];
try {
const searchUrl = `https://api.themoviedb.org/3/search/movie?query=${encodeURIComponent(keyword)}&language=zh-CN&page=1`;
const searchUrl = buildSearchUrl('movie', keyword);
const searchResp = await fetch(searchUrl, {
headers: { 'Authorization': `Bearer ${tmdbToken}` },
signal: AbortSignal.timeout(8000),
@@ -111,7 +112,7 @@ async function fetchFromTMDB(keyword: string, tmdbToken: string): Promise<Conten
}
try {
const searchUrl = `https://api.themoviedb.org/3/search/tv?query=${encodeURIComponent(keyword)}&language=zh-CN&page=1`;
const searchUrl = buildSearchUrl('tv', keyword);
const searchResp = await fetch(searchUrl, {
headers: { 'Authorization': `Bearer ${tmdbToken}` },
signal: AbortSignal.timeout(8000),
@@ -212,7 +213,7 @@ async function fetchFromTMDB(keyword: string, tmdbToken: string): Promise<Conten
let tmdbId = best.id;
try {
const detailUrl = `https://api.themoviedb.org/3/${mediaType}/${tmdbId}?language=zh-CN&append_to_response=credits`;
const detailUrl = buildDetailUrl(mediaType as 'movie' | 'tv', tmdbId);
const detailResp = await fetch(detailUrl, {
headers: { 'Authorization': `Bearer ${tmdbToken}` },
signal: AbortSignal.timeout(8000),
@@ -248,10 +249,10 @@ async function fetchFromTMDB(keyword: string, tmdbToken: string): Promise<Conten
? (movie.runtime > 0 ? `${movie.runtime}分钟` : '')
: (movie.episode_run_time && movie.episode_run_time.length > 0 ? `每集${movie.episode_run_time[0]}分钟` : '');
const description = movie.overview ? movie.overview.substring(0, 200) : '';
const cover = movie.poster_path ? `https://image.tmdb.org/t/p/w500${movie.poster_path}` : '';
const cover = movie.poster_path ? buildImageUrl(movie.poster_path) : '';
// TMDB detail page URL
const tmdbUrl = `https://www.themoviedb.org/${mediaType}/${tmdbId}`;
const tmdbUrl = buildWebUrl(mediaType as 'movie' | 'tv', tmdbId);
// Generate tags from keyword + title
const tags = genTags({ keyword, title });
@@ -322,4 +323,4 @@ function safeParseTags(tagsStr: string | null | undefined): string[] {
} catch {
return [];
}
}
}