chapters fix and removed useless request headers
This commit is contained in:
parent
3ed664132c
commit
fdf76f1ef1
@ -419,8 +419,6 @@ export async function crunchyGetPlaylist(q: string, geo: string | undefined) {
|
||||
|
||||
const headersLoc = {
|
||||
Authorization: `Bearer ${login.access_token}`,
|
||||
'X-Cr-Disable-Drm': 'true',
|
||||
'x-cr-stream-limits': 'false',
|
||||
'User-Agent': 'Crunchyroll/1.8.0 Nintendo Switch/12.3.12.0 UE4/4.27'
|
||||
}
|
||||
|
||||
@ -515,7 +513,6 @@ export async function crunchyGetPlaylist(q: string, geo: string | undefined) {
|
||||
|
||||
const headers = {
|
||||
Authorization: `Bearer ${logindata.access_token}`,
|
||||
'X-Cr-Disable-Drm': 'true',
|
||||
'User-Agent': 'Crunchyroll/1.8.0 Nintendo Switch/12.3.12.0 UE4/4.27'
|
||||
}
|
||||
|
||||
|
@ -715,7 +715,7 @@ export async function downloadCrunchyrollPlaylist(
|
||||
return null
|
||||
}
|
||||
|
||||
const chapterPath = await createChapterFile(metadata, chapterFolder, format)
|
||||
const chapterPath = await createChapterFile(metadata, chapterFolder, format, e)
|
||||
|
||||
return chapterPath
|
||||
}
|
||||
@ -1101,7 +1101,7 @@ export async function downloadCrunchyrollPlaylist(
|
||||
await deleteFolder(videoFolder)
|
||||
await deleteFolder(subFolder)
|
||||
await deleteFolder(audioFolder)
|
||||
await deleteFolder(chapterFolder)
|
||||
// await deleteFolder(chapterFolder)
|
||||
|
||||
return playlist
|
||||
}
|
||||
|
@ -7,44 +7,61 @@ function formatTimeFFMPEG(seconds: number) {
|
||||
return seconds * 1000
|
||||
}
|
||||
|
||||
export async function createChapterFile(rawchapters: VideoMetadata, dir: string, format: string) {
|
||||
async function createChapter(chapter: VideoMetadataSingle, format: string, name: string) {
|
||||
var chapters: string[] = []
|
||||
if (format === 'mkv') {
|
||||
chapters.push('[CHAPTER]')
|
||||
chapters.push('TIMEBASE=1/1000')
|
||||
chapters.push(`START=${formatTimeFFMPEG(chapter.start)}`)
|
||||
chapters.push(`END=${formatTimeFFMPEG(chapter.start)}`)
|
||||
chapters.push(`title=${name}`)
|
||||
chapters.push(``)
|
||||
chapters.push('[CHAPTER]')
|
||||
chapters.push('TIMEBASE=1/1000')
|
||||
chapters.push(`START=${formatTimeFFMPEG(chapter.end)}`)
|
||||
chapters.push(`END=${formatTimeFFMPEG(chapter.end)}`)
|
||||
chapters.push(`title=${name} End`)
|
||||
chapters.push(``)
|
||||
} else {
|
||||
chapters.push('[CHAPTER]')
|
||||
chapters.push('TIMEBASE=1/1000')
|
||||
chapters.push(`START=${formatTimeFFMPEG(chapter.start)}`)
|
||||
chapters.push(`END=${formatTimeFFMPEG(chapter.end)}`)
|
||||
chapters.push(`title=${name}`)
|
||||
chapters.push(``)
|
||||
}
|
||||
|
||||
return chapters
|
||||
}
|
||||
|
||||
export async function createChapterFile(rawchapters: VideoMetadata, dir: string, format: string, mediaid: string) {
|
||||
const filepath = path.join(dir, 'chapters.txt')
|
||||
|
||||
var chapters: string[] = []
|
||||
|
||||
const addChapter = (chapter: VideoMetadataSingle) => {
|
||||
if (format === 'mkv') {
|
||||
chapters.push('[CHAPTER]')
|
||||
chapters.push('TIMEBASE=1/1000')
|
||||
chapters.push(`START=${formatTimeFFMPEG(chapter.start)}`)
|
||||
chapters.push(`title=${chapter.title}`)
|
||||
chapters.push('[CHAPTER]')
|
||||
chapters.push('TIMEBASE=1/1000')
|
||||
chapters.push(`START=${formatTimeFFMPEG(chapter.end)}`)
|
||||
chapters.push(`title=Chapter`)
|
||||
} else {
|
||||
chapters.push('[CHAPTER]')
|
||||
chapters.push('TIMEBASE=1/1000')
|
||||
chapters.push(`START=${formatTimeFFMPEG(chapter.start)}`)
|
||||
chapters.push(`END=${formatTimeFFMPEG(chapter.end)}`)
|
||||
chapters.push(`title=${chapter.title}`)
|
||||
}
|
||||
}
|
||||
chapters.push(';FFMETADATA1')
|
||||
chapters.push(`title=${mediaid}`)
|
||||
chapters.push(`artist=Crunchyroll`)
|
||||
chapters.push(``)
|
||||
|
||||
if (rawchapters.intro && rawchapters.intro.type && rawchapters.intro.start && rawchapters.intro.end) {
|
||||
addChapter(rawchapters.intro)
|
||||
chapters.push(...await createChapter(rawchapters.intro, format, 'Intro'));
|
||||
console.log(chapters)
|
||||
}
|
||||
|
||||
if (rawchapters.credits && rawchapters.credits.type && rawchapters.credits.start && rawchapters.credits.end) {
|
||||
addChapter(rawchapters.credits)
|
||||
chapters.push(...await createChapter(rawchapters.credits, format, 'Credits'));
|
||||
console.log(chapters)
|
||||
}
|
||||
|
||||
if (rawchapters.preview && rawchapters.preview.type && rawchapters.preview.start && rawchapters.preview.end) {
|
||||
addChapter(rawchapters.preview)
|
||||
chapters.push(...await createChapter(rawchapters.preview, format, 'Preview'));
|
||||
console.log(chapters)
|
||||
}
|
||||
|
||||
if (rawchapters.recap && rawchapters.recap.type && rawchapters.recap.start && rawchapters.recap.end) {
|
||||
addChapter(rawchapters.recap)
|
||||
chapters.push(...await createChapter(rawchapters.recap, format, 'Recap'));
|
||||
console.log(chapters)
|
||||
}
|
||||
|
||||
try {
|
||||
|
Reference in New Issue
Block a user