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'
export async function searchCrunchy(q: string) {
var isProxyActive: boolean | undefined;
var isProxyActive: boolean | undefined
;(window as any).myAPI.getProxyActive().then((result: boolean) => {
isProxyActive = result
@ -71,13 +70,13 @@ export async function searchCrunchy(q: string) {
data.value?.data[0].items.push(r)
} else {
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)) {
data.value.data[0].items.find(d => d.id === r.id)?.series_metadata.audio_locales.push(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)
}
}
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)) {
data.value.data[0].items.find(d => d.id === r.id)?.series_metadata.subtitle_locales.push(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)
}
}
}
@ -112,8 +111,7 @@ export async function searchCrunchy(q: string) {
}
export async function getCRSeries(q: string) {
var isProxyActive: boolean | undefined;
var isProxyActive: boolean | undefined
;(window as any).myAPI.getProxyActive().then((result: boolean) => {
isProxyActive = result

View File

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

View File

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

View File

@ -17,9 +17,7 @@
<option :value="12">Android (DRM PROTECTED)</option>
<option :value="13">Samsung TV (DRM PROTECTED) (Fastest)</option>
</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>
</template>
@ -38,7 +36,6 @@ const selectEndpoint = () => {
;(window as any).myAPI.selectEndpoint(selectedEndpoint.value)
}
}
</script>
<style>

View File

@ -3,14 +3,10 @@
<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="flex flex-row">
<input v-model="isProxyLogin" @change="setProxyActive(isProxyLogin)" type="checkbox" name="Login Proxy" class="cursor-pointer">
<div class="text-sm ml-1.5">
Use Login Proxies
</div>
</div>
<div class="text-xs mt-2">
Used for bypassing geoblocking
<input v-model="isProxyLogin" @change="setProxyActive(isProxyLogin)" type="checkbox" name="Login Proxy" class="cursor-pointer" />
<div class="text-sm ml-1.5"> Use Login Proxies </div>
</div>
<div class="text-xs mt-2"> Used for bypassing geoblocking </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="text-sm mb-2"> Global Proxies </div>
@ -42,7 +38,7 @@
</template>
<script lang="ts" setup>
const isProxyLogin = ref<boolean>();
const isProxyLogin = ref<boolean>()
const proxies = ref<{ name: string; url: string; status: string }[]>()
const fetchingProxies = ref<0>(0)

View File

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

View File

@ -651,7 +651,7 @@ const switchToSeason = async () => {
if (dubLocales.value && dubLocales.value.length !== 0) {
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)
}
}
@ -661,7 +661,7 @@ const switchToSeason = async () => {
if (subLocales.value && subLocales.value.length !== 0) {
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)
}
}
@ -692,7 +692,7 @@ const switchToSeason = async () => {
if (dubLocales.value && dubLocales.value.length !== 0) {
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)
}
}
@ -702,7 +702,7 @@ const switchToSeason = async () => {
if (subLocales.value && subLocales.value.length !== 0) {
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)
}
}

View File

@ -68,7 +68,9 @@
<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="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.downloadspeed && p.status === 'downloading'" class="text-xs ml-auto">{{ p.downloadspeed }} MB/s</div>
</div>

View File

@ -2,12 +2,14 @@ import type { FastifyReply, FastifyRequest } from 'fastify'
import { crunchyLogin } from './crunchyroll.service'
import { loggedInCheck } from '../service/service.service'
export async function loginController(request: FastifyRequest<{
Querystring: {
geo: string
}
}>, reply: FastifyReply) {
export async function loginController(
request: FastifyRequest<{
Querystring: {
geo: string
}
}>,
reply: FastifyReply
) {
const query = request.query
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
async function crunchyLoginFetchProxy(user: string, passw: string, geo: string) {
const proxies = await checkProxies()
var host: string | undefined
@ -206,15 +205,14 @@ async function crunchyLoginFetch(user: string, passw: string) {
// Crunchyroll Playlist Fetch
export async function crunchyGetPlaylist(q: string, geo: string | undefined) {
const isProxyActive = await settings.get('proxyActive')
var proxies: {
name: string;
code: string;
url: string;
status: string | undefined;
}[] = [];
name: string
code: string
url: string
status: string | undefined
}[] = []
if (isProxyActive) {
proxies = await checkProxies()
@ -344,55 +342,54 @@ export async function crunchyGetPlaylist(q: string, geo: string | undefined) {
}
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 (p.code !== loginLocal.country) {
const { data: login, error } = await crunchyLogin(account.username, account.password, p.code)
if (!login) return
if (!login) return
const headers = {
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
const headers = {
Authorization: `Bearer ${login.access_token}`,
'X-Cr-Disable-Drm': 'true'
}
)
if (response.ok) {
const data: VideoPlaylistNoGEO = JSON.parse(await response.text())
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 })
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
}
}
)
for (const v of data.subtitles) {
if (!playlist.subtitles.find((ver) => ver.language === v.language)) {
playlist.subtitles.push({ ...v, geo: p.code })
if (response.ok) {
const data: VideoPlaylistNoGEO = JSON.parse(await response.text())
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) {
if (!playlist.hardSubs.find((ver) => ver.hlang === v.hlang)) {
playlist.hardSubs.push({ ...v, geo: p.code })
for (const v of data.subtitles) {
if (!playlist.subtitles.find((ver) => ver.language === v.language)) {
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 }
}

View File

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

View File

@ -135,41 +135,45 @@ export async function getPlaylistController(request: FastifyRequest, reply: Fast
return reply.code(200).send(playlist.reverse())
}
export async function checkProxiesController(
request: FastifyRequest,
reply: FastifyReply
) {
const cachedData = server.CacheController.get('proxycheck');
export async function checkProxiesController(request: FastifyRequest, reply: FastifyReply) {
const cachedData = server.CacheController.get('proxycheck')
if (!cachedData) {
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: '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
}]
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: '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) {
const response = await fetch(
p.url + 'health',
{
method: 'GET',
}
)
const response = await fetch(p.url + 'health', {
method: 'GET'
})
if (response.ok) {
p.status = 'online'
} else {
p.status = 'offline'
}
}
server.CacheController.set('proxycheck', proxies, 60)
return reply.code(200).send(proxies)
}

View File

@ -1,5 +1,13 @@
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) {
server.post(

View File

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

View File

@ -116,7 +116,7 @@ export interface VideoPlaylist {
hardSubs: Array<{
hlang: string
url: string
quality: string,
quality: string
geo: string | undefined
}>
playbackType: string
@ -132,7 +132,7 @@ export interface VideoPlaylist {
subtitles: Array<{
format: string
language: string
url: string,
url: string
geo: string | undefined
}>
token: string
@ -144,7 +144,7 @@ export interface VideoPlaylist {
media_guid: string
original: boolean
season_guid: string
variant: string,
variant: string
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) => {
if (!type) return
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) => {
if (!type) return
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) => {
const savedStat = await settings.get('proxyActive')
if (!savedStat) {
@ -236,7 +233,6 @@ ipcMain.handle('dialog:proxyActive', async (events) => {
})
ipcMain.handle('dialog:proxyActiveSet', async (events, status: boolean) => {
await settings.set('proxyActive', status)
return status