added open folder button after download

This commit is contained in:
stratuma 2024-05-20 18:31:36 +02:00
parent a6f6c50345
commit 1662b7ed63
5 changed files with 34 additions and 27 deletions

View File

@ -3,9 +3,6 @@
<MainHeader /> <MainHeader />
<Updater /> <Updater />
<div class="flex flex-col text-white gap-5 mt-14 p-5 overflow-y-scroll h-[calc(100vh-3.5rem)]"> <div class="flex flex-col text-white gap-5 mt-14 p-5 overflow-y-scroll h-[calc(100vh-3.5rem)]">
<!-- <button @click="deletePlaylist">
Delete Playlist
</button> -->
<div v-for="p in playlist" class="relative flex flex-row gap-4 min-h-36 bg-[#63636383] rounded-xl font-dm overflow-hidden"> <div v-for="p in playlist" class="relative flex flex-row gap-4 min-h-36 bg-[#63636383] rounded-xl font-dm overflow-hidden">
<div <div
class="absolute top-0 left-0 w-full h-full bg-[#a1a1a141] transition-all duration-300" class="absolute top-0 left-0 w-full h-full bg-[#a1a1a141] transition-all duration-300"
@ -74,6 +71,9 @@
<div v-if="p.partsleft && p.status === 'downloading'" class="text-xs ml-auto">{{ p.partsdownloaded }}/{{ p.partsleft }}</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 v-if="p.downloadspeed && p.status === 'downloading'" class="text-xs ml-auto">{{ p.downloadspeed }} MB/s</div>
</div> </div>
<button @click="openFolder(p.installDir)" v-if="p.status === 'completed'" class="ml-auto h-9 w-9 hover:bg-[#ffffff2c] rounded-xl transition-all">
<Icon name="ph:folder-open" class="h-5 w-5 text-white" />
</button>
</div> </div>
</div> </div>
</div> </div>
@ -95,6 +95,7 @@ const playlist = ref<
dub: Array<{ locale: string; name: string }> dub: Array<{ locale: string; name: string }>
sub: Array<{ locale: string; name: string }> sub: Array<{ locale: string; name: string }>
dir: string dir: string
installDir: string
partsleft: number partsleft: number
partsdownloaded: number partsdownloaded: number
downloadspeed: number downloadspeed: number
@ -114,6 +115,7 @@ const getPlaylist = async () => {
dub: Array<{ locale: string; name: string }> dub: Array<{ locale: string; name: string }>
sub: Array<{ locale: string; name: string }> sub: Array<{ locale: string; name: string }>
dir: string dir: string
installDir: string
partsleft: number partsleft: number
partsdownloaded: number partsdownloaded: number
downloadspeed: number downloadspeed: number
@ -136,26 +138,17 @@ const getPlaylist = async () => {
playlist.value = data.value playlist.value = data.value
} }
const deletePlaylist = async () => {
const { data, error } = await useFetch('http://localhost:9941/api/service/playlist', {
method: 'delete'
})
if (error.value) {
alert(error.value)
return
}
if (!data.value) {
return
}
}
onMounted(() => { onMounted(() => {
getPlaylist() getPlaylist()
setInterval(getPlaylist, 1000) setInterval(getPlaylist, 1000)
}) })
const openFolder = (dir: string) => {
if (process.client) {
;(window as any).myAPI.openFolder(dir)
}
}
</script> </script>
<style> <style>

View File

