fixed metadata fetch error

This commit is contained in:
stratuma 2024-06-20 23:11:59 +02:00
parent 932e089c06
commit a81379b375
4 changed files with 14 additions and 24 deletions

View File

@ -15,7 +15,7 @@
<option :value="10">Iphone (DRM PROTECTED)</option>
<option :value="11">Ipad (DRM PROTECTED)</option>
<option :value="12">Android (DRM PROTECTED)</option>
<option :value="13">Samsung TV (DRM PROTECTED) (Fastest)</option>
<option :value="13">Samsung TV (DRM PROTECTED)</option>
</select>
<div class="text-xs mt-2"> Fallback to non-drm stream if no widevine key provided </div>
</div>

View File

@ -805,29 +805,15 @@ export async function crunchyGetMetadata(q: string) {
'User-Agent': 'Crunchyroll/1.8.0 Nintendo Switch/12.3.12.0 UE4/4.27'
}
try {
const response = await fetch(`https://static.crunchyroll.com/skip-events/production/${q}.json`, {
method: 'GET',
headers: headers
})
const response = await fetch(`https://static.crunchyroll.com/skip-events/production/${q}.json`, {
method: 'GET',
headers: headers
})
if (response.ok) {
return (await JSON.parse(await response.text())) as VideoMetadata
} else {
const error = await response.text()
messageBox('error', ['Cancel'], 2, 'Failed to get Crunchyroll Metadata', 'Failed to get Crunchyroll Metadata', error)
server.logger.log({
level: 'error',
message: 'Failed to get Crunchyroll Metadata',
error: error,
timestamp: new Date().toISOString(),
section: 'metadataCrunchyrollFetch'
})
throw new Error(error)
}
} catch (e) {
throw new Error(e as string)
if (response.ok) {
return (await JSON.parse(await response.text())) as VideoMetadata
} else {
return null
}
}

View File

@ -703,6 +703,8 @@ export async function downloadCrunchyrollPlaylist(
const chapterDownload = async () => {
const metadata = await crunchyGetMetadata(e)
if (!metadata) return null
if (!metadata.intro && !metadata.credits && !metadata.preview && !metadata.recap) {
return null
}

View File

@ -22,5 +22,7 @@ contextBridge.exposeInMainWorld('myAPI', {
setEpisodeTemplate: (name: string) => ipcRenderer.invoke('dialog:setEpisodeTemplate', name),
getEpisodeTemplate: () => ipcRenderer.invoke('dialog:getEpisodeTemplate'),
setSeasonTemplate: (name: string) => ipcRenderer.invoke('dialog:setSeasonTemplate', name),
getSeasonTemplate: () => ipcRenderer.invoke('dialog:getSeasonTemplate')
getSeasonTemplate: () => ipcRenderer.invoke('dialog:getSeasonTemplate'),
setSeasonEnabled: (status: boolean) => ipcRenderer.invoke('dialog:setSeasonEnabledTemplate', status),
getSeasonEnabled: (status: boolean) => ipcRenderer.invoke('dialog:setSeasonEnabledTemplate', status),
})