This commit is contained in:
stratuma 2024-05-24 01:48:11 +02:00
parent 0e9e3080f1
commit 0b967d5189
3 changed files with 82 additions and 81 deletions

View File

@ -131,11 +131,15 @@
<div class="text-xs">Dubs: {{ p.dub.map((t) => t.name).join(', ') }}</div>
<div class="text-xs mr-20">Subs: {{ p.sub.length !== 0 ? p.sub.map((t) => t.name).join(', ') : '-' }}</div>
<div class="absolute flex flex-col ml-auto gap-0.5 right-0 bottom-0">
<div v-if="p.totaldownloaded && p.status === 'downloading' || p.totaldownloaded && p.status === 'downloading video'" class="text-xs ml-auto"
<div v-if="(p.totaldownloaded && p.status === 'downloading') || (p.totaldownloaded && p.status === 'downloading video')" class="text-xs ml-auto"
>{{ (p.totaldownloaded / Math.pow(1024, 2)).toFixed(2) }} MB</div
>
<div v-if="p.partsleft && p.status === 'downloading' || p.totaldownloaded && p.status === 'downloading video'" class="text-xs ml-auto">{{ p.partsdownloaded }}/{{ p.partsleft }}</div>
<div v-if="p.downloadspeed && p.status === 'downloading' || p.totaldownloaded && p.status === 'downloading video'" class="text-xs ml-auto">{{ p.downloadspeed }} MB/s</div>
<div v-if="(p.partsleft && p.status === 'downloading') || (p.totaldownloaded && p.status === 'downloading video')" class="text-xs ml-auto"
>{{ p.partsdownloaded }}/{{ p.partsleft }}</div
>
<div v-if="(p.downloadspeed && p.status === 'downloading') || (p.totaldownloaded && p.status === 'downloading video')" class="text-xs ml-auto"
>{{ p.downloadspeed }} MB/s</div
>
</div>
<button @click="openFolder(p.installDir)" v-if="p.status === 'completed'" class="ml-auto h-9 w-9 hover:bg-[#ffffff2c] rounded-xl transition-all">
<Icon name="ph:folder-open" class="h-5 w-5 text-white" />

View File

@ -502,101 +502,98 @@ export async function crunchyGetPlaylist(q: string, geo: string | undefined) {
throw new Error(e as string)
}
if (isProxyActive)
if (isProxyActive) await deactivateVideoToken(q, playlist.token)
decrementPlaylistCounter()
await deactivateVideoToken(q, playlist.token)
decrementPlaylistCounter()
for (const p of proxies) {
if (p.code !== login.country) {
await incrementPlaylistCounter()
for (const p of proxies) {
if (p.code !== login.country) {
const logindata = await crunchyLogin(account.username, account.password, p.code)
await incrementPlaylistCounter()
if (!logindata) return
const logindata = await crunchyLogin(account.username, account.password, p.code)
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'
}
if (!logindata) return
const responseProx = await fetch(
`https://cr-play-service.prd.crunchyrollsvc.com/v1/${q}${
endpoints.find((e) => e.id === endpoint) ? endpoints.find((e) => e.id === endpoint)?.url : '/console/switch/play'
}`,
{
method: 'GET',
headers: headers
}
)
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'
if (responseProx.ok) {
const dataProx: VideoPlaylistNoGEO = JSON.parse(await responseProx.text())
dataProx.hardSubs = Object.values((dataProx as any).hardSubs)
dataProx.subtitles = Object.values((dataProx as any).subtitles)
for (const v of dataProx.versions) {
if (!playlist.versions.find((ver) => ver.guid === v.guid)) {
playlist.versions.push({ ...v, geo: p.code })
}
}
const responseProx = await fetch(
`https://cr-play-service.prd.crunchyrollsvc.com/v1/${q}${
endpoints.find((e) => e.id === endpoint) ? endpoints.find((e) => e.id === endpoint)?.url : '/console/switch/play'
}`,
{
method: 'GET',
headers: headers
for (const v of dataProx.subtitles) {
if (!playlist.subtitles.find((ver) => ver.language === v.language)) {
playlist.subtitles.push({ ...v, geo: p.code })
}
)
}
if (responseProx.ok) {
const dataProx: VideoPlaylistNoGEO = JSON.parse(await responseProx.text())
for (const v of dataProx.hardSubs) {
if (!playlist.hardSubs.find((ver) => ver.hlang === v.hlang)) {
playlist.hardSubs.push({ ...v, geo: p.code })
}
}
dataProx.hardSubs = Object.values((dataProx as any).hardSubs)
await deleteVideoToken(q, dataProx.token)
} else {
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)
dataProx.subtitles = Object.values((dataProx as any).subtitles)
for (const v of dataProx.versions) {
if (!playlist.versions.find((ver) => ver.guid === v.guid)) {
playlist.versions.push({ ...v, geo: p.code })
}
if (errorJSON && errorJSON.activeStreams && errorJSON.activeStreams.length !== 0) {
for (const e of errorJSON.activeStreams) {
await deleteVideoToken(e.contentId, e.token)
}
for (const v of dataProx.subtitles) {
if (!playlist.subtitles.find((ver) => ver.language === v.language)) {
playlist.subtitles.push({ ...v, geo: p.code })
}
}
for (const v of dataProx.hardSubs) {
if (!playlist.hardSubs.find((ver) => ver.hlang === v.hlang)) {
playlist.hardSubs.push({ ...v, geo: p.code })
}
}
await deleteVideoToken(q, dataProx.token)
} else {
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'
})
}
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'
})
}
}
}
}
await incrementPlaylistCounter()
await activateVideoToken(q, playlist.token)
await incrementPlaylistCounter()
await activateVideoToken(q, playlist.token)
return { data: playlist, account_id: login.account_id }
}

View File

@ -145,7 +145,7 @@ async function fetchAndPipe(url: string, stream: fs.WriteStream, index: number,
section: 'audiofragmentCrunchyrollFetch'
})
console.error(`Retrying fragment ${index} due to error:`, error)
await new Promise(resolve => setTimeout(resolve, 1000))
await new Promise((resolve) => setTimeout(resolve, 1000))
}
}