added default crunchyroll language selector

This commit is contained in:
stratuma 2024-06-21 16:27:58 +02:00
parent be4fd91f74
commit d9fe95dd25
7 changed files with 128 additions and 6 deletions

View File

@ -5,9 +5,14 @@ import type { CrunchyAnimeFetch, CrunchyEpisodeFetch, CrunchyEpisodesFetch, Crun
export async function searchCrunchy(q: string) {
var isProxyActive: boolean | undefined
var selectedLanguage: string | undefined
;(window as any).myAPI.getProxyActive().then((result: boolean) => {
isProxyActive = result
})
;(window as any).myAPI.getDefaultCrunchyrollLanguage().then((result: string) => {
selectedLanguage = result
})
var proxies
@ -32,7 +37,9 @@ export async function searchCrunchy(q: string) {
q: q,
n: 100,
type: 'series',
ratings: false
ratings: false,
preferred_audio_language: selectedLanguage,
locale: selectedLanguage
}
})
@ -61,7 +68,9 @@ export async function searchCrunchy(q: string) {
q: q,
n: 100,
type: 'series',
ratings: false
ratings: false,
preferred_audio_language: selectedLanguage,
locale: selectedLanguage
}
})
@ -119,9 +128,14 @@ export async function searchCrunchy(q: string) {
export async function getCRSeries(q: string) {
var isProxyActive: boolean | undefined
var selectedLanguage: string | undefined
;(window as any).myAPI.getProxyActive().then((result: boolean) => {
isProxyActive = result
})
;(window as any).myAPI.getDefaultCrunchyrollLanguage().then((result: string) => {
selectedLanguage = result
})
var proxies
@ -141,6 +155,10 @@ export async function getCRSeries(q: string) {
method: 'GET',
headers: {
Authorization: `Bearer ${token.value.access_token}`
},
query: {
preferred_audio_language: selectedLanguage,
locale: selectedLanguage
}
})
@ -162,6 +180,10 @@ export async function getCRSeries(q: string) {
method: 'GET',
headers: {
Authorization: `Bearer ${tokeng.value.access_token}`
},
query: {
preferred_audio_language: selectedLanguage,
locale: selectedLanguage
}
})
@ -201,9 +223,14 @@ export async function getCRSeries(q: string) {
export async function getCREpisodeSeriesID(q: string) {
var isProxyActive: boolean | undefined
var selectedLanguage: string | undefined
;(window as any).myAPI.getProxyActive().then((result: boolean) => {
isProxyActive = result
})
;(window as any).myAPI.getDefaultCrunchyrollLanguage().then((result: string) => {
selectedLanguage = result
})
var proxies
@ -223,6 +250,10 @@ export async function getCREpisodeSeriesID(q: string) {
method: 'GET',
headers: {
Authorization: `Bearer ${token.value.access_token}`
},
query: {
preferred_audio_language: selectedLanguage,
locale: selectedLanguage
}
})
@ -244,6 +275,10 @@ export async function getCREpisodeSeriesID(q: string) {
method: 'GET',
headers: {
Authorization: `Bearer ${tokeng.value.access_token}`
},
query: {
preferred_audio_language: selectedLanguage,
locale: selectedLanguage
}
})

View File

@ -2,6 +2,13 @@ import { crunchyLogin } from './Account'
import type { CrunchyEpisodesFetch } from './Types'
export async function listEpisodeCrunchy(q: string, geo: string | undefined) {
var selectedLanguage: string | undefined
;(window as any).myAPI.getDefaultCrunchyrollLanguage().then((result: string) => {
selectedLanguage = result
})
const { data: token, error: tokenerror } = await crunchyLogin(geo ? geo : 'LOCAL')
if (!token.value) {
@ -12,6 +19,10 @@ export async function listEpisodeCrunchy(q: string, geo: string | undefined) {
method: 'GET',
headers: {
Authorization: `Bearer ${token.value.access_token}`
},
query: {
preferred_audio_language: selectedLanguage,
locale: selectedLanguage
}
})

View File

@ -3,6 +3,13 @@ import { getProxies } from './Proxy'
import type { CrunchySeasonsFetch } from './Types'
export async function listSeasonCrunchy(q: string, geo: string | undefined) {
var selectedLanguage: string | undefined
;(window as any).myAPI.getDefaultCrunchyrollLanguage().then((result: string) => {
selectedLanguage = result
})
const { data: token, error: tokenerror } = await crunchyLogin(geo ? geo : 'LOCAL')
if (!token.value) {
@ -13,6 +20,10 @@ export async function listSeasonCrunchy(q: string, geo: string | undefined) {
method: 'GET',
headers: {
Authorization: `Bearer ${token.value.access_token}`
},
query: {
preferred_audio_language: selectedLanguage,
locale: selectedLanguage
}
})

View File

@ -1,5 +1,22 @@
<template>
<div class="flex flex-col gap-3 mt-3 font-dm" style="-webkit-app-region: no-drag">
<div class="flex flex-col items-center p-3 bg-[#11111189] rounded-xl select-none">
<div class="text-sm mb-2">Default Language</div>
<select v-model="selectedLanguage" @change="selectLanguage()" class="bg-[#5c5b5b] w-full focus:outline-none px-3 py-2 rounded-xl text-sm text-center cursor-pointer">
<option value="en-US">English</option>
<option value="de-DE">Deutsch</option>
<option value="it-IT">Italiano</option>
<option value="es-419">Español</option>
<option value="es-ES">Español (España)</option>
<option value="fr-FR">Français (France)</option>
<option value="pt-BR">Português (Brasil)</option>
<option value="pt-PT">Português (Portugal)</option>
<option value="ru-RU">Русский</option>
<option value="ar-SA">العربية</option>
<option value="hi-IN">ि</option>
</select>
<div class="text-xs mt-2"> For search, series and episode name </div>
</div>
<div class="flex flex-col items-center p-3 bg-[#11111189] rounded-xl select-none">
<div class="text-sm mb-2">Stream Endpoint</div>
<select v-model="selectedEndpoint" @change="selectEndpoint()" class="bg-[#5c5b5b] w-full focus:outline-none px-3 py-2 rounded-xl text-sm text-center cursor-pointer">
@ -23,13 +40,24 @@
</template>
<script lang="ts" setup>
const selectedLanguage = ref<string>()
const selectedEndpoint = ref<number>()
onMounted(() => {
;(window as any).myAPI.getEndpoint().then((result: any) => {
selectedEndpoint.value = result
})
;(window as any).myAPI.getDefaultCrunchyrollLanguage().then((result: any) => {
selectedLanguage.value = result
})
})
const selectLanguage = () => {
if (process.client) {
;(window as any).myAPI.setDefaultCrunchyrollLanguage(selectedLanguage.value)
}
}
const selectEndpoint = () => {
if (process.client) {

View File

@ -187,7 +187,7 @@
<div v-if="service === 'adn' && ADNselectedShow" class="relative flex flex-col select-none">
<div @click="selectDub ? (selectDub = false) : (selectDub = true)" class="bg-[#5c5b5b] focus:outline-none px-3 py-2 rounded-xl text-sm text-center cursor-pointer">
Dubs:
{{ selectedDubs.map((t) => t.name).join(', ') }}
{{ selectedDubs.length !== 0 ? selectedDubs.map((t) => t.name).join(', ') : 'No Dubs selected' }}
</div>
<div v-if="selectDub" class="absolute top-full left-0 w-full bg-[#868585] rounded-xl grid grid-cols-12 gap-1 p-1 z-10">
<button
@ -292,10 +292,18 @@
<option :value="480" class="text-sm text-slate-200">480p</option>
</select>
</div>
<div v-if="service === 'crunchyroll'" class="relative flex flex-col w-full">
<select v-model="qualityaudio" name="format" class="bg-[#5c5b5b] focus:outline-none px-3 py-2 rounded-xl text-sm text-center cursor-pointer">
<option :value="1" class="text-sm text-slate-200">44.10 kHz</option>
<option :value="2" class="text-sm text-slate-200">44.10 kHz (2)</option>
<option :value="3" class="text-sm text-slate-200">22.05 kHz</option>
</select>
</div>
<div class="relative flex flex-col w-full">
<select v-model="format" name="format" class="bg-[#5c5b5b] focus:outline-none px-3 py-2 rounded-xl text-sm text-center cursor-pointer">
<option value="mp4" class="text-sm text-slate-200">MP4</option>
<option value="mkv" class="text-sm text-slate-200">MKV</option>
<option value="mp4" class="text-sm text-slate-200">MP4</option>
<option value="untouched" class="text-sm text-slate-200">Untouched</option>
</select>
</div>
</div>
@ -410,7 +418,8 @@ const hardsub = ref<boolean>(false)
const added = ref<boolean>(false)
const isHardsubDisabled = ref<boolean>(true)
const quality = ref<1080 | 720 | 480 | 360 | 240>(1080)
const format = ref<'mp4' | 'mkv'>('mkv')
const qualityaudio = ref<1 | 2 | 3>(1)
const format = ref<'mp4' | 'mkv' | 'untouched'>('mkv')
const isFetchingSeasons = ref<number>(0)
const isFetchingEpisodes = ref<number>(0)
@ -837,6 +846,7 @@ const addToPlaylist = async () => {
dir: path.value,
hardsub: hardsub.value,
quality: quality.value,
qualityaudio: qualityaudio.value,
service: 'CR',
format: format.value
}

View File

@ -334,6 +334,25 @@ ipcMain.handle('dialog:getSeasonTemplate', async (events) => {
return seTP
})
ipcMain.handle('dialog:setDefaultCrunchyrollLanguageTemplate', async (events, lang: string) => {
await settings.set('CrunchyrollDefaultLanguage', lang)
return lang
})
ipcMain.handle('dialog:getDefaultCrunchyrollLanguageTemplate', async (events) => {
const seTP = await settings.get('CrunchyrollDefaultLanguage')
if (!seTP) {
await settings.set('CrunchyrollDefaultLanguage', 'en-US')
return 'en-US'
}
return seTP
})
const openWindows = new Map()
// Open New Window

View File

@ -24,5 +24,13 @@ contextBridge.exposeInMainWorld('myAPI', {
setSeasonTemplate: (name: string) => ipcRenderer.invoke('dialog:setSeasonTemplate', name),
getSeasonTemplate: () => ipcRenderer.invoke('dialog:getSeasonTemplate'),
setSeasonEnabled: (active: boolean) => ipcRenderer.invoke('dialog:setSeasonEnabledTemplate', active),
getSeasonEnabled: () => ipcRenderer.invoke('dialog:getSeasonEnabledTemplate')
getSeasonEnabled: () => ipcRenderer.invoke('dialog:getSeasonEnabledTemplate'),
// setDefaultVideoQuality: (quality: number) => ipcRenderer.invoke('dialog:setDefaultVideoQualityTemplate', quality),
// getDefaultVideoQuality: () => ipcRenderer.invoke('dialog:getDefaultVideoQualityTemplate'),
// setDefaultAudioQuality: (quality: number) => ipcRenderer.invoke('dialog:setDefaultAudioQualityTemplate', quality),
// getDefaultAudioQuality: () => ipcRenderer.invoke('dialog:getDefaultAudioQualityTemplate'),
// setDefaultOutputFormat: (format: string) => ipcRenderer.invoke('dialog:setDefaultOutputFormatTemplate', format),
// getDefaultOutputFormat: () => ipcRenderer.invoke('dialog:getDefaultOutputFormatTemplate'),
setDefaultCrunchyrollLanguage: (lang: string) => ipcRenderer.invoke('dialog:setDefaultCrunchyrollLanguageTemplate', lang),
getDefaultCrunchyrollLanguage: () => ipcRenderer.invoke('dialog:getDefaultCrunchyrollLanguageTemplate')
})