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="10">Iphone (DRM PROTECTED)</option>
<option :value="11">Ipad (DRM PROTECTED)</option> <option :value="11">Ipad (DRM PROTECTED)</option>
<option :value="12">Android (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> </select>
<div class="text-xs mt-2"> Fallback to non-drm stream if no widevine key provided </div> <div class="text-xs mt-2"> Fallback to non-drm stream if no widevine key provided </div>
</div> </div>

View File

@ -805,7 +805,6 @@ export async function crunchyGetMetadata(q: string) {
'User-Agent': 'Crunchyroll/1.8.0 Nintendo Switch/12.3.12.0 UE4/4.27' '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`, { const response = await fetch(`https://static.crunchyroll.com/skip-events/production/${q}.json`, {
method: 'GET', method: 'GET',
headers: headers headers: headers
@ -814,20 +813,7 @@ export async function crunchyGetMetadata(q: string) {
if (response.ok) { if (response.ok) {
return (await JSON.parse(await response.text())) as VideoMetadata return (await JSON.parse(await response.text())) as VideoMetadata
} else { } else {
const error = await response.text() return null
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)
} }
} }

View File

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

View File

@ -22,5 +22,7 @@ contextBridge.exposeInMainWorld('myAPI', {
setEpisodeTemplate: (name: string) => ipcRenderer.invoke('dialog:setEpisodeTemplate', name), setEpisodeTemplate: (name: string) => ipcRenderer.invoke('dialog:setEpisodeTemplate', name),
getEpisodeTemplate: () => ipcRenderer.invoke('dialog:getEpisodeTemplate'), getEpisodeTemplate: () => ipcRenderer.invoke('dialog:getEpisodeTemplate'),
setSeasonTemplate: (name: string) => ipcRenderer.invoke('dialog:setSeasonTemplate', name), 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),
}) })