feat: Update nhiều thứ

This commit is contained in:
ngthanhvu
2026-07-28 21:55:39 -04:00
parent 72bc657d86
commit 1c92c0d50b
14 changed files with 173 additions and 129 deletions
+25
View File
@@ -0,0 +1,25 @@
function extractEpisodeNumber(value?: string): number {
if (!value) return 0
const match = value.match(/(\d+)(?:\/\d+)?\s*$/)
if (!match) {
const anyNumber = value.match(/\d+/)
return anyNumber ? Number(anyNumber[0]) : 0
}
return Number(match[1])
}
export function getEpisodeDisplay(
episode?: string,
episodeTotal?: string,
): string | undefined {
if (!episode) return undefined
const totalNum = extractEpisodeNumber(episodeTotal)
const epNum = extractEpisodeNumber(episode)
if (totalNum > 0 && epNum > 0 && epNum !== totalNum) {
return `Tập ${epNum}/${totalNum}`
}
return episode
}