@ -36,6 +36,7 @@ interface PlaylistAttributes {
hardsub: boolean hardsub: boolean
quality: 1080 | 720 | 480 | 360 | 240 quality: 1080 | 720 | 480 | 360 | 240
dir: string dir: string
installDir: string
failedreason: string failedreason: string
service: 'CR' | 'ADN' service: 'CR' | 'ADN'
format: 'mp4' | 'mkv' format: 'mp4' | 'mkv'
@ -109,6 +110,10 @@ const Playlist: ModelDefined<PlaylistAttributes, PlaylistCreateAttributes> = seq
allowNull: false, allowNull: false,
type: DataTypes.STRING type: DataTypes.STRING
}, },
installDir: {
allowNull: true,
type: DataTypes.STRING
},
hardsub: { hardsub: {
allowNull: false, allowNull: false,
type: DataTypes.BOOLEAN type: DataTypes.BOOLEAN

View File

@ -167,16 +167,18 @@ setTimeout(deletePlaylistandTMP, 500)
export async function updatePlaylistByID( export async function updatePlaylistByID(
id: number, id: number,
status?: 'waiting' | 'preparing' | 'downloading' | 'merging' | 'decrypting' | 'completed' | 'failed', status?: 'waiting' | 'preparing' | 'downloading' | 'merging' | 'decrypting' | 'completed' | 'failed',
quality?: 1080 | 720 | 480 | 360 | 240 quality?: 1080 | 720 | 480 | 360 | 240,
installedDir?: string
) { ) {
try { try {
await Playlist.update({ status: status, quality: quality }, { where: { id: id } }) await Playlist.update({ status: status, quality: quality, installDir: installedDir }, { where: { id: id } })
server.logger.log({ server.logger.log({
level: 'info', level: 'info',
message: `Updated Playlist Item ${id}`, message: `Updated Playlist Item ${id}`,
status: status || undefined, status: status || undefined,
quality: quality || undefined, quality: quality || undefined,
installedDir: installedDir || undefined,
timestamp: new Date().toISOString(), timestamp: new Date().toISOString(),
section: 'playlistItemUpdateDatabase' section: 'playlistItemUpdateDatabase'
}) })
@ -249,13 +251,13 @@ async function checkPlaylists() {
if (isDownloading < 3 && e.dataValues.status === 'waiting') { if (isDownloading < 3 && e.dataValues.status === 'waiting') {
updatePlaylistByID(e.dataValues.id, 'preparing') updatePlaylistByID(e.dataValues.id, 'preparing')
isDownloading++ isDownloading++
server.logger.log({
level: 'info',
message: `Added Playlist Item ${e.dataValues.id} to Download Process`,
timestamp: new Date().toISOString(),
section: 'playlistCheckCron'
})
if (e.dataValues.service === 'CR') { if (e.dataValues.service === 'CR') {
server.logger.log({
level: 'info',
message: `Added Playlist Item ${e.dataValues.id} to Download Process`,
timestamp: new Date().toISOString(),
section: 'playlistCheckCron'
})
downloadCrunchyrollPlaylist( downloadCrunchyrollPlaylist(
(e.dataValues.media as CrunchyEpisode).id, (e.dataValues.media as CrunchyEpisode).id,
(e as any).dataValues.dub.map((s: { locale: any }) => s.locale), (e as any).dataValues.dub.map((s: { locale: any }) => s.locale),
@ -502,6 +504,8 @@ export async function downloadCrunchyrollPlaylist(
const seasonFolder = await createFolderName(`${name.replace(/[/\\?%*:|"<>]/g, '')} Season ${season}`, downloadPath) const seasonFolder = await createFolderName(`${name.replace(/[/\\?%*:|"<>]/g, '')} Season ${season}`, downloadPath)
await updatePlaylistByID(downloadID, undefined, undefined, seasonFolder)
const drmL3blob = await settings.get('l3blob') const drmL3blob = await settings.get('l3blob')
const drmL3key = await settings.get('l3key') const drmL3key = await settings.get('l3key')

View File

@ -1,6 +1,6 @@
import * as path from 'path' import * as path from 'path'
import * as os from 'os' import * as os from 'os'
import { app, BrowserWindow, dialog, ipcMain, session } from 'electron' import { app, BrowserWindow, dialog, ipcMain, session, shell } from 'electron'
import singleInstance from './singleInstance' import singleInstance from './singleInstance'
import dynamicRenderer from './dynamicRenderer' import dynamicRenderer from './dynamicRenderer'
import titleBarActionsModule from './modules/titleBarActions' import titleBarActionsModule from './modules/titleBarActions'
@ -115,6 +115,10 @@ export async function messageBox(
console.log(response) console.log(response)
} }
ipcMain.handle('dialog:openFolder', async (events, dir: string) => {
shell.showItemInFolder(dir)
})
ipcMain.handle('dialog:openDirectory', async () => { ipcMain.handle('dialog:openDirectory', async () => {
const window = BrowserWindow.getFocusedWindow() const window = BrowserWindow.getFocusedWindow()

View File

@ -6,6 +6,7 @@ contextBridge.exposeInMainWorld('myAPI', {
selectEndpoint: (nr: number) => ipcRenderer.invoke('dialog:selectEndpoint', nr), selectEndpoint: (nr: number) => ipcRenderer.invoke('dialog:selectEndpoint', nr),
getEndpoint: () => ipcRenderer.invoke('dialog:getEndpoint'), getEndpoint: () => ipcRenderer.invoke('dialog:getEndpoint'),
getFolder: () => ipcRenderer.invoke('dialog:defaultDirectory'), getFolder: () => ipcRenderer.invoke('dialog:defaultDirectory'),
openFolder: (dir: string) => ipcRenderer.invoke('dialog:openFolder', dir),
getFile: (type: string) => ipcRenderer.invoke('dialog:defaultFile', type), getFile: (type: string) => ipcRenderer.invoke('dialog:defaultFile', type),
getArray: (type: string) => ipcRenderer.invoke('dialog:defaultArray', type), getArray: (type: string) => ipcRenderer.invoke('dialog:defaultArray', type),
setArraySub: (va: Array<any>) => ipcRenderer.invoke('dialog:defaultArraySetSub', va), setArraySub: (va: Array<any>) => ipcRenderer.invoke('dialog:defaultArraySetSub', va),