Skip to content

Commit 950b05f

Browse files
committed
feat: Improve episode parsing in parsePlayUrl to handle missing names and provide default Chinese episode names.
1 parent 772e377 commit 950b05f

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

lib/api/parsers.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,23 @@ export function parseEpisodes(playUrl: string): Episode[] {
1515
const episodes = playUrl.split('#').filter(Boolean);
1616

1717
return episodes.map((episode, index) => {
18-
const [name, url] = episode.split('$');
18+
const parts = episode.split('$');
19+
let name: string, url: string;
20+
21+
if (parts.length > 1) {
22+
name = parts[0];
23+
url = parts[1];
24+
} else {
25+
// If no '$' separator, treat the whole thing as the URL
26+
url = parts[0];
27+
name = `第 ${index + 1} 集`;
28+
}
29+
1930
// Clean up URL: remove double slashes but keep protocol (http:// or https://)
2031
const cleanUrl = (url || '').replace(/([^:])\/\//g, '$1/');
32+
2133
return {
22-
name: name || `Episode ${index + 1}`,
34+
name: name || ` ${index + 1}`,
2335
url: cleanUrl,
2436
index,
2537
};
@@ -29,3 +41,4 @@ export function parseEpisodes(playUrl: string): Episode[] {
2941
return [];
3042
}
3143
}
44+

0 commit comments

Comments
 (0)