added audio download failed status
This commit is contained in:
parent
7e255b6fcc
commit
fd480009c9
@ -56,7 +56,10 @@
|
||||
<Icon name="mdi:loading" class="h-3.5 w-3.5 text-white animate-spin" />
|
||||
{{ p.status }}
|
||||
</div>
|
||||
<div v-if="p.status === 'downloading video'" class="flex flex-row items-center justify-center gap-1 text-xs capitalize p-1.5 bg-[#60501b] rounded-lg">
|
||||
<div
|
||||
v-if="p.status === 'downloading video'"
|
||||
class="flex flex-row items-center justify-center gap-1 text-xs capitalize p-1.5 bg-[#60501b] rounded-lg"
|
||||
>
|
||||
<Icon name="mdi:loading" class="h-3.5 w-3.5 text-white animate-spin" />
|
||||
{{ p.status }}
|
||||
</div>
|
||||
@ -94,12 +97,19 @@
|
||||
</div>
|
||||
<div v-for="a in p.audiosdownloading">
|
||||
<div
|
||||
v-if="a.status && a.audio && a.status !== 'finished'"
|
||||
v-if="a.status && a.audio && a.status !== 'finished' && a.status !== 'failed'"
|
||||
class="ml-2 flex flex-row items-center justify-center gap-1 text-xs capitalize p-1.5 bg-[#866332] rounded-lg"
|
||||
>
|
||||
<Icon name="mdi:loading" class="h-3.5 w-3.5 text-white animate-spin" />
|
||||
{{ a.status }} Audio {{ a.audio }}
|
||||
</div>
|
||||
<div
|
||||
v-if="a.status && a.audio && a.status === 'failed'"
|
||||
class="flex flex-row items-center justify-center gap-1 text-xs capitalize p-1.5 bg-[#863232] rounded-lg"
|
||||
>
|
||||
<Icon name="bitcoin-icons:cross-filled" class="h-3.5 w-3.5 text-white" />
|
||||
{{ a.status }} Audio {{ a.audio }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -445,6 +445,38 @@ export async function crunchyGetPlaylist(q: string, geo: string | undefined) {
|
||||
playlist = data
|
||||
} else {
|
||||
const error = await response.text()
|
||||
const errorJSON: {
|
||||
activeStreams: {
|
||||
accountId: string
|
||||
active: boolean
|
||||
assetId: string
|
||||
clientId: string
|
||||
contentId: string
|
||||
country: string
|
||||
createdTimestamp: string
|
||||
deviceSubtype: string
|
||||
deviceType: string
|
||||
episodeIdentity: string
|
||||
id: string
|
||||
token: string
|
||||
}[]
|
||||
} = await JSON.parse(error)
|
||||
|
||||
if (errorJSON && errorJSON.activeStreams && errorJSON.activeStreams.length !== 0) {
|
||||
for (const e of errorJSON.activeStreams) {
|
||||
await deleteVideoToken(e.contentId, e.token)
|
||||
}
|
||||
|
||||
server.logger.log({
|
||||
level: 'error',
|
||||
message: 'Refetching Crunchyroll Video Playlist & Deleting all Video Token because too many streams',
|
||||
error: errorJSON,
|
||||
timestamp: new Date().toISOString(),
|
||||
section: 'playlistCrunchyrollFetch'
|
||||
})
|
||||
|
||||
return await crunchyGetPlaylist(q, geo)
|
||||
}
|
||||
|
||||
messageBox('error', ['Cancel'], 2, 'Failed to get Crunchyroll Video Playlist', 'Failed to get Crunchyroll Video Playlist', error)
|
||||
server.logger.log({
|
||||
@ -512,7 +544,38 @@ export async function crunchyGetPlaylist(q: string, geo: string | undefined) {
|
||||
|
||||
await deleteVideoToken(q, dataProx.token)
|
||||
} else {
|
||||
decrementPlaylistCounter();
|
||||
decrementPlaylistCounter()
|
||||
const error = await responseProx.text()
|
||||
const errorJSON: {
|
||||
activeStreams: {
|
||||
accountId: string
|
||||
active: boolean
|
||||
assetId: string
|
||||
clientId: string
|
||||
contentId: string
|
||||
country: string
|
||||
createdTimestamp: string
|
||||
deviceSubtype: string
|
||||
deviceType: string
|
||||
episodeIdentity: string
|
||||
id: string
|
||||
token: string
|
||||
}[]
|
||||
} = await JSON.parse(error)
|
||||
|
||||
if (errorJSON && errorJSON.activeStreams && errorJSON.activeStreams.length !== 0) {
|
||||
for (const e of errorJSON.activeStreams) {
|
||||
await deleteVideoToken(e.contentId, e.token)
|
||||
}
|
||||
|
||||
server.logger.log({
|
||||
level: 'error',
|
||||
message: 'Refetching Crunchyroll Video Playlist & Deleting all Video Token because too many streams',
|
||||
error: errorJSON,
|
||||
timestamp: new Date().toISOString(),
|
||||
section: 'playlistCrunchyrollFetch'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ export async function downloadMPDAudio(
|
||||
while (!downloadSuccess) {
|
||||
try {
|
||||
const stream = fs.createWriteStream(`${path}/${part.filename}`)
|
||||
await fetchAndPipe(part.url, stream, index + 1)
|
||||
await fetchAndPipe(part.url, stream, index + 1, downloadID, name)
|
||||
downloadSuccess = true
|
||||
} catch (error) {
|
||||
retries++
|
||||
@ -73,12 +73,18 @@ export async function downloadMPDAudio(
|
||||
return await mergePartsAudio(parts, path, dir, name, downloadID, drmkeys)
|
||||
}
|
||||
|
||||
async function fetchAndPipe(url: string, stream: fs.WriteStream, index: number) {
|
||||
async function fetchAndPipe(url: string, stream: fs.WriteStream, index: number, downloadID: number, name: string) {
|
||||
try {
|
||||
|
||||
const dn = downloading.find((i) => i.id === downloadID && i.audio === name)
|
||||
|
||||
const response = await fetch(url)
|
||||
|
||||
// Check if fetch was successful
|
||||
if (!response.ok) {
|
||||
if (dn) {
|
||||
dn.status = 'failed'
|
||||
}
|
||||
server.logger.log({
|
||||
level: 'error',
|
||||
message: 'Error while downloading an Audio Fragment',
|
||||
@ -94,6 +100,9 @@ async function fetchAndPipe(url: string, stream: fs.WriteStream, index: number)
|
||||
|
||||
// Check if the body exists and is readable
|
||||
if (!body) {
|
||||
if (dn) {
|
||||
dn.status = 'failed'
|
||||
}
|
||||
server.logger.log({
|
||||
level: 'error',
|
||||
message: 'Error while downloading an Audio Fragment',
|
||||
@ -115,6 +124,9 @@ async function fetchAndPipe(url: string, stream: fs.WriteStream, index: number)
|
||||
resolve()
|
||||
})
|
||||
.on('error', (error) => {
|
||||
if (dn) {
|
||||
dn.status = 'failed'
|
||||
}
|
||||
server.logger.log({
|
||||
level: 'error',
|
||||
message: 'Error while downloading an Audio Fragment',
|
||||
|
Reference in New Issue
Block a user