mirror of
https://github.com/jackwener/OpenCLI.git
synced 2026-09-14 18:25:42 +08:00
ab44d9f542
* fix(xiaoyuzhou): migrate from broken SSR scraping to authenticated API (fixes #1023) Xiaoyuzhou removed SSR rendering — /podcast/<id> and /episode/<id> pages now return 404, breaking fetchPageProps() which scraped __NEXT_DATA__. Migrate podcast, podcast-episodes, episode, and download commands to use the existing authenticated API client (requestXiaoyuzhouJson) that transcript.js already uses successfully. Changes: - podcast.js: use /v1/podcast/get API endpoint - podcast-episodes.js: use /v1/podcast/listEpisode API endpoint - episode.js: use /v1/episode/get API endpoint - download.js: use /v1/episode/get API endpoint - utils.js: remove unused fetchPageProps, keep format helpers - Update all affected tests (download.test.js, utils.test.js) - Change strategy from PUBLIC to LOCAL (requires credentials) * fix(xiaoyuzhou): align local strategy contract * fix(xiaoyuzhou): align local api metadata --------- Co-authored-by: jackwener <jakevingoo@gmail.com>
16 lines
528 B
JavaScript
16 lines
528 B
JavaScript
/** Format seconds to mm:ss (e.g. 3890 → "64:50"). Returns '-' for invalid input. */
|
|
export function formatDuration(seconds) {
|
|
if (!Number.isFinite(seconds) || seconds < 0)
|
|
return '-';
|
|
seconds = Math.round(seconds);
|
|
const m = Math.floor(seconds / 60);
|
|
const s = seconds % 60;
|
|
return `${m}:${String(s).padStart(2, '0')}`;
|
|
}
|
|
/** Format ISO date string to YYYY-MM-DD. Returns '-' for missing input. */
|
|
export function formatDate(iso) {
|
|
if (!iso)
|
|
return '-';
|
|
return iso.slice(0, 10);
|
|
}
|