prettier linting

This commit is contained in:
stratuma 2024-05-20 02:44:14 +02:00
parent e07fc5ac6a
commit bc93a04c80
16 changed files with 118 additions and 124 deletions

View File

@ -4,8 +4,7 @@ import { getProxies } from './Proxy'
import type { CrunchyAnimeFetch, CrunchySearchFetch } from './Types' import type { CrunchyAnimeFetch, CrunchySearchFetch } from './Types'
export async function searchCrunchy(q: string) { export async function searchCrunchy(q: string) {
var isProxyActive: boolean | undefined
var isProxyActive: boolean | undefined;
;(window as any).myAPI.getProxyActive().then((result: boolean) => { ;(window as any).myAPI.getProxyActive().then((result: boolean) => {
isProxyActive = result isProxyActive = result
@ -71,13 +70,13 @@ export async function searchCrunchy(q: string) {
data.value?.data[0].items.push(r) data.value?.data[0].items.push(r)
} else { } else {
for (const l of r.series_metadata.audio_locales) { for (const l of r.series_metadata.audio_locales) {
if (!data.value.data[0].items.find(d => d.id === r.id)?.series_metadata.audio_locales.find(loc => loc === l)) { if (!data.value.data[0].items.find((d) => d.id === r.id)?.series_metadata.audio_locales.find((loc) => loc === l)) {
data.value.data[0].items.find(d => d.id === r.id)?.series_metadata.audio_locales.push(l) data.value.data[0].items.find((d) => d.id === r.id)?.series_metadata.audio_locales.push(l)
} }
} }
for (const l of r.series_metadata.subtitle_locales) { for (const l of r.series_metadata.subtitle_locales) {
if (!data.value.data[0].items.find(d => d.id === r.id)?.series_metadata.subtitle_locales.find(loc => loc === l)) { if (!data.value.data[0].items.find((d) => d.id === r.id)?.series_metadata.subtitle_locales.find((loc) => loc === l)) {
data.value.data[0].items.find(d => d.id === r.id)?.series_metadata.subtitle_locales.push(l) data.value.data[0].items.find((d) => d.id === r.id)?.series_metadata.subtitle_locales.push(l)
} }
} }
} }
@ -112,8 +111,7 @@ export async function searchCrunchy(q: string) {
} }
export async function getCRSeries(q: string) { export async function getCRSeries(q: string) {
var isProxyActive: boolean | undefined
var isProxyActive: boolean | undefined;
;(window as any).myAPI.getProxyActive().then((result: boolean) => { ;(window as any).myAPI.getProxyActive().then((result: boolean) => {
isProxyActive = result isProxyActive = result

View File

@ -3,7 +3,6 @@ import { getProxies } from './Proxy'
import type { CrunchySeasonsFetch } from './Types' import type { CrunchySeasonsFetch } from './Types'
export async function listSeasonCrunchy(q: string, geo: string | undefined) { export async function listSeasonCrunchy(q: string, geo: string | undefined) {
const { data: token, error: tokenerror } = await crunchyLogin(geo ? geo : 'LOCAL') const { data: token, error: tokenerror } = await crunchyLogin(geo ? geo : 'LOCAL')
if (!token.value) { if (!token.value) {

View File

@ -1,8 +1,8 @@
import type { Proxies } from "./Types" import type { Proxies } from './Types'
export async function getProxies() { export async function getProxies() {
const { data, error } = await useFetch<Proxies>('http://localhost:9941/api/service/proxies', { const { data, error } = await useFetch<Proxies>('http://localhost:9941/api/service/proxies', {
method: 'GET', method: 'GET'
}) })
return { data, error } return { data, error }

View File

@ -17,9 +17,7 @@
<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) (Fastest)</option>
</select> </select>
<div class="text-xs mt-2"> <div class="text-xs mt-2"> Fallback to non-drm stream if no widevine key provided </div>
Fallback to non-drm stream if no widevine key provided
</div>
</div> </div>
</div> </div>
</template> </template>
@ -38,7 +36,6 @@ const selectEndpoint = () => {
;(window as any).myAPI.selectEndpoint(selectedEndpoint.value) ;(window as any).myAPI.selectEndpoint(selectedEndpoint.value)
} }
} }
</script> </script>
<style> <style>

View File

@ -3,14 +3,10 @@
<div class="flex flex-col items-center p-3 bg-[#11111189] rounded-xl select-none"> <div class="flex flex-col items-center p-3 bg-[#11111189] rounded-xl select-none">
<div class="text-sm mb-2"> Proxy Settings </div> <div class="text-sm mb-2"> Proxy Settings </div>
<div class="flex flex-row"> <div class="flex flex-row">
<input v-model="isProxyLogin" @change="setProxyActive(isProxyLogin)" type="checkbox" name="Login Proxy" class="cursor-pointer"> <input v-model="isProxyLogin" @change="setProxyActive(isProxyLogin)" type="checkbox" name="Login Proxy" class="cursor-pointer" />
<div class="text-sm ml-1.5"> <div class="text-sm ml-1.5"> Use Login Proxies </div>
Use Login Proxies
</div>
</div>
<div class="text-xs mt-2">
Used for bypassing geoblocking
</div> </div>
<div class="text-xs mt-2"> Used for bypassing geoblocking </div>
</div> </div>
<div class="flex flex-col items-center p-3 bg-[#11111189] rounded-xl select-none gap-1" :class="fetchingProxies ? 'h-44' : 'h-auto'"> <div class="flex flex-col items-center p-3 bg-[#11111189] rounded-xl select-none gap-1" :class="fetchingProxies ? 'h-44' : 'h-auto'">
<div class="text-sm mb-2"> Global Proxies </div> <div class="text-sm mb-2"> Global Proxies </div>
@ -42,7 +38,7 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
const isProxyLogin = ref<boolean>(); const isProxyLogin = ref<boolean>()
const proxies = ref<{ name: string; url: string; status: string }[]>() const proxies = ref<{ name: string; url: string; status: string }[]>()
const fetchingProxies = ref<0>(0) const fetchingProxies = ref<0>(0)

View File

@ -46,11 +46,11 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
const pathL3Blob = ref<string>(); const pathL3Blob = ref<string>()
const pathL3Key = ref<string>(); const pathL3Key = ref<string>()
const pathL1Blob = ref<string>(); const pathL1Blob = ref<string>()
const pathL1Key = ref<string>(); const pathL1Key = ref<string>()
const getFilePathL3Blob = () => { const getFilePathL3Blob = () => {
if (process.client) { if (process.client) {
@ -88,21 +88,16 @@ onMounted(() => {
;(window as any).myAPI.getFile('l3blob').then((result: any) => { ;(window as any).myAPI.getFile('l3blob').then((result: any) => {
pathL3Blob.value = result pathL3Blob.value = result
}) })
;(window as any).myAPI.getFile('l3key').then((result: any) => { ;(window as any).myAPI.getFile('l3key').then((result: any) => {
pathL3Key.value = result pathL3Key.value = result
}) })
;(window as any).myAPI.getFile('l1blob').then((result: any) => { ;(window as any).myAPI.getFile('l1blob').then((result: any) => {
pathL1Blob.value = result pathL1Blob.value = result
}) })
;(window as any).myAPI.getFile('l1key').then((result: any) => { ;(window as any).myAPI.getFile('l1key').then((result: any) => {
pathL1Key.value = result pathL1Key.value = result
}) })
}) })
</script> </script>
<style></style> <style></style>

View File

@ -651,7 +651,7 @@ const switchToSeason = async () => {
if (dubLocales.value && dubLocales.value.length !== 0) { if (dubLocales.value && dubLocales.value.length !== 0) {
for (const a of dubLocales.value) { for (const a of dubLocales.value) {
if (CRselectedShow.value.Dubs.find(cr => cr === a.locale)) { if (CRselectedShow.value.Dubs.find((cr) => cr === a.locale)) {
toggleDub(a) toggleDub(a)
} }
} }
@ -661,7 +661,7 @@ const switchToSeason = async () => {
if (subLocales.value && subLocales.value.length !== 0) { if (subLocales.value && subLocales.value.length !== 0) {
for (const a of subLocales.value) { for (const a of subLocales.value) {
if (CRselectedShow.value.Subs.find(cr => cr === a.locale)) { if (CRselectedShow.value.Subs.find((cr) => cr === a.locale)) {
toggleSub(a) toggleSub(a)
} }
} }
@ -692,7 +692,7 @@ const switchToSeason = async () => {
if (dubLocales.value && dubLocales.value.length !== 0) { if (dubLocales.value && dubLocales.value.length !== 0) {
for (const a of dubLocales.value) { for (const a of dubLocales.value) {
if (CRselectedShow.value.Dubs.find(cr => cr === a.locale)) { if (CRselectedShow.value.Dubs.find((cr) => cr === a.locale)) {
toggleDub(a) toggleDub(a)
} }
} }
@ -702,7 +702,7 @@ const switchToSeason = async () => {
if (subLocales.value && subLocales.value.length !== 0) { if (subLocales.value && subLocales.value.length !== 0) {
for (const a of subLocales.value) { for (const a of subLocales.value) {
if (CRselectedShow.value.Subs.find(cr => cr === a.locale)) { if (CRselectedShow.value.Subs.find((cr) => cr === a.locale)) {
toggleSub(a) toggleSub(a)
} }
} }

View File

@ -68,7 +68,9 @@
<div class="text-xs">Dubs: {{ p.dub.map((t) => t.name).join(', ') }}</div> <div class="text-xs">Dubs: {{ p.dub.map((t) => t.name).join(', ') }}</div>
<div class="text-xs mr-14">Subs: {{ p.sub.length !== 0 ? p.sub.map((t) => t.name).join(', ') : '-' }}</div> <div class="text-xs mr-14">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 class="absolute flex flex-col ml-auto gap-0.5 right-0 bottom-0">
<div v-if="p.totaldownloaded && p.status === 'downloading'" class="text-xs ml-auto">{{ (p.totaldownloaded / Math.pow(1024, 2)).toFixed(2) }} MB</div> <div v-if="p.totaldownloaded && p.status === 'downloading'" class="text-xs ml-auto"
>{{ (p.totaldownloaded / Math.pow(1024, 2)).toFixed(2) }} MB</div
>
<div v-if="p.partsleft && p.status === 'downloading'" class="text-xs ml-auto">{{ p.partsdownloaded }}/{{ p.partsleft }}</div> <div v-if="p.partsleft && p.status === 'downloading'" class="text-xs ml-auto">{{ p.partsdownloaded }}/{{ p.partsleft }}</div>
<div v-if="p.downloadspeed && p.status === 'downloading'" class="text-xs ml-auto">{{ p.downloadspeed }} MB/s</div> <div v-if="p.downloadspeed && p.status === 'downloading'" class="text-xs ml-auto">{{ p.downloadspeed }} MB/s</div>
</div> </div>

View File

@ -2,12 +2,14 @@ import type { FastifyReply, FastifyRequest } from 'fastify'
import { crunchyLogin } from './crunchyroll.service' import { crunchyLogin } from './crunchyroll.service'
import { loggedInCheck } from '../service/service.service' import { loggedInCheck } from '../service/service.service'
export async function loginController(request: FastifyRequest<{ export async function loginController(
Querystring: { request: FastifyRequest<{
geo: string Querystring: {
} geo: string
}>, reply: FastifyReply) { }
}>,
reply: FastifyReply
) {
const query = request.query const query = request.query
const account = await loggedInCheck('CR') const account = await loggedInCheck('CR')

View File

@ -112,7 +112,6 @@ export async function crunchyLogin(user: string, passw: string, geo: string) {
// Crunchyroll Login Fetch Proxy // Crunchyroll Login Fetch Proxy
async function crunchyLoginFetchProxy(user: string, passw: string, geo: string) { async function crunchyLoginFetchProxy(user: string, passw: string, geo: string) {
const proxies = await checkProxies() const proxies = await checkProxies()
var host: string | undefined var host: string | undefined
@ -206,15 +205,14 @@ async function crunchyLoginFetch(user: string, passw: string) {
// Crunchyroll Playlist Fetch // Crunchyroll Playlist Fetch
export async function crunchyGetPlaylist(q: string, geo: string | undefined) { export async function crunchyGetPlaylist(q: string, geo: string | undefined) {
const isProxyActive = await settings.get('proxyActive') const isProxyActive = await settings.get('proxyActive')
var proxies: { var proxies: {
name: string; name: string
code: string; code: string
url: string; url: string
status: string | undefined; status: string | undefined
}[] = []; }[] = []
if (isProxyActive) { if (isProxyActive) {
proxies = await checkProxies() proxies = await checkProxies()
@ -344,55 +342,54 @@ export async function crunchyGetPlaylist(q: string, geo: string | undefined) {
} }
if (isProxyActive) if (isProxyActive)
for (const p of proxies) {
if (p.code !== loginLocal.country) {
const { data: login, error } = await crunchyLogin(account.username, account.password, p.code)
for (const p of proxies) { if (!login) return
if (p.code !== loginLocal.country) {
const { data: login, error } = await crunchyLogin(account.username, account.password, p.code)
if (!login) return const headers = {
Authorization: `Bearer ${login.access_token}`,
const headers = { 'X-Cr-Disable-Drm': 'true'
Authorization: `Bearer ${login.access_token}`,
'X-Cr-Disable-Drm': 'true'
}
const response = 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
} }
)
if (response.ok) { const response = await fetch(
const data: VideoPlaylistNoGEO = JSON.parse(await response.text()) `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'
data.hardSubs = Object.values((data as any).hardSubs) }`,
{
data.subtitles = Object.values((data as any).subtitles) method: 'GET',
headers: headers
for (const v of data.versions) {
if (!playlist.versions.find((ver) => ver.guid === v.guid)) {
playlist.versions.push({ ...v, geo: p.code })
} }
} )
for (const v of data.subtitles) { if (response.ok) {
if (!playlist.subtitles.find((ver) => ver.language === v.language)) { const data: VideoPlaylistNoGEO = JSON.parse(await response.text())
playlist.subtitles.push({ ...v, geo: p.code })
data.hardSubs = Object.values((data as any).hardSubs)
data.subtitles = Object.values((data as any).subtitles)
for (const v of data.versions) {
if (!playlist.versions.find((ver) => ver.guid === v.guid)) {
playlist.versions.push({ ...v, geo: p.code })
}
} }
}
for (const v of data.hardSubs) { for (const v of data.subtitles) {
if (!playlist.hardSubs.find((ver) => ver.hlang === v.hlang)) { if (!playlist.subtitles.find((ver) => ver.language === v.language)) {
playlist.hardSubs.push({ ...v, geo: p.code }) playlist.subtitles.push({ ...v, geo: p.code })
}
}
for (const v of data.hardSubs) {
if (!playlist.hardSubs.find((ver) => ver.hlang === v.hlang)) {
playlist.hardSubs.push({ ...v, geo: p.code })
}
} }
} }
} }
} }
}
return { data: playlist, account_id: loginLocal.account_id } return { data: playlist, account_id: loginLocal.account_id }
} }

View File

@ -52,7 +52,7 @@ export async function getNetflixMetadata(id: string) {
drmSystem: 'widevine', drmSystem: 'widevine',
isWatchlistEnabled: 'false', isWatchlistEnabled: 'false',
isShortformEnabled: 'false', isShortformEnabled: 'false',
isVolatileBillboardsEnabled: 'false', isVolatileBillboardsEnabled: 'false'
} }
const querystring = new URLSearchParams(params) const querystring = new URLSearchParams(params)

View File

@ -135,31 +135,35 @@ export async function getPlaylistController(request: FastifyRequest, reply: Fast
return reply.code(200).send(playlist.reverse()) return reply.code(200).send(playlist.reverse())
} }
export async function checkProxiesController( export async function checkProxiesController(request: FastifyRequest, reply: FastifyReply) {
request: FastifyRequest, const cachedData = server.CacheController.get('proxycheck')
reply: FastifyReply
) {
const cachedData = server.CacheController.get('proxycheck');
if (!cachedData) { if (!cachedData) {
const proxies: { name: string, code: string, url: string, status: string | undefined }[] = [{ const proxies: { name: string; code: string; url: string; status: string | undefined }[] = [
name: 'US Proxy', code: 'US', url: 'https://us-proxy.crd.cx/', status: undefined {
}, name: 'US Proxy',
{ code: 'US',
name: 'UK Proxy', code: 'GB', url: 'https://uk-proxy.crd.cx/', status: undefined url: 'https://us-proxy.crd.cx/',
}, status: undefined
{ },
name: 'DE Proxy', code: 'DE', url: 'https://de-proxy.crd.cx/', status: undefined {
}] name: 'UK Proxy',
code: 'GB',
url: 'https://uk-proxy.crd.cx/',
status: undefined
},
{
name: 'DE Proxy',
code: 'DE',
url: 'https://de-proxy.crd.cx/',
status: undefined
}
]
for (const p of proxies) { for (const p of proxies) {
const response = await fetch( const response = await fetch(p.url + 'health', {
p.url + 'health', method: 'GET'
{ })
method: 'GET',
}
)
if (response.ok) { if (response.ok) {
p.status = 'online' p.status = 'online'

View File

@ -1,5 +1,13 @@
import { FastifyInstance } from 'fastify' import { FastifyInstance } from 'fastify'
import { addPlaylistController, checkLoginController, checkProxiesController, deleteAccountHandler, getAllAccountsHandler, getPlaylistController, loginController } from './service.controller' import {
addPlaylistController,
checkLoginController,
checkProxiesController,
deleteAccountHandler,
getAllAccountsHandler,
getPlaylistController,
loginController
} from './service.controller'
async function serviceRoutes(server: FastifyInstance) { async function serviceRoutes(server: FastifyInstance) {
server.post( server.post(

View File

@ -3,8 +3,8 @@ import settings from 'electron-settings'
import path from 'path' import path from 'path'
export async function getWVKPath() { export async function getWVKPath() {
const drmL3blob = await settings.get('l3blob') as string const drmL3blob = (await settings.get('l3blob')) as string
const drmL3key = await settings.get('l3key') as string const drmL3key = (await settings.get('l3key')) as string
if (!drmL3blob || !drmL3key) { if (!drmL3blob || !drmL3key) {
return return

View File

@ -116,7 +116,7 @@ export interface VideoPlaylist {
hardSubs: Array<{ hardSubs: Array<{
hlang: string hlang: string
url: string url: string
quality: string, quality: string
geo: string | undefined geo: string | undefined
}> }>
playbackType: string playbackType: string
@ -132,7 +132,7 @@ export interface VideoPlaylist {
subtitles: Array<{ subtitles: Array<{
format: string format: string
language: string language: string
url: string, url: string
geo: string | undefined geo: string | undefined
}> }>
token: string token: string
@ -144,7 +144,7 @@ export interface VideoPlaylist {
media_guid: string media_guid: string
original: boolean original: boolean
season_guid: string season_guid: string
variant: string, variant: string
geo: string | undefined geo: string | undefined
}> }>
geo: string | undefined geo: string | undefined

View File

@ -186,7 +186,6 @@ ipcMain.handle('dialog:getEndpoint', async (events, nr: number) => {
}) })
ipcMain.handle('dialog:defaultFile', async (events, type: string) => { ipcMain.handle('dialog:defaultFile', async (events, type: string) => {
if (!type) return if (!type) return
const savedPath = await settings.get(type) const savedPath = await settings.get(type)
@ -199,7 +198,6 @@ ipcMain.handle('dialog:defaultFile', async (events, type: string) => {
}) })
ipcMain.handle('dialog:defaultArray', async (events, type: string) => { ipcMain.handle('dialog:defaultArray', async (events, type: string) => {
if (!type) return if (!type) return
const savedPath = await settings.get(type) const savedPath = await settings.get(type)
@ -224,7 +222,6 @@ ipcMain.handle('dialog:defaultArraySetDub', async (events, va: Array<any>) => {
}) })
ipcMain.handle('dialog:proxyActive', async (events) => { ipcMain.handle('dialog:proxyActive', async (events) => {
const savedStat = await settings.get('proxyActive') const savedStat = await settings.get('proxyActive')
if (!savedStat) { if (!savedStat) {
@ -236,7 +233,6 @@ ipcMain.handle('dialog:proxyActive', async (events) => {
}) })
ipcMain.handle('dialog:proxyActiveSet', async (events, status: boolean) => { ipcMain.handle('dialog:proxyActiveSet', async (events, status: boolean) => {
await settings.set('proxyActive', status) await settings.set('proxyActive', status)
return status return status