From 7d85f06fc82a2ce7f3cdc2904268260ba6907808 Mon Sep 17 00:00:00 2001 From: stratuma Date: Mon, 6 May 2024 23:50:25 +0200 Subject: [PATCH] some changes and removed taskbar progessbar --- .env.default | 5 ++++ .gitignore | 11 +++++--- build.js | 3 +-- ffmpeg/.gitkeep | 0 keys/.gitkeep | 0 mp4decrypt/.gitkeep | 0 nuxt.config.ts | 2 +- package.json | 2 +- .../crunchyroll/crunchyroll.controller.ts | 3 --- .../routes/crunchyroll/crunchyroll.service.ts | 3 +-- src/api/routes/service/service.service.ts | 27 +------------------ src/api/services/mp4decrypt.ts | 2 +- src/api/services/widevine.ts | 23 ++++++++++++++++ src/electron/background.ts | 4 --- 14 files changed, 41 insertions(+), 44 deletions(-) create mode 100644 .env.default create mode 100644 ffmpeg/.gitkeep create mode 100644 keys/.gitkeep create mode 100644 mp4decrypt/.gitkeep create mode 100644 src/api/services/widevine.ts diff --git a/.env.default b/.env.default new file mode 100644 index 0000000..d2fcf6e --- /dev/null +++ b/.env.default @@ -0,0 +1,5 @@ +FFMPEG_PATH= +FFPROBE_PATH= +MP4DECRYPT_PATH= +KEY_KEY= +KEY_CLIENT= diff --git a/.gitignore b/.gitignore index ee360c6..98563a2 100644 --- a/.gitignore +++ b/.gitignore @@ -18,11 +18,14 @@ debug.json errors.json build/ crunchyroll-downloader-output-*/ -updater/ # FFMPEG -ffmpeg/ +ffmpeg/ffmpeg.exe +ffmpeg/ffprobe.exe # MP4DECRYPT -mp4decrypt/ -src/api/services/widevine.ts +mp4decrypt/mp4decrypt.exe + +# Keys +keys/client +keys/key diff --git a/build.js b/build.js index f3bd490..6e7118f 100644 --- a/build.js +++ b/build.js @@ -14,8 +14,7 @@ const options = { nodeGypRebuild: true, buildDependenciesFromSource: true, - - // test 2 + publish: { provider: 'github', releaseType: 'release' diff --git a/ffmpeg/.gitkeep b/ffmpeg/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/keys/.gitkeep b/keys/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/mp4decrypt/.gitkeep b/mp4decrypt/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/nuxt.config.ts b/nuxt.config.ts index 554108c..1456ffd 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -8,7 +8,7 @@ export default defineNuxtConfig({ modules: ['@nuxtjs/tailwindcss', 'nuxt-icon', '@nuxtjs/google-fonts'], googleFonts: { families: { - 'DM+Sans': [600, '1000'], + 'DM+Sans': ['600', '1000'], 'Protest+Riot': true } }, diff --git a/package.json b/package.json index da2aa09..aeba947 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "extraResources": [ "./ffmpeg/**", "./mp4decrypt/**", - "./updater/**" + "./keys/**" ] } } diff --git a/src/api/routes/crunchyroll/crunchyroll.controller.ts b/src/api/routes/crunchyroll/crunchyroll.controller.ts index 5f8a2b6..9bcede0 100644 --- a/src/api/routes/crunchyroll/crunchyroll.controller.ts +++ b/src/api/routes/crunchyroll/crunchyroll.controller.ts @@ -1,8 +1,5 @@ import type { FastifyReply, FastifyRequest } from 'fastify' import { crunchyLogin } from './crunchyroll.service' -import { dialog } from 'electron' -import { messageBox } from '../../../electron/background' -import { CrunchyEpisodes, CrunchySeason } from '../../types/crunchyroll' import { loggedInCheck } from '../service/service.service' export async function loginController(request: FastifyRequest, reply: FastifyReply) { diff --git a/src/api/routes/crunchyroll/crunchyroll.service.ts b/src/api/routes/crunchyroll/crunchyroll.service.ts index 9c47ccd..1ca156e 100644 --- a/src/api/routes/crunchyroll/crunchyroll.service.ts +++ b/src/api/routes/crunchyroll/crunchyroll.service.ts @@ -4,10 +4,9 @@ import { VideoPlaylist } from '../../types/crunchyroll' import { useFetch } from '../useFetch' import { parse as mpdParse } from 'mpd-parser' import { loggedInCheck } from '../service/service.service' -import { app } from 'electron' // Disable when Crunchyroll turns off switch endpoint -const enableDRMBypass = false +const enableDRMBypass = true const crErrors = [ { diff --git a/src/api/routes/service/service.service.ts b/src/api/routes/service/service.service.ts index 87e7024..4976f7a 100644 --- a/src/api/routes/service/service.service.ts +++ b/src/api/routes/service/service.service.ts @@ -12,7 +12,7 @@ import { finished } from 'stream/promises' import Ffmpeg from 'fluent-ffmpeg' import { adnGetM3U8Playlist, adnGetPlaylist } from '../adn/adn.service' import { ADNEpisode } from '../../types/adn' -import { messageBox, setProgressBar } from '../../../electron/background' +import { messageBox } from '../../../electron/background' import { getFFMPEGPath } from '../../services/ffmpeg' import { getDRMKeys, Uint8ArrayToBase64 } from '../../services/decryption' import { getMP4DecryptPath } from '../../services/mp4decrypt' @@ -108,31 +108,6 @@ export async function getDownloading(id: number) { return null } -// Download Progress Bar Updater -function updateProgress() { - const totalParts = downloading.reduce((total, item) => total + item.partsToDownload, 0) - let downloadedParts = 0 - - downloading.forEach((item) => { - downloadedParts += item.downloadedParts - }) - - const progress = totalParts > 0 ? downloadedParts / totalParts : 0 - - setProgressBar(progress) - - const allDownloaded = downloading.every((item) => item.downloadedParts === item.partsToDownload) - - if (allDownloaded) { - setProgressBar(0) - return - } -} - -cron.schedule('*/2 * * * * *', () => { - updateProgress() -}) - // Define IsDownloading Count var isDownloading: number = 0 diff --git a/src/api/services/mp4decrypt.ts b/src/api/services/mp4decrypt.ts index 7de3c22..787ec58 100644 --- a/src/api/services/mp4decrypt.ts +++ b/src/api/services/mp4decrypt.ts @@ -10,7 +10,7 @@ if (isDev) { export function getMP4DecryptPath() { if (isDev) { - const mp4Decrypt = process.env.MP4DECRYPT + const mp4Decrypt = process.env.MP4DECRYPT_PATH return mp4Decrypt } else { diff --git a/src/api/services/widevine.ts b/src/api/services/widevine.ts new file mode 100644 index 0000000..7217d4d --- /dev/null +++ b/src/api/services/widevine.ts @@ -0,0 +1,23 @@ +import { app } from 'electron' +import path from 'path' +const isDev = process.env.NODE_ENV === 'development' +const appPath = app.getAppPath() +const resourcesPath = path.dirname(appPath) +const keyPath = path.join(resourcesPath, 'keys') +if (isDev) { + require('dotenv').config() +} + +export function getWVKPath() { + if (isDev) { + const key = process.env.KEY_KEY + const client = process.env.KEY_CLIENT + + return { key: key, client: client } + } else { + const key = path.join(keyPath, 'key') + const client = path.join(keyPath, 'client') + + return { key: key, client: client } + } +} \ No newline at end of file diff --git a/src/electron/background.ts b/src/electron/background.ts index 904b21b..2f8cd78 100644 --- a/src/electron/background.ts +++ b/src/electron/background.ts @@ -116,10 +116,6 @@ export async function messageBox( console.log(response) } -export async function setProgressBar(c: number) { - mainWindow.setProgressBar(c) -} - ipcMain.handle('dialog:openDirectory', async () => { const window = BrowserWindow.getFocusedWindow()