added open folder button after download
This commit is contained in:
parent
a6f6c50345
commit
1662b7ed63
@ -3,9 +3,6 @@
|
||||
<MainHeader />
|
||||
<Updater />
|
||||
<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
|
||||
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.downloadspeed && p.status === 'downloading'" class="text-xs ml-auto">{{ p.downloadspeed }} MB/s</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>
|
||||
@ -95,6 +95,7 @@ const playlist = ref<
|
||||
dub: Array<{ locale: string; name: string }>
|
||||
sub: Array<{ locale: string; name: string }>
|
||||
dir: string
|
||||
installDir: string
|
||||
partsleft: number
|
||||
partsdownloaded: number
|
||||
downloadspeed: number
|
||||
@ -114,6 +115,7 @@ const getPlaylist = async () => {
|
||||
dub: Array<{ locale: string; name: string }>
|
||||
sub: Array<{ locale: string; name: string }>
|
||||
dir: string
|
||||
installDir: string
|
||||
partsleft: number
|
||||
partsdownloaded: number
|
||||
downloadspeed: number
|
||||
@ -136,26 +138,17 @@ const getPlaylist = async () => {
|
||||
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(() => {
|
||||
getPlaylist()
|
||||
|
||||
setInterval(getPlaylist, 1000)
|
||||
})
|
||||
|
||||
const openFolder = (dir: string) => {
|
||||
if (process.client) {
|
||||
;(window as any).myAPI.openFolder(dir)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
@ -36,6 +36,7 @@ interface PlaylistAttributes {
|
||||
hardsub: boolean
|
||||
quality: 1080 | 720 | 480 | 360 | 240
|
||||
dir: string
|
||||
installDir: string
|
||||
failedreason: string
|
||||
service: 'CR' | 'ADN'
|
||||
format: 'mp4' | 'mkv'
|
||||
@ -109,6 +110,10 @@ const Playlist: ModelDefined<PlaylistAttributes, PlaylistCreateAttributes> = seq
|
||||
allowNull: false,
|
||||
type: DataTypes.STRING
|
||||
},
|
||||
installDir: {
|
||||
allowNull: true,
|
||||
type: DataTypes.STRING
|
||||
},
|
||||
hardsub: {
|
||||
allowNull: false,
|
||||
type: DataTypes.BOOLEAN
|
||||
|
@ -167,16 +167,18 @@ setTimeout(deletePlaylistandTMP, 500)
|
||||
export async function updatePlaylistByID(
|
||||
id: number,
|
||||
status?: 'waiting' | 'preparing' | 'downloading' | 'merging' | 'decrypting' | 'completed' | 'failed',
|
||||
quality?: 1080 | 720 | 480 | 360 | 240
|
||||
quality?: 1080 | 720 | 480 | 360 | 240,
|
||||
installedDir?: string
|
||||
) {
|
||||
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({
|
||||
level: 'info',
|
||||
message: `Updated Playlist Item ${id}`,
|
||||
status: status || undefined,
|
||||
quality: quality || undefined,
|
||||
installedDir: installedDir || undefined,
|
||||
timestamp: new Date().toISOString(),
|
||||
section: 'playlistItemUpdateDatabase'
|
||||
})
|
||||
@ -249,13 +251,13 @@ async function checkPlaylists() {
|
||||
if (isDownloading < 3 && e.dataValues.status === 'waiting') {
|
||||
updatePlaylistByID(e.dataValues.id, 'preparing')
|
||||
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') {
|
||||
server.logger.log({
|
||||
level: 'info',
|
||||
message: `Added Playlist Item ${e.dataValues.id} to Download Process`,
|
||||
timestamp: new Date().toISOString(),
|
||||
section: 'playlistCheckCron'
|
||||
})
|
||||
downloadCrunchyrollPlaylist(
|
||||
(e.dataValues.media as CrunchyEpisode).id,
|
||||
(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)
|
||||
|
||||
await updatePlaylistByID(downloadID, undefined, undefined, seasonFolder)
|
||||
|
||||
const drmL3blob = await settings.get('l3blob')
|
||||
const drmL3key = await settings.get('l3key')
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import * as path from 'path'
|
||||
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 dynamicRenderer from './dynamicRenderer'
|
||||
import titleBarActionsModule from './modules/titleBarActions'
|
||||
@ -115,6 +115,10 @@ export async function messageBox(
|
||||
console.log(response)
|
||||
}
|
||||
|
||||
ipcMain.handle('dialog:openFolder', async (events, dir: string) => {
|
||||
shell.showItemInFolder(dir)
|
||||
})
|
||||
|
||||
ipcMain.handle('dialog:openDirectory', async () => {
|
||||
const window = BrowserWindow.getFocusedWindow()
|
||||
|
||||
|
@ -6,6 +6,7 @@ contextBridge.exposeInMainWorld('myAPI', {
|
||||
selectEndpoint: (nr: number) => ipcRenderer.invoke('dialog:selectEndpoint', nr),
|
||||
getEndpoint: () => ipcRenderer.invoke('dialog:getEndpoint'),
|
||||
getFolder: () => ipcRenderer.invoke('dialog:defaultDirectory'),
|
||||
openFolder: (dir: string) => ipcRenderer.invoke('dialog:openFolder', dir),
|
||||
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),
|
||||
|
Reference in New Issue
Block a user