added toggle for subtitle resampler
This commit is contained in:
parent
32fb607f8a
commit
67fff3eaf5
@ -36,14 +36,21 @@
|
||||
</select>
|
||||
<div class="text-xs mt-2"> Fallback to non-drm stream if no widevine key provided </div>
|
||||
</div>
|
||||
<div class="flex flex-col items-center p-3 bg-[#11111189] rounded-xl select-none">
|
||||
<div class="text-sm mb-2">Subtitle Resampler (Experimental)</div>
|
||||
<select v-model="selectedSubResampler" @change="setResampler()" class="bg-[#5c5b5b] w-full focus:outline-none px-3 py-2 rounded-xl text-sm text-center cursor-pointer">
|
||||
<option :value="true">Actived</option>
|
||||
<option :value="false">Deactivated</option>
|
||||
</select>
|
||||
<div class="text-xs mt-2"> Fixes broken crunchyroll subtitles </div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
const selectedLanguage = ref<string>()
|
||||
const selectedEndpoint = ref<number>()
|
||||
const selectedVideoQuality = ref<number>()
|
||||
const selectedAudioQuality = ref<number>()
|
||||
const selectedSubResampler = ref<boolean>()
|
||||
|
||||
onMounted(() => {
|
||||
;(window as any).myAPI.getEndpoint().then((result: any) => {
|
||||
@ -52,6 +59,9 @@ onMounted(() => {
|
||||
;(window as any).myAPI.getDefaultCrunchyrollLanguage().then((result: any) => {
|
||||
selectedLanguage.value = result
|
||||
})
|
||||
;(window as any).myAPI.getSubtitleResampler().then((result: boolean) => {
|
||||
selectedSubResampler.value = result
|
||||
})
|
||||
})
|
||||
|
||||
const selectLanguage = () => {
|
||||
@ -65,6 +75,12 @@ const selectEndpoint = () => {
|
||||
;(window as any).myAPI.selectEndpoint(selectedEndpoint.value)
|
||||
}
|
||||
}
|
||||
|
||||
const setResampler = () => {
|
||||
if (process.client) {
|
||||
;(window as any).myAPI.setSubtitleResampler(selectedSubResampler.value)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
@ -4,6 +4,7 @@ import { Readable } from 'stream'
|
||||
import { finished } from 'stream/promises'
|
||||
import CryptoJS from 'crypto-js'
|
||||
import { server } from '../api'
|
||||
import settings from 'electron-settings'
|
||||
|
||||
export async function downloadCRSub(
|
||||
sub: {
|
||||
@ -16,6 +17,13 @@ export async function downloadCRSub(
|
||||
qual: 1080 | 720 | 480 | 360 | 240
|
||||
) {
|
||||
try {
|
||||
|
||||
var resamplerActive = await settings.get('subtitleResamplerActive')
|
||||
|
||||
if (resamplerActive === undefined || resamplerActive === null) {
|
||||
resamplerActive = true
|
||||
}
|
||||
|
||||
const path = `${dir}/${sub.language}${sub.isDub ? `-FORCED` : ''}.${sub.format}`
|
||||
var qualX
|
||||
var qualY
|
||||
@ -46,6 +54,15 @@ export async function downloadCRSub(
|
||||
const stream = fs.createWriteStream(path)
|
||||
const response = await fetch(sub.url)
|
||||
|
||||
if (!resamplerActive) {
|
||||
const readableStream = Readable.from([await response.text()])
|
||||
|
||||
await finished(readableStream.pipe(stream))
|
||||
console.log(`Sub ${sub.language}.${sub.format} downloaded`)
|
||||
|
||||
return path
|
||||
}
|
||||
|
||||
var parsedASS = parse(await response.text())
|
||||
|
||||
parsedASS.info['Original Script'] = 'crd [https://github.com/stratuma/]'
|
||||
|
@ -429,6 +429,23 @@ ipcMain.handle('dialog:getDefaultMaxDownloadsTemplate', async (events) => {
|
||||
return seTP
|
||||
})
|
||||
|
||||
ipcMain.handle('dialog:getSubtitleResamplerTemplate', async (events) => {
|
||||
const savedStat = await settings.get('subtitleResamplerActive')
|
||||
|
||||
if (savedStat === undefined || savedStat === null) {
|
||||
await settings.set('subtitleResamplerActive', true)
|
||||
return true
|
||||
}
|
||||
|
||||
return savedStat
|
||||
})
|
||||
|
||||
ipcMain.handle('dialog:setSubtitleResamplerTemplate', async (events, active: boolean) => {
|
||||
await settings.set('subtitleResamplerActive', active)
|
||||
|
||||
return active
|
||||
})
|
||||
|
||||
const openWindows = new Map()
|
||||
|
||||
// Open New Window
|
||||
|
@ -34,5 +34,7 @@ contextBridge.exposeInMainWorld('myAPI', {
|
||||
setDefaultCrunchyrollLanguage: (lang: string) => ipcRenderer.invoke('dialog:setDefaultCrunchyrollLanguageTemplate', lang),
|
||||
getDefaultCrunchyrollLanguage: () => ipcRenderer.invoke('dialog:getDefaultCrunchyrollLanguageTemplate'),
|
||||
setDefaultMaxDownloads: (max: number) => ipcRenderer.invoke('dialog:setDefaultMaxDownloadsTemplate', max),
|
||||
getDefaultMaxDownloads: () => ipcRenderer.invoke('dialog:getDefaultMaxDownloadsTemplate')
|
||||
getDefaultMaxDownloads: () => ipcRenderer.invoke('dialog:getDefaultMaxDownloadsTemplate'),
|
||||
setSubtitleResampler: (active: boolean) => ipcRenderer.invoke('dialog:setSubtitleResamplerTemplate', active),
|
||||
getSubtitleResampler: () => ipcRenderer.invoke('dialog:getSubtitleResamplerTemplate')
|
||||
})
|
||||
|
Reference in New Issue
Block a user