added option to disable season folder

This commit is contained in:
stratuma 2024-06-20 23:31:21 +02:00
parent a81379b375
commit 1468cbcb3c
4 changed files with 53 additions and 14 deletions

View File

@ -33,6 +33,10 @@
<div class="text-sm mt-2"> Variables: </div>
<div class="text-sm text-center"> {seriesName}, {seasonNumber}, {seasonNumberDD}, {quality} </div>
<div class="flex flex-row mt-3">
<input v-model="isSeasonActive" @change="setSeasonFolder(isSeasonActive)" type="checkbox" name="Season Folder" class="cursor-pointer" />
<div class="text-sm ml-1.5"> Create Season Folder </div>
</div>
</div>
</div>
</template>
@ -45,6 +49,7 @@ const seriesName = ref<string>('Frieren')
const episodeName = ref<string>("The Journey's End")
const episodeNamingTemplate = ref<string>()
const seasonNamingTemplate = ref<string>()
const isSeasonActive = ref<boolean>()
const episodeNaming = computed(() => {
if (!episodeNamingTemplate.value) return
@ -74,6 +79,9 @@ onMounted(() => {
;(window as any).myAPI.getEpisodeTemplate().then((result: string) => {
episodeNamingTemplate.value = result
})
;(window as any).myAPI.getSeasonEnabled().then((result: boolean) => {
isSeasonActive.value = result
})
})
watch(episodeNamingTemplate, () => {
@ -101,6 +109,14 @@ const setSeasonTemplate = (name: string) => {
})
}
}
const setSeasonFolder = (status: boolean | undefined) => {
if (process.client) {
;(window as any).myAPI.setSeasonEnabled(status).then((result: boolean) => {
isSeasonActive.value = result
})
}
}
</script>
<style></style>

View File

@ -530,21 +530,27 @@ export async function downloadCrunchyrollPlaylist(
const chapterFolder = await createFolder()
var seasonFolderNaming = (await settings.get('SeasonTemp')) as string
var downloadDir: string = downloadPath;
if (!seasonFolderNaming) {
seasonFolderNaming = '{seriesName} Season {seasonNumber}'
var isSeasonFolderActive = (await settings.get('seasonFolderActive')) as string
if (isSeasonFolderActive) {
var seasonFolderNaming = (await settings.get('SeasonTemp')) as string
if (!seasonFolderNaming) {
seasonFolderNaming = '{seriesName} Season {seasonNumber}'
}
seasonFolderNaming = seasonFolderNaming
.replace('{seriesName}', name.replace(/[/\\?%*:|"<>]/g, ''))
.replace('{seasonNumber}', season.toString())
.replace('{seasonNumberDD}', season.toString().padStart(2, '0'))
.replace('{quality}', quality.toString() + 'p')
downloadDir = await createFolderName(seasonFolderNaming, downloadPath)
}
seasonFolderNaming = seasonFolderNaming
.replace('{seriesName}', name.replace(/[/\\?%*:|"<>]/g, ''))
.replace('{seasonNumber}', season.toString())
.replace('{seasonNumberDD}', season.toString().padStart(2, '0'))
.replace('{quality}', quality.toString() + 'p')
const seasonFolder = await createFolderName(seasonFolderNaming, downloadPath)
await updatePlaylistByID(downloadID, undefined, undefined, seasonFolder)
await updatePlaylistByID(downloadID, undefined, undefined, downloadDir)
const drmL3blob = (await settings.get('l3blob')) as string
const drmL3key = (await settings.get('l3key')) as string
@ -1088,7 +1094,7 @@ export async function downloadCrunchyrollPlaylist(
.replace('{episodeNumberDD}', episode ? episode.toString().padStart(2, '0') : episode_string)
.replace('{quality}', quality.toString() + 'p')
await mergeVideoFile(file as string, chapter, audios, subss, seasonFolder, episodeNaming, format, downloadID)
await mergeVideoFile(file as string, chapter, audios, subss, downloadDir, episodeNaming, format, downloadID)
await updatePlaylistByID(downloadID, 'completed')

View File

@ -274,6 +274,23 @@ ipcMain.handle('dialog:proxyActiveSet', async (events, status: boolean) => {
return status
})
ipcMain.handle('dialog:getSeasonEnabledTemplate', async (events) => {
const savedStat = await settings.get('seasonFolderActive')
if (!savedStat) {
await settings.set('seasonFolderActive', true)
return true
}
return savedStat
})
ipcMain.handle('dialog:setSeasonEnabledTemplate', async (events, active: boolean) => {
await settings.set('seasonFolderActive', active)
return active
})
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()

View File

@ -24,5 +24,5 @@ contextBridge.exposeInMainWorld('myAPI', {
setSeasonTemplate: (name: string) => ipcRenderer.invoke('dialog:setSeasonTemplate', name),
getSeasonTemplate: () => ipcRenderer.invoke('dialog:getSeasonTemplate'),
setSeasonEnabled: (status: boolean) => ipcRenderer.invoke('dialog:setSeasonEnabledTemplate', status),
getSeasonEnabled: (status: boolean) => ipcRenderer.invoke('dialog:setSeasonEnabledTemplate', status),
getSeasonEnabled: (status: boolean) => ipcRenderer.invoke('dialog:getSeasonEnabledTemplate', status),
})