fixed default sub dub selector
This commit is contained in:
parent
56865e767d
commit
fc1323351b
@ -25,7 +25,7 @@
|
||||
v-for="l in locales"
|
||||
@click="toggleDub(l)"
|
||||
class="flex flex-row items-center justify-center gap-3 py-2 rounded-xl text-sm"
|
||||
:class="dubLocales && dubLocales.find((i) => i.locale === l.locale) ? 'bg-[#424242]' : 'hover:bg-[#747474]'"
|
||||
:class="dubLocales && dubLocales.length !== 0 && dubLocales.find((i) => i.locale === l.locale) ? 'bg-[#424242]' : 'hover:bg-[#747474]'"
|
||||
>
|
||||
{{ l.name }}
|
||||
</button>
|
||||
@ -38,7 +38,7 @@
|
||||
v-for="l in locales"
|
||||
@click="toggleSub(l)"
|
||||
class="flex flex-row items-center justify-center gap-3 py-2 rounded-xl text-sm"
|
||||
:class="subLocales && subLocales.find((i) => i.locale === l.locale) ? 'bg-[#424242]' : 'hover:bg-[#747474]'"
|
||||
:class="subLocales && subLocales.length !== 0 && subLocales.find((i) => i.locale === l.locale) ? 'bg-[#424242]' : 'hover:bg-[#747474]'"
|
||||
>
|
||||
{{ l.name }}
|
||||
</button>
|
||||
@ -79,11 +79,20 @@ const toggleDub = (lang: { locale: string; name: string }) => {
|
||||
|
||||
if (index !== -1) {
|
||||
dubLocales.value.splice(index, 1)
|
||||
if (process.client) {
|
||||
;(window as any).myAPI.setArrayDub(JSON.stringify(dubLocales.value))
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if (index === -1) {
|
||||
dubLocales.value.push(lang)
|
||||
|
||||
if (process.client) {
|
||||
;(window as any).myAPI.setArrayDub(JSON.stringify(dubLocales.value))
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -93,16 +102,19 @@ const toggleSub = (lang: { locale: string; name: string }) => {
|
||||
|
||||
if (index !== -1) {
|
||||
subLocales.value.splice(index, 1)
|
||||
;(window as any).myAPI.setArraySub(JSON.stringify(subLocales.value))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if (index === -1) {
|
||||
subLocales.value.push(lang)
|
||||
;(window as any).myAPI.setArraySub(JSON.stringify(subLocales.value))
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const services = ref<{ name: string; service: string }[]>([
|
||||
{
|
||||
name: 'Crunchyroll',
|
||||
@ -148,14 +160,12 @@ const deleteAccount = async (id: number) => {
|
||||
|
||||
onMounted(() => {
|
||||
;(window as any).myAPI.getArray('defdubarray').then((result: any) => {
|
||||
dubLocales.value = result
|
||||
dubLocales.value = JSON.parse(result)
|
||||
})
|
||||
|
||||
;(window as any).myAPI.getFile('defsubarray').then((result: any) => {
|
||||
subLocales.value = result
|
||||
;(window as any).myAPI.getArray('defsubarray').then((result: any) => {
|
||||
subLocales.value = JSON.parse(result)
|
||||
})
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<style></style>
|
||||
|
@ -381,6 +381,8 @@ const locales = ref<Array<{ locale: string; name: string }>>([
|
||||
const isProduction = process.env.NODE_ENV !== 'development'
|
||||
const selectDub = ref<boolean>(false)
|
||||
const selectedDubs = ref<Array<{ name: string | undefined; locale: string }>>([{ locale: 'ja-JP', name: 'JP' }])
|
||||
const dubLocales = ref<Array<{ locale: string; name: string }>>([])
|
||||
const subLocales = ref<Array<{ locale: string; name: string }>>([])
|
||||
|
||||
const selectSub = ref<boolean>(false)
|
||||
const selectedSubs = ref<Array<{ name: string | undefined; locale: string }>>([])
|
||||
@ -525,6 +527,12 @@ onMounted(() => {
|
||||
;(window as any).myAPI.getFolder().then((result: any) => {
|
||||
path.value = result
|
||||
})
|
||||
;(window as any).myAPI.getArray('defdubarray').then((result: any) => {
|
||||
dubLocales.value = JSON.parse(result)
|
||||
})
|
||||
;(window as any).myAPI.getArray('defsubarray').then((result: any) => {
|
||||
subLocales.value = JSON.parse(result)
|
||||
})
|
||||
})
|
||||
|
||||
const getFolderPath = () => {
|
||||
@ -637,8 +645,29 @@ const switchToSeason = async () => {
|
||||
selectedEndEpisode.value = episodes.value[0]
|
||||
}
|
||||
tab.value = 2
|
||||
selectedDubs.value = [{ locale: 'ja-JP', name: 'JP' }]
|
||||
|
||||
selectedDubs.value = []
|
||||
selectedSubs.value = []
|
||||
|
||||
if (dubLocales.value && dubLocales.value.length !== 0) {
|
||||
for (const a of dubLocales.value) {
|
||||
if (CRselectedShow.value.Dubs.find(cr => cr === a.locale)) {
|
||||
toggleDub(a)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
selectedDubs.value = [{ locale: 'ja-JP', name: 'JP' }]
|
||||
}
|
||||
|
||||
if (subLocales.value && subLocales.value.length !== 0) {
|
||||
for (const a of subLocales.value) {
|
||||
if (CRselectedShow.value.Subs.find(cr => cr === a.locale)) {
|
||||
toggleSub(a)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
selectedSubs.value = []
|
||||
}
|
||||
}
|
||||
|
||||
if (url.value && url.value.includes('crunchyroll') && !CRselectedShow.value) {
|
||||
@ -657,8 +686,29 @@ const switchToSeason = async () => {
|
||||
selectedEndEpisode.value = episodes.value[0]
|
||||
}
|
||||
tab.value = 2
|
||||
selectedDubs.value = [{ locale: 'ja-JP', name: 'JP' }]
|
||||
|
||||
selectedDubs.value = []
|
||||
selectedSubs.value = []
|
||||
|
||||
if (dubLocales.value && dubLocales.value.length !== 0) {
|
||||
for (const a of dubLocales.value) {
|
||||
if (CRselectedShow.value.Dubs.find(cr => cr === a.locale)) {
|
||||
toggleDub(a)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
selectedDubs.value = [{ locale: 'ja-JP', name: 'JP' }]
|
||||
}
|
||||
|
||||
if (subLocales.value && subLocales.value.length !== 0) {
|
||||
for (const a of subLocales.value) {
|
||||
if (CRselectedShow.value.Subs.find(cr => cr === a.locale)) {
|
||||
toggleSub(a)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
selectedSubs.value = []
|
||||
}
|
||||
}
|
||||
|
||||
isFetchingSeasons.value--
|
||||
|
@ -82,7 +82,11 @@ async function deletePlaylistandTMP() {
|
||||
deletePlaylistandTMP()
|
||||
|
||||
// Update Playlist Item
|
||||
export async function updatePlaylistByID(id: number, status?: 'waiting' | 'preparing' | 'downloading' | 'merging' | 'decrypting' | 'completed' | 'failed', quality?: 1080 | 720 | 480 | 360 | 240) {
|
||||
export async function updatePlaylistByID(
|
||||
id: number,
|
||||
status?: 'waiting' | 'preparing' | 'downloading' | 'merging' | 'decrypting' | 'completed' | 'failed',
|
||||
quality?: 1080 | 720 | 480 | 360 | 240
|
||||
) {
|
||||
await Playlist.update({ status: status, quality: quality }, { where: { id: id } })
|
||||
}
|
||||
|
||||
@ -156,7 +160,7 @@ async function checkPlaylists() {
|
||||
e.dataValues.quality,
|
||||
e.dataValues.dir,
|
||||
e.dataValues.format,
|
||||
(e.dataValues.media as CrunchyEpisode).geo,
|
||||
(e.dataValues.media as CrunchyEpisode).geo
|
||||
)
|
||||
}
|
||||
if (e.dataValues.service === 'ADN') {
|
||||
@ -653,11 +657,7 @@ export async function downloadCrunchyrollPlaylist(
|
||||
keys = await getDRMKeys(pssh, assetId[1], play.account_id)
|
||||
}
|
||||
|
||||
if (
|
||||
(hq.contentProtection && !drmL3blob && !drmL3key) ||
|
||||
(hq.contentProtection && !drmL3blob) ||
|
||||
(hq.contentProtection && !drmL3key)
|
||||
) {
|
||||
if ((hq.contentProtection && !drmL3blob && !drmL3key) || (hq.contentProtection && !drmL3blob) || (hq.contentProtection && !drmL3key)) {
|
||||
await updatePlaylistByID(downloadID, 'failed')
|
||||
messageBox(
|
||||
'error',
|
||||
@ -714,8 +714,8 @@ async function downloadParts(parts: { filename: string; url: string }[], downloa
|
||||
const path = await createFolder()
|
||||
const dn = downloading.find((i) => i.id === downloadID)
|
||||
|
||||
let totalDownloadedBytes = 0;
|
||||
let totalSizeBytes = 0;
|
||||
let totalDownloadedBytes = 0
|
||||
let totalSizeBytes = 0
|
||||
let startTime = Date.now()
|
||||
|
||||
for (const [index, part] of parts.entries()) {
|
||||
@ -730,12 +730,12 @@ async function downloadParts(parts: { filename: string; url: string }[], downloa
|
||||
|
||||
const readableStream = Readable.from(body as any)
|
||||
let partDownloadedBytes = 0
|
||||
let partSizeBytes = 0;
|
||||
let partSizeBytes = 0
|
||||
|
||||
readableStream.on('data', (chunk) => {
|
||||
partDownloadedBytes += chunk.length
|
||||
totalDownloadedBytes += chunk.length
|
||||
totalSizeBytes += chunk.length;
|
||||
totalSizeBytes += chunk.length
|
||||
})
|
||||
|
||||
await finished(readableStream.pipe(stream))
|
||||
@ -748,7 +748,7 @@ async function downloadParts(parts: { filename: string; url: string }[], downloa
|
||||
const endTime = Date.now()
|
||||
const durationInSeconds = (endTime - startTime) / 1000
|
||||
dn.downloadSpeed = totalDownloadedBytes / 1024 / 1024 / durationInSeconds
|
||||
dn.totalDownloaded = tot;
|
||||
dn.totalDownloaded = tot
|
||||
}
|
||||
|
||||
success = true
|
||||
@ -941,29 +941,35 @@ async function mergeVideoFile(video: string, audios: Array<string>, subs: Array<
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
export async function checkProxies() {
|
||||
|
||||
const cachedData = server.CacheController.get('proxycheck') as { name: string, code: string, url: string, status: string | undefined }[];
|
||||
const cachedData = server.CacheController.get('proxycheck') as { name: string; code: string; url: string; status: string | undefined }[]
|
||||
|
||||
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
|
||||
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: '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
|
||||
}]
|
||||
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'
|
||||
@ -978,5 +984,4 @@ export async function checkProxies() {
|
||||
}
|
||||
|
||||
return cachedData
|
||||
|
||||
}
|
||||
|
@ -211,6 +211,18 @@ ipcMain.handle('dialog:defaultArray', async (events, type: string) => {
|
||||
return savedPath
|
||||
})
|
||||
|
||||
ipcMain.handle('dialog:defaultArraySetSub', async (events, va: Array<any>) => {
|
||||
await settings.set('defsubarray', va)
|
||||
|
||||
return va
|
||||
})
|
||||
|
||||
ipcMain.handle('dialog:defaultArraySetDub', async (events, va: Array<any>) => {
|
||||
await settings.set('defdubarray', va)
|
||||
|
||||
return va
|
||||
})
|
||||
|
||||
ipcMain.handle('dialog:proxyActive', async (events) => {
|
||||
|
||||
const savedStat = await settings.get('proxyActive')
|
||||
|
@ -8,6 +8,8 @@ contextBridge.exposeInMainWorld('myAPI', {
|
||||
getFolder: () => ipcRenderer.invoke('dialog:defaultDirectory'),
|
||||
getFile: (type: string) => ipcRenderer.invoke('dialog:defaultFile', type),
|
||||
getArray: (type: string) => ipcRenderer.invoke('dialog:defaultArray', type),
|
||||
setArraySub: (va: Array<any>) => ipcRenderer.invoke('dialog:defaultArraySetSub', va),
|
||||
setArrayDub: (va: Array<any>) => ipcRenderer.invoke('dialog:defaultArraySetDub', va),
|
||||
getProxyActive: () => ipcRenderer.invoke('dialog:proxyActive'),
|
||||
setProxyActive: (status: boolean) => ipcRenderer.invoke('dialog:proxyActiveSet', status),
|
||||
openWindow: (opt: { title: string; url: string; width: number; height: number; backgroundColor: string }) => ipcRenderer.invoke('window:openNewWindow', opt),
|
||||
|
Reference in New Issue
Block a user