added prettier

This commit is contained in:
Daniel Haller 2024-05-01 01:45:45 +02:00
parent 2e29f467d1
commit 9909e3b558
52 changed files with 5752 additions and 4129 deletions

View File

@ -11,7 +11,7 @@
"requirePragma": false,
"semi": false,
"singleQuote": true,
"tabWidth": 2,
"tabWidth": 4,
"trailingComma": "none",
"useTabs": false,
"vueIndentScriptAndStyle": false,

View File

@ -1,72 +0,0 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const builder = require('electron-builder')
const Platform = builder.Platform
/**
* @type {import('electron-builder').Configuration}
*/
const options = {
appId: 'com.stratum.crunchyrolldownloader',
productName: 'Crunchyroll Downloader',
compression: 'maximum',
removePackageScripts: true,
nodeGypRebuild: true,
buildDependenciesFromSource: true,
publish: {
provider: 'github',
releaseType: 'release'
},
directories: {
output: 'crunchyroll-downloader-output-${version}'
},
win: {
artifactName: 'crunchyroll-downloader-${version}-windows-installer.${ext}',
icon: 'public/favicon.ico',
target: [
{
target: 'nsis',
arch: ['x64', 'ia32']
}
]
},
nsis: {
deleteAppDataOnUninstall: true
},
mac: {
category: 'public.app-category.entertainment',
hardenedRuntime: false,
gatekeeperAssess: false,
target: [
{
target: 'default',
arch: ['x64', 'arm64']
}
]
},
linux: {
maintainer: 'Stratum',
desktop: {
StartupNotify: 'false',
Encoding: 'UTF-8',
MimeType: 'x-scheme-handler/deeplink'
},
target: ['AppImage', 'rpm', 'deb']
}
}
const platform = 'WINDOWS'
builder
.build({
targets: Platform[platform].createTarget(),
config: options
})
.then((result) => {
console.log('----------------------------')
console.log('Platform:', platform)
console.log('Output:', JSON.stringify(result, null, 2))
})

72
build.ts Normal file
View File

@ -0,0 +1,72 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const builder = require('electron-builder')
const Platform = builder.Platform
/**
* @type {import('electron-builder').Configuration}
*/
const options = {
appId: 'com.stratum.crunchyrolldownloader',
productName: 'Crunchyroll Downloader',
compression: 'maximum',
removePackageScripts: true,
nodeGypRebuild: true,
buildDependenciesFromSource: true,
publish: {
provider: 'github',
releaseType: 'release'
},
directories: {
output: 'crunchyroll-downloader-output-${version}'
},
win: {
artifactName: 'crunchyroll-downloader-${version}-windows-installer.${ext}',
icon: 'public/favicon.ico',
target: [
{
target: 'nsis',
arch: ['x64', 'ia32']
}
]
},
nsis: {
deleteAppDataOnUninstall: true
},
mac: {
category: 'public.app-category.entertainment',
hardenedRuntime: false,
gatekeeperAssess: false,
target: [
{
target: 'default',
arch: ['x64', 'arm64']
}
]
},
linux: {
maintainer: 'Stratum',
desktop: {
StartupNotify: 'false',
Encoding: 'UTF-8',
MimeType: 'x-scheme-handler/deeplink'
},
target: ['AppImage', 'rpm', 'deb']
}
}
const platform = 'WINDOWS'
builder
.build({
targets: Platform[platform].createTarget(),
config: options
})
.then((result: any) => {
console.log('----------------------------')
console.log('Platform:', platform)
console.log('Output:', JSON.stringify(result, null, 2))
})

View File

@ -1,19 +1,16 @@
import type { ADNSearchFetch } from "./Types";
import type { ADNSearchFetch } from './Types'
export async function searchADN(q: string) {
const { data: deData, error: deError } = await useFetch<ADNSearchFetch>(
`https://gw.api.animationdigitalnetwork.fr/show/catalog`,
{
method: "GET",
headers: {
"x-target-distribution": 'de',
},
query: {
"maxAgeCategory": "18",
"search": q
}
const { data: deData, error: deError } = await useFetch<ADNSearchFetch>(`https://gw.api.animationdigitalnetwork.fr/show/catalog`, {
method: 'GET',
headers: {
'x-target-distribution': 'de'
},
query: {
maxAgeCategory: '18',
search: q
}
);
})
if (deError.value) {
throw new Error(deError.value?.data.message as string)
@ -21,19 +18,16 @@ export async function searchADN(q: string) {
if (!deData.value) return
const { data: frData, error: frError } = await useFetch<ADNSearchFetch>(
`https://gw.api.animationdigitalnetwork.fr/show/catalog`,
{
method: "GET",
headers: {
"x-target-distribution": 'fr',
},
query: {
"maxAgeCategory": "18",
"search": q
}
const { data: frData, error: frError } = await useFetch<ADNSearchFetch>(`https://gw.api.animationdigitalnetwork.fr/show/catalog`, {
method: 'GET',
headers: {
'x-target-distribution': 'fr'
},
query: {
maxAgeCategory: '18',
search: q
}
);
})
if (frError.value) {
throw new Error(frError.value?.data.message as string)
@ -41,22 +35,24 @@ export async function searchADN(q: string) {
if (!frData.value) return
const deShows = deData.value.shows;
const frShows = frData.value.shows;
const deShows = deData.value.shows
const frShows = frData.value.shows
const mergeLanguagesOfDuplicates = (shows: {
id: number
url: string
title: string
image2x: string
episodeCount: number,
languages: Array<string>
}[]) => {
shows.forEach(show => {
const existingShow = shows.find(s => s.id === show.id);
const mergeLanguagesOfDuplicates = (
shows: {
id: number
url: string
title: string
image2x: string
episodeCount: number
languages: Array<string>
}[]
) => {
shows.forEach((show) => {
const existingShow = shows.find((s) => s.id === show.id)
if (existingShow) {
const existingShowIndex = shows.findIndex(s=> s === existingShow);
const rawLanguages = [...show.languages, ...existingShow.languages];
const existingShowIndex = shows.findIndex((s) => s === existingShow)
const rawLanguages = [...show.languages, ...existingShow.languages]
const languages: Array<string> = []
for (const l of rawLanguages) {
@ -66,13 +62,13 @@ export async function searchADN(q: string) {
}
show.languages = languages
}
});
return shows;
};
})
return shows
}
const allShows = mergeLanguagesOfDuplicates([...deShows, ...frShows]);
const allShows = mergeLanguagesOfDuplicates([...deShows, ...frShows])
const unique = [...new Map(allShows.map((s) => [s.id, s])).values()];
const unique = [...new Map(allShows.map((s) => [s.id, s])).values()]
return unique
}

View File

@ -1,18 +1,18 @@
import type { ADNEpisodes, ADNEpisodesFetch } from './Types'
export async function getEpisodesWithShowIdADN(id: number, lang: 'de' | 'fr') {
const { data, error } = await useFetch<ADNEpisodesFetch>(`https://gw.api.animationdigitalnetwork.fr/video/show/${id}?offset=0&limit=-1&order=asc`, {
method: 'GET',
headers: {
"x-target-distribution": lang,
},
})
const { data, error } = await useFetch<ADNEpisodesFetch>(`https://gw.api.animationdigitalnetwork.fr/video/show/${id}?offset=0&limit=-1&order=asc`, {
method: 'GET',
headers: {
'x-target-distribution': lang
}
})
if (error.value || !data.value) {
console.log(error.value)
alert(error.value)
return
}
if (error.value || !data.value) {
console.log(error.value)
alert(error.value)
return
}
return data.value.videos
return data.value.videos
}

View File

@ -1,85 +1,85 @@
export interface ADNSearchFetch {
shows: Array<{
id: number
url: string
title: string
image2x: string
episodeCount: number,
languages: Array<string>
}>
shows: Array<{
id: number
url: string
title: string
image2x: string
episodeCount: number
languages: Array<string>
}>
}
export interface ADNEpisodesFetch {
videos: Array<ADNEpisode>
videos: Array<ADNEpisode>
}
export interface ADNEpisode {
id: number,
title: string,
name: string,
number: string,
shortNumber: string,
season: string,
reference: string,
type: string,
order: number,
image: string,
image2x: string,
summary: string,
releaseDate: string,
duration: number,
url: string,
urlPath: string,
embeddedUrl: string,
languages: Array<string>,
qualities: Array<string>,
rating: number,
ratingsCount: number,
commentsCount: number,
available: boolean,
download: boolean,
free: boolean,
freeWithAds: boolean,
show: {
id: number,
title: string,
type: string,
originalTitle: string,
shortTitle: string,
reference: string,
age: string,
languages: Array<string>,
summary: string,
image: string,
image2x: string,
imageHorizontal: string,
imageHorizontal2x: string,
url: string,
urlPath: string,
episodeCount: number,
genres: Array<string>,
copyright: string,
rating: number,
ratingsCount: number,
commentsCount: number,
qualities: Array<string>,
simulcast: boolean,
free: boolean,
available: boolean,
download: boolean,
basedOn: string,
tagline: Array<string>,
firstReleaseYear: string,
productionStudio: string,
countryOfOrigin: string,
productionTeam: Array<{
role: string,
name: string,
}>,
nextVideoReleaseDate: string,
id: number
title: string
name: string
number: string
shortNumber: string
season: string
reference: string
type: string
order: number
image: string
image2x: string
summary: string
releaseDate: string
duration: number
url: string
urlPath: string
embeddedUrl: string
languages: Array<string>
qualities: Array<string>
rating: number
ratingsCount: number
commentsCount: number
available: boolean
download: boolean
free: boolean
freeWithAds: boolean
show: {
id: number
title: string
type: string
originalTitle: string
shortTitle: string
reference: string
age: string
languages: Array<string>
summary: string
image: string
image2x: string
imageHorizontal: string
imageHorizontal2x: string
url: string
urlPath: string
episodeCount: number
genres: Array<string>
copyright: string
rating: number
ratingsCount: number
commentsCount: number
qualities: Array<string>
simulcast: boolean
free: boolean
available: boolean
download: boolean
basedOn: string
tagline: Array<string>
firstReleaseYear: string
productionStudio: string
countryOfOrigin: string
productionTeam: Array<{
role: string
name: string
}>
nextVideoReleaseDate: string
indexable: boolean
}
indexable: boolean
}
indexable: boolean
}
export interface ADNEpisodes extends Array<ADNEpisode> {}
export interface ADNEpisodes extends Array<ADNEpisode> {}

View File

@ -1,29 +1,29 @@
import type { CrunchyLogin } from './Types'
export async function crunchyLogin() {
const { data, error } = await useFetch<CrunchyLogin>('http://localhost:8080/api/crunchyroll/login', {
method: 'POST'
})
const { data, error } = await useFetch<CrunchyLogin>('http://localhost:8080/api/crunchyroll/login', {
method: 'POST'
})
return { data, error }
return { data, error }
}
export async function checkAccount(service: string) {
const { data, error } = await useFetch<CrunchyLogin>(`http://localhost:8080/api/service/check/${service}`, {
method: 'GET'
})
const { data, error } = await useFetch<CrunchyLogin>(`http://localhost:8080/api/service/check/${service}`, {
method: 'GET'
})
return { data, error }
return { data, error }
}
export async function loginAccount(user: string, password: string, service: string) {
const { data, error } = await useFetch<CrunchyLogin>(`http://localhost:8080/api/service/login/${service}`, {
method: 'POST',
body: {
user: user,
password: password
}
})
const { data, error } = await useFetch<CrunchyLogin>(`http://localhost:8080/api/service/login/${service}`, {
method: 'POST',
body: {
user: user,
password: password
}
})
return { data, error }
return { data, error }
}

View File

@ -3,87 +3,87 @@ import { crunchyLogin } from './Account'
import type { CrunchyAnimeFetch, CrunchySearchFetch } from './Types'
export async function searchCrunchy(q: string) {
const { data: token, error: tokenerror } = await crunchyLogin()
const { data: token, error: tokenerror } = await crunchyLogin()
if (!token.value) {
return
}
const { data, error } = await useFetch<CrunchySearchFetch>(`https://beta-api.crunchyroll.com/content/v2/discover/search`, {
method: 'GET',
headers: {
Authorization: `Bearer ${token.value.access_token}`
},
query: {
q: q,
n: 100,
type: 'series',
ratings: false
if (!token.value) {
return
}
})
if (error.value) {
console.error(error.value)
throw new Error(JSON.stringify(error.value))
}
if (!data.value) return
var results: CrunchyrollSearchResults = []
for (const result of data.value.data[0].items) {
results.push({
ID: result.id,
Url: `https://www.crunchyroll.com/series/${result.id}/${result.slug_title}`,
Title: result.title,
Description: result.description,
Dubs: result.series_metadata.audio_locales,
Subs: result.series_metadata.subtitle_locales,
Episodes: result.series_metadata.episode_count,
Seasons: result.series_metadata.season_count,
PEGI: result.series_metadata.maturity_ratings,
Year: result.series_metadata.series_launch_year,
Images: result.images
const { data, error } = await useFetch<CrunchySearchFetch>(`https://beta-api.crunchyroll.com/content/v2/discover/search`, {
method: 'GET',
headers: {
Authorization: `Bearer ${token.value.access_token}`
},
query: {
q: q,
n: 100,
type: 'series',
ratings: false
}
})
}
return results
if (error.value) {
console.error(error.value)
throw new Error(JSON.stringify(error.value))
}
if (!data.value) return
var results: CrunchyrollSearchResults = []
for (const result of data.value.data[0].items) {
results.push({
ID: result.id,
Url: `https://www.crunchyroll.com/series/${result.id}/${result.slug_title}`,
Title: result.title,
Description: result.description,
Dubs: result.series_metadata.audio_locales,
Subs: result.series_metadata.subtitle_locales,
Episodes: result.series_metadata.episode_count,
Seasons: result.series_metadata.season_count,
PEGI: result.series_metadata.maturity_ratings,
Year: result.series_metadata.series_launch_year,
Images: result.images
})
}
return results
}
export async function getCRSeries(q: string) {
const { data: token, error: tokenerror } = await crunchyLogin()
const { data: token, error: tokenerror } = await crunchyLogin()
if (!token.value) {
return
}
const { data, error } = await useFetch<CrunchyAnimeFetch>(`https://beta-api.crunchyroll.com/content/v2/cms/series/${q}`, {
method: 'GET',
headers: {
Authorization: `Bearer ${token.value.access_token}`
if (!token.value) {
return
}
})
if (error.value) {
console.error(error.value)
throw new Error(JSON.stringify(error.value))
}
const { data, error } = await useFetch<CrunchyAnimeFetch>(`https://beta-api.crunchyroll.com/content/v2/cms/series/${q}`, {
method: 'GET',
headers: {
Authorization: `Bearer ${token.value.access_token}`
}
})
if (!data.value) return
if (error.value) {
console.error(error.value)
throw new Error(JSON.stringify(error.value))
}
const anime = data.value.data[0]
if (!data.value) return
return {
ID: anime.id,
Url: `https://www.crunchyroll.com/series/${anime.id}/${anime.slug_title}`,
Title: anime.title,
Description: anime.description,
Dubs: anime.audio_locales,
Subs: anime.subtitle_locales,
Episodes: anime.episode_count,
Seasons: anime.season_count,
PEGI: anime.maturity_ratings,
Year: anime.series_launch_year,
Images: anime.images
}
const anime = data.value.data[0]
return {
ID: anime.id,
Url: `https://www.crunchyroll.com/series/${anime.id}/${anime.slug_title}`,
Title: anime.title,
Description: anime.description,
Dubs: anime.audio_locales,
Subs: anime.subtitle_locales,
Episodes: anime.episode_count,
Seasons: anime.season_count,
PEGI: anime.maturity_ratings,
Year: anime.series_launch_year,
Images: anime.images
}
}

View File

@ -2,25 +2,25 @@ import { crunchyLogin } from './Account'
import type { CrunchyEpisodesFetch } from './Types'
export async function listEpisodeCrunchy(q: string) {
const { data: token, error: tokenerror } = await crunchyLogin()
const { data: token, error: tokenerror } = await crunchyLogin()
if (!token.value) {
return
}
const { data, error } = await useFetch<CrunchyEpisodesFetch>(`https://beta-api.crunchyroll.com/content/v2/cms/seasons/${q}/episodes`, {
method: 'GET',
headers: {
Authorization: `Bearer ${token.value.access_token}`
if (!token.value) {
return
}
})
if (error.value) {
console.error(error.value)
throw new Error(JSON.stringify(error.value))
}
const { data, error } = await useFetch<CrunchyEpisodesFetch>(`https://beta-api.crunchyroll.com/content/v2/cms/seasons/${q}/episodes`, {
method: 'GET',
headers: {
Authorization: `Bearer ${token.value.access_token}`
}
})
if (!data.value) return
if (error.value) {
console.error(error.value)
throw new Error(JSON.stringify(error.value))
}
return data.value.data
if (!data.value) return
return data.value.data
}

View File

@ -2,27 +2,27 @@ import { crunchyLogin } from './Account'
import type { CrunchySeasonsFetch } from './Types'
export async function listSeasonCrunchy(q: string) {
const { data: token, error: tokenerror } = await crunchyLogin()
const { data: token, error: tokenerror } = await crunchyLogin()
if (!token.value) {
return
}
console.log(q)
const { data, error } = await useFetch<CrunchySeasonsFetch>(`https://beta-api.crunchyroll.com/content/v2/cms/series/${q}/seasons`, {
method: 'GET',
headers: {
Authorization: `Bearer ${token.value.access_token}`
if (!token.value) {
return
}
})
if (error.value) {
console.error(error.value)
throw new Error(JSON.stringify(error.value))
}
console.log(q)
if (!data.value) return
const { data, error } = await useFetch<CrunchySeasonsFetch>(`https://beta-api.crunchyroll.com/content/v2/cms/series/${q}/seasons`, {
method: 'GET',
headers: {
Authorization: `Bearer ${token.value.access_token}`
}
})
return data.value.data
if (error.value) {
console.error(error.value)
throw new Error(JSON.stringify(error.value))
}
if (!data.value) return
return data.value.data
}

View File

@ -1,18 +1,73 @@
export interface CrunchySearchFetch {
total: number
data: Array<{
type: string
count: number
items: Array<{
promo_description: string
title: string
promo_title: string
channel_id: string
slug_title: string
search_metadata: {
score: number
}
series_metadata: {
total: number
data: Array<{
type: string
count: number
items: Array<{
promo_description: string
title: string
promo_title: string
channel_id: string
slug_title: string
search_metadata: {
score: number
}
series_metadata: {
audio_locales: Array<string>
availability_notes: string
episode_count: number
extended_description: string
extended_maturity_rating: string
is_dubbed: boolean
is_mature: boolean
is_simulcast: boolean
is_subbed: boolean
mature_blocked: boolean
maturity_ratings: Array<string>
season_count: number
series_launch_year: number
subtitle_locales: Array<string>
}
id: string
slug: string
external_id: string
description: string
new: boolean
images: {
poster_tall: Array<
Array<{
height: number
source: string
type: string
width: number
}>
>
poster_wide: Array<
Array<{
height: number
source: string
type: string
width: number
}>
>
}
linked_resource_key: string
type: string
}>
}>
}
export interface CrunchyAnimeFetch {
total: number
data: Array<{
promo_description: string
title: string
promo_title: string
channel_id: string
slug_title: string
search_metadata: {
score: number
}
audio_locales: Array<string>
availability_notes: string
episode_count: number
@ -27,212 +82,157 @@ export interface CrunchySearchFetch {
season_count: number
series_launch_year: number
subtitle_locales: Array<string>
}
id: string
slug: string
external_id: string
description: string
new: boolean
images: {
poster_tall: Array<
Array<{
height: number
source: string
type: string
width: number
}>
>
poster_wide: Array<
Array<{
height: number
source: string
type: string
width: number
}>
>
}
linked_resource_key: string
type: string
id: string
slug: string
external_id: string
description: string
new: boolean
images: {
poster_tall: Array<
Array<{
height: number
source: string
type: string
width: number
}>
>
poster_wide: Array<
Array<{
height: number
source: string
type: string
width: number
}>
>
}
linked_resource_key: string
type: string
}>
}>
}
export interface CrunchyAnimeFetch {
total: number
data: Array<{
promo_description: string
title: string
promo_title: string
channel_id: string
slug_title: string
search_metadata: {
score: number
}
audio_locales: Array<string>
availability_notes: string
episode_count: number
extended_description: string
extended_maturity_rating: string
is_dubbed: boolean
is_mature: boolean
is_simulcast: boolean
is_subbed: boolean
mature_blocked: boolean
maturity_ratings: Array<string>
season_count: number
series_launch_year: number
subtitle_locales: Array<string>
id: string
slug: string
external_id: string
description: string
new: boolean
images: {
poster_tall: Array<
Array<{
height: number
source: string
type: string
width: number
}>
>
poster_wide: Array<
Array<{
height: number
source: string
type: string
width: number
}>
>
}
linked_resource_key: string
type: string
}>
}
export interface CrunchyLogin {
access_token: string
refresh_token: string
expires_in: number
token_type: string
scope: string
country: string
account_id: string
profile_id: string
access_token: string
refresh_token: string
expires_in: number
token_type: string
scope: string
country: string
account_id: string
profile_id: string
}
export interface CrunchySeasonsFetch {
total: number
data: Array<{
identifier: string
description: string
is_simulcast: boolean
subtitle_locales: Array<string>
series_id: string
id: string
audio_locales: Array<string>
title: string
versions: Array<{
audio_locale: string
guid: string
original: boolean
variant: string
total: number
data: Array<{
identifier: string
description: string
is_simulcast: boolean
subtitle_locales: Array<string>
series_id: string
id: string
audio_locales: Array<string>
title: string
versions: Array<{
audio_locale: string
guid: string
original: boolean
variant: string
}>
season_sequence_number: number
season_number: number
maturity_ratings: Array<string>
mature_blocked: boolean
channel_id: string
is_subbed: boolean
audio_locale: string
season_display_number: string
is_complete: boolean
season_tags: Array<string>
is_mature: boolean
is_dubbed: boolean
slug_title: string
availability_notes: string
number_of_episodes: boolean
}>
season_sequence_number: number
season_number: number
maturity_ratings: Array<string>
mature_blocked: boolean
channel_id: string
is_subbed: boolean
audio_locale: string
season_display_number: string
is_complete: boolean
season_tags: Array<string>
is_mature: boolean
is_dubbed: boolean
slug_title: string
availability_notes: string
number_of_episodes: boolean
}>
meta: {
versions_considered: boolean
}
meta: {
versions_considered: boolean
}
}
export interface CrunchyEpisodesFetch {
total: number
data: Array<{
closed_captions_available: boolean
availability_notes: string
next_episode_title: string
upload_date: string
versions: Array<{
audio_locale: string
guid: string
is_premium_only: boolean
media_guid: string
original: boolean
season_guid: string
variant: string
}>
season_slug_title: string
series_title: string
season_title: string
sequence_number: number
maturity_ratings: Array<string>
slug_title: string
is_premium_only: boolean
availability_ends: string
identifier: string
recent_variant: string
free_available_date: string
subtitle_locales: Array<string>
series_id: string
mature_blocked: boolean
duration_ms: number
availability_starts: string
audio_locale: string
images: {
thumbnail: Array<
Array<{
height: number
source: string
type: string
width: number
total: number
data: Array<{
closed_captions_available: boolean
availability_notes: string
next_episode_title: string
upload_date: string
versions: Array<{
audio_locale: string
guid: string
is_premium_only: boolean
media_guid: string
original: boolean
season_guid: string
variant: string
}>
>
season_slug_title: string
series_title: string
season_title: string
sequence_number: number
maturity_ratings: Array<string>
slug_title: string
is_premium_only: boolean
availability_ends: string
identifier: string
recent_variant: string
free_available_date: string
subtitle_locales: Array<string>
series_id: string
mature_blocked: boolean
duration_ms: number
availability_starts: string
audio_locale: string
images: {
thumbnail: Array<
Array<{
height: number
source: string
type: string
width: number
}>
>
}
season_sequence_number: number
season_id: string
episode_number: number
listing_id: string
available_date: string
channel_id: string
season_number: number
hd_flag: boolean
recent_audio_locale: string
available_offline: boolean
episode: string
is_subbed: boolean
media_type: string
is_clip: boolean
title: string
streams_link: string
slug: string
id: string
production_episode_id: string
is_dubbed: boolean
next_episode_id: string
series_slug_title: string
season_tags: Array<string>
premium_date: string
is_mature: boolean
premium_available_date: string
description: string
episode_air_date: string
eligible_region: string
}>
meta: {
versions_considered: boolean
}
season_sequence_number: number
season_id: string
episode_number: number
listing_id: string
available_date: string
channel_id: string
season_number: number
hd_flag: boolean
recent_audio_locale: string
available_offline: boolean
episode: string
is_subbed: boolean
media_type: string
is_clip: boolean
title: string
streams_link: string
slug: string
id: string
production_episode_id: string
is_dubbed: boolean
next_episode_id: string
series_slug_title: string
season_tags: Array<string>
premium_date: string
is_mature: boolean
premium_available_date: string
description: string
episode_air_date: string
eligible_region: string
}>
meta: {
versions_considered: boolean
}
}

View File

@ -1,71 +1,73 @@
export interface CrunchyEpisode {
closed_captions_available: boolean,
availability_notes: string,
next_episode_title: string,
upload_date: string,
closed_captions_available: boolean
availability_notes: string
next_episode_title: string
upload_date: string
versions: Array<{
audio_locale: string,
guid: string,
is_premium_only: boolean,
media_guid: string,
original: boolean,
season_guid: string,
audio_locale: string
guid: string
is_premium_only: boolean
media_guid: string
original: boolean
season_guid: string
variant: string
}>,
season_slug_title: string,
series_title: string,
season_title: string,
sequence_number: number,
maturity_ratings: Array<string>,
slug_title: string,
is_premium_only: boolean,
availability_ends: string,
identifier: string,
recent_variant: string,
free_available_date: string,
subtitle_locales: Array<string>,
series_id: string,
mature_blocked: boolean,
duration_ms: number,
availability_starts: string,
audio_locale: string,
}>
season_slug_title: string
series_title: string
season_title: string
sequence_number: number
maturity_ratings: Array<string>
slug_title: string
is_premium_only: boolean
availability_ends: string
identifier: string
recent_variant: string
free_available_date: string
subtitle_locales: Array<string>
series_id: string
mature_blocked: boolean
duration_ms: number
availability_starts: string
audio_locale: string
images: {
thumbnail: Array<Array<{
height: number,
source: string,
type: string,
width: number
}>>
},
season_sequence_number: number,
season_id: string,
episode_number: number,
listing_id: string,
available_date: string,
channel_id: string,
season_number: number,
hd_flag: boolean,
recent_audio_locale: string,
available_offline: boolean,
episode: string,
is_subbed: boolean,
media_type: string,
is_clip: boolean,
title: string,
streams_link: string,
slug: string,
id: string,
production_episode_id: string,
is_dubbed: boolean,
next_episode_id: string,
series_slug_title: string,
season_tags: Array<string>,
premium_date: string,
is_mature: boolean,
premium_available_date: string,
description: string,
episode_air_date: string,
thumbnail: Array<
Array<{
height: number
source: string
type: string
width: number
}>
>
}
season_sequence_number: number
season_id: string
episode_number: number
listing_id: string
available_date: string
channel_id: string
season_number: number
hd_flag: boolean
recent_audio_locale: string
available_offline: boolean
episode: string
is_subbed: boolean
media_type: string
is_clip: boolean
title: string
streams_link: string
slug: string
id: string
production_episode_id: string
is_dubbed: boolean
next_episode_id: string
series_slug_title: string
season_tags: Array<string>
premium_date: string
is_mature: boolean
premium_available_date: string
description: string
episode_air_date: string
eligible_region: string
}
export interface CrunchyEpisodes extends Array<CrunchyEpisode> {}
export interface CrunchyEpisodes extends Array<CrunchyEpisode> {}

View File

@ -1,8 +1,8 @@
const isProduction = process.env.NODE_ENV !== 'development'
export function openNewWindow(urlprod: string, urldev: string, w: string) {
const newWindow = window.open(isProduction ? urlprod : urldev, '_blank', w)
if (newWindow) {
newWindow.focus()
}
}
const newWindow = window.open(isProduction ? urlprod : urldev, '_blank', w)
if (newWindow) {
newWindow.focus()
}
}

View File

@ -1,32 +1,39 @@
<template>
<div class="fixed w-full flex flex-row px-2 bg-[#11111189] h-14 z-10 gap-1" style="-webkit-app-region: drag">
<div class="w-full flex gap-10 flex-row items-center justify-center px-5">
<button @click="openAddAnime" class="flex items-center justify-center px-2 py-2 gap-1 transition-all bg-[#ffffff16] hover:bg-[#ffffff25] rounded-lg select-none" style="-webkit-app-region: no-drag">
<Icon name="ph:plus-bold" class="h-3.5 w-3.5 text-white" />
<div class="text-[11px] text-white font-dm">
ADD DOWNLOAD
<div class="fixed w-full flex flex-row px-2 bg-[#11111189] h-14 z-10 gap-1" style="-webkit-app-region: drag">
<div class="w-full flex gap-10 flex-row items-center justify-center px-5">
<button
@click="openAddAnime"
class="flex items-center justify-center px-2 py-2 gap-1 transition-all bg-[#ffffff16] hover:bg-[#ffffff25] rounded-lg select-none"
style="-webkit-app-region: no-drag"
>
<Icon name="ph:plus-bold" class="h-3.5 w-3.5 text-white" />
<div class="text-[11px] text-white font-dm"> ADD DOWNLOAD </div>
</button>
</div>
</button>
</div>
<div class="w-full flex flex-row items-center justify-center">
<img src="/logo.png" class="h-8">
<div class="text-[10px] leading-[10px] text-opacity-90 text-white select-none">Crunchyroll <br> Downloader</div>
</div>
<div class="w-full flex gap-2 flex-row items-center justify-center">
<!-- <button class="flex items-center justify-center px-2 py-2 gap-1 transition-all bg-[#ffffff16] hover:bg-[#ffffff25] rounded-lg select-none" style="-webkit-app-region: no-drag">
<div class="w-full flex flex-row items-center justify-center">
<img src="/logo.png" class="h-8" />
<div class="text-[10px] leading-[10px] text-opacity-90 text-white select-none"
>Crunchyroll <br />
Downloader</div
>
</div>
<div class="w-full flex gap-2 flex-row items-center justify-center">
<!-- <button class="flex items-center justify-center px-2 py-2 gap-1 transition-all bg-[#ffffff16] hover:bg-[#ffffff25] rounded-lg select-none" style="-webkit-app-region: no-drag">
<Icon name="iconamoon:playlist" class="h-3.5 w-3.5 text-white" />
<div class="text-[11px] text-white font-dm">
PLAYLIST
</div>
</button> -->
<button @click="openSettings" class="flex items-center justify-center px-2 py-2 gap-1 transition-all bg-[#ffffff16] hover:bg-[#ffffff25] rounded-lg select-none" style="-webkit-app-region: no-drag">
<Icon name="ic:round-settings" class="h-3.5 w-3.5 text-white" />
<div class="text-[11px] text-white font-dm">
SETTINGS
<button
@click="openSettings"
class="flex items-center justify-center px-2 py-2 gap-1 transition-all bg-[#ffffff16] hover:bg-[#ffffff25] rounded-lg select-none"
style="-webkit-app-region: no-drag"
>
<Icon name="ic:round-settings" class="h-3.5 w-3.5 text-white" />
<div class="text-[11px] text-white font-dm"> SETTINGS </div>
</button>
</div>
</button>
</div>
</div>
</template>
<script lang="ts" setup>
@ -36,35 +43,35 @@ import { openNewWindow } from './Functions/WindowHandler'
const isProduction = process.env.NODE_ENV !== 'development'
async function openSettings() {
(window as any).myAPI.openWindow({
title: "Settings",
url: isProduction ? 'http://localhost:8079/settings' : 'http://localhost:3000/settings',
width: 600,
height: 700,
backgroundColor: "#111111"
})
;(window as any).myAPI.openWindow({
title: 'Settings',
url: isProduction ? 'http://localhost:8079/settings' : 'http://localhost:3000/settings',
width: 600,
height: 700,
backgroundColor: '#111111'
})
}
async function openAddAnime() {
// const { data, error } = await checkAccount()
// const { data, error } = await checkAccount()
// if (error.value) {
// (window as any).myAPI.openWindow({
// title: "Crunchyroll Login",
// url: isProduction ? 'http://localhost:8079/crunchylogin' : 'http://localhost:3000/crunchylogin',
// width: 600,
// height: 300,
// backgroundColor: "#111111"
// })
// return
// }
// if (error.value) {
// (window as any).myAPI.openWindow({
// title: "Crunchyroll Login",
// url: isProduction ? 'http://localhost:8079/crunchylogin' : 'http://localhost:3000/crunchylogin',
// width: 600,
// height: 300,
// backgroundColor: "#111111"
// })
// return
// }
(window as any).myAPI.openWindow({
title: "Add Anime",
url: isProduction ? 'http://localhost:8079/addanime' : 'http://localhost:3000/addanime',
width: 700,
height: 450,
backgroundColor: "#111111"
})
;(window as any).myAPI.openWindow({
title: 'Add Anime',
url: isProduction ? 'http://localhost:8079/addanime' : 'http://localhost:3000/addanime',
width: 700,
height: 450,
backgroundColor: '#111111'
})
}
</script>

View File

@ -1,43 +1,43 @@
export interface CrunchyrollSearchResult {
ID: string
Url: string
Title: string
Description: string
Dubs: Array<string>
Subs: Array<string>
Episodes: number
Seasons: number
PEGI: Array<string>
Year: number
Images: {
poster_tall: Array<
Array<{
height: number
source: string
type: string
width: number
}>
>
poster_wide: Array<
Array<{
height: number
source: string
type: string
width: number
}>
>
}
ID: string
Url: string
Title: string
Description: string
Dubs: Array<string>
Subs: Array<string>
Episodes: number
Seasons: number
PEGI: Array<string>
Year: number
Images: {
poster_tall: Array<
Array<{
height: number
source: string
type: string
width: number
}>
>
poster_wide: Array<
Array<{
height: number
source: string
type: string
width: number
}>
>
}
}
export interface CrunchyrollSearchResults extends Array<CrunchyrollSearchResult> {}
export interface ADNSearchResult {
id: number
url: string
title: string
image2x: string
episodeCount: number
languages: Array<string>
id: number
url: string
title: string
image2x: string
episodeCount: number
languages: Array<string>
}
export interface ADNSearchResults extends Array<ADNSearchResult> {}

View File

@ -1,33 +1,33 @@
export interface CrunchySeason {
identifier: string
description: string
is_simulcast: boolean
subtitle_locales: Array<string>
series_id: string
id: string
audio_locales: Array<string>
title: string
versions: Array<{
identifier: string
description: string
is_simulcast: boolean
subtitle_locales: Array<string>
series_id: string
id: string
audio_locales: Array<string>
title: string
versions: Array<{
audio_locale: string
guid: string
original: boolean
variant: string
}>
season_sequence_number: number
season_number: number
maturity_ratings: Array<string>
mature_blocked: boolean
channel_id: string
is_subbed: boolean
audio_locale: string
guid: string
original: boolean
variant: string
}>
season_sequence_number: number
season_number: number
maturity_ratings: Array<string>
mature_blocked: boolean
channel_id: string
is_subbed: boolean
audio_locale: string
season_display_number: string
is_complete: boolean
season_tags: Array<string>
is_mature: boolean
is_dubbed: boolean
slug_title: string
availability_notes: string
number_of_episodes: boolean
season_display_number: string
is_complete: boolean
season_tags: Array<string>
is_mature: boolean
is_dubbed: boolean
slug_title: string
availability_notes: string
number_of_episodes: boolean
}
export interface CrunchySeasons extends Array<CrunchySeason> {}

View File

@ -1,25 +1,29 @@
<template>
<div
class="fixed bottom-3 right-5 p-3 flex flex-col bg-[#111111dc] w-80 min-h-24 rounded-xl font-dm text-white transition-all duration-300"
:class="data?.status === 'update-available' && !ignoreUpdate || data?.status === 'downloading' || data?.status === 'update-downloaded' ? 'opacity-100' : 'opacity-0 pointer-events-none'"
>
<button @click="ignoreUpdate = true" class="absolute right-3 top-2">
<Icon name="akar-icons:cross" class="h-4 w-4 text-white" />
</button>
<div class="text-base text-center"> Update available </div>
<div class="text-sm text-center"> A new update is available </div>
<div v-if="data && data.info && data.info.version" class="text-sm text-center"> v{{ data.info.version }} </div>
<button @click="startDownload" v-if="data && data.status === 'update-available'" class="text-sm py-3 bg-[#363434] mt-5 rounded-xl" :disabled="downloading">
Download Update
</button>
<button v-if="data && data.status === 'downloading'" class="relative text-sm py-3 bg-[#363434] mt-5 rounded-xl overflow-hidden">
<div class="absolute top-0 left-0 w-full h-full bg-[#a1a1a141] transition-all duration-300" :style="`width: calc((${data.info.percent} / 100) * 100%);`"></div>
Downloading...
</button>
<button @click="startInstall" v-if="data && data.status === 'update-downloaded'" class="text-sm py-3 bg-[#363434] mt-5 rounded-xl" :disabled="installing">
Install Update
</button>
</div>
<div
class="fixed bottom-3 right-5 p-3 flex flex-col bg-[#111111dc] w-80 min-h-24 rounded-xl font-dm text-white transition-all duration-300"
:class="
(data?.status === 'update-available' && !ignoreUpdate) || data?.status === 'downloading' || data?.status === 'update-downloaded'
? 'opacity-100'
: 'opacity-0 pointer-events-none'
"
>
<button @click="ignoreUpdate = true" class="absolute right-3 top-2">
<Icon name="akar-icons:cross" class="h-4 w-4 text-white" />
</button>
<div class="text-base text-center"> Update available </div>
<div class="text-sm text-center"> A new update is available </div>
<div v-if="data && data.info && data.info.version" class="text-sm text-center"> v{{ data.info.version }} </div>
<button @click="startDownload" v-if="data && data.status === 'update-available'" class="text-sm py-3 bg-[#363434] mt-5 rounded-xl" :disabled="downloading">
Download Update
</button>
<button v-if="data && data.status === 'downloading'" class="relative text-sm py-3 bg-[#363434] mt-5 rounded-xl overflow-hidden">
<div class="absolute top-0 left-0 w-full h-full bg-[#a1a1a141] transition-all duration-300" :style="`width: calc((${data.info.percent} / 100) * 100%);`"></div>
Downloading...
</button>
<button @click="startInstall" v-if="data && data.status === 'update-downloaded'" class="text-sm py-3 bg-[#363434] mt-5 rounded-xl" :disabled="installing">
Install Update
</button>
</div>
</template>
<script lang="ts" setup>
@ -29,25 +33,25 @@ const installing = ref<boolean>(false)
const ignoreUpdate = ref<boolean>(false)
const checkUpdate = () => {
;(window as any).myAPI.getUpdateStatus().then((result: any) => {
data.value = result
})
;(window as any).myAPI.getUpdateStatus().then((result: any) => {
data.value = result
})
}
const startDownload = () => {
downloading.value = true
;(window as any).myAPI.startUpdateDownload()
downloading.value = true
;(window as any).myAPI.startUpdateDownload()
}
const startInstall = () => {
installing.value = true
;(window as any).myAPI.startUpdateInstall()
installing.value = true
;(window as any).myAPI.startUpdateInstall()
}
onMounted(() => {
checkUpdate()
checkUpdate()
setInterval(checkUpdate, 2000)
setInterval(checkUpdate, 2000)
})
</script>

View File

@ -1,67 +1,67 @@
{
"name": "crunchyroll-downloader",
"author": "Stratum",
"description": "Crunchyroll Downloader",
"version": "1.0.7",
"private": true,
"main": ".output/src/electron/background.js",
"repository": "https://github.com/stratuma/Crunchyroll-Downloader-v4.0",
"scripts": {
"dev": "nuxt dev -o",
"build": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare && electron-builder install-app-deps",
"transpile-src": "tsc -p ./src --outDir .output/src",
"dev:electron": "NODE_ENV=development concurrently --kill-others \"nuxt dev\" \"tsc-watch -p ./src --outDir .output/src --onSuccess 'electron ./.output/src/electron/background.js'\"",
"dev:electron:win": "set NODE_ENV=development& concurrently --kill-others \"nuxt dev\" \"tsc-watch -p ./src --outDir .output/src --onSuccess run.electron\"",
"build:electron": "pnpm build && pnpm transpile-src && node build.js"
},
"devDependencies": {
"7zip-bin": "^5.2.0",
"@nuxtjs/eslint-config-typescript": "^12.1.0",
"@nuxtjs/google-fonts": "^3.2.0",
"@nuxtjs/tailwindcss": "^6.12.0",
"@pinia/nuxt": "^0.4.11",
"@types/express": "^4.17.21",
"concurrently": "^8.2.2",
"dotenv": "^16.4.5",
"electron": "^30.0.1",
"electron-builder": "^24.13.3",
"eslint": "^8.57.0",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-prettier": "^4.2.1",
"nuxt": "^3.11.2",
"nuxt-icon": "^0.6.10",
"prettier": "^2.8.8",
"sass": "^1.75.0",
"sass-loader": "^13.3.3",
"tsc-watch": "^6.2.0",
"typescript": "^5.4.5",
"wait-on": "^7.2.0"
},
"dependencies": {
"@fastify/cors": "^9.0.1",
"@types/crypto-js": "^4.2.2",
"@types/fluent-ffmpeg": "^2.1.24",
"@types/node-cron": "^3.0.11",
"ass-compiler": "^0.1.11",
"crypto-js": "^4.2.0",
"electron-log": "^5.1.2",
"electron-settings": "^4.0.4",
"electron-updater": "^6.1.8",
"express": "^4.19.2",
"fastify": "^4.26.2",
"fluent-ffmpeg": "^2.1.2",
"jsencrypt": "^3.3.2",
"mpd-parser": "^1.3.0",
"node-cache": "^5.1.2",
"node-cron": "^3.0.3",
"sequelize": "^6.37.3",
"sqlite3": "5.1.6"
},
"build": {
"extraResources": [
"./ffmpeg/**"
]
}
"name": "crunchyroll-downloader",
"author": "Stratum",
"description": "Crunchyroll Downloader",
"version": "1.0.7",
"private": true,
"main": ".output/src/electron/background.js",
"repository": "https://github.com/stratuma/Crunchyroll-Downloader-v4.0",
"scripts": {
"dev": "nuxt dev -o",
"build": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare && electron-builder install-app-deps",
"transpile-src": "tsc -p ./src --outDir .output/src",
"dev:electron": "NODE_ENV=development concurrently --kill-others \"nuxt dev\" \"tsc-watch -p ./src --outDir .output/src --onSuccess 'electron ./.output/src/electron/background.js'\"",
"dev:electron:win": "set NODE_ENV=development& concurrently --kill-others \"nuxt dev\" \"tsc-watch -p ./src --outDir .output/src --onSuccess run.electron\"",
"build:electron": "pnpm build && pnpm transpile-src && node build.ts",
"prettier:fix": "pnpm prettier src --write && pnpm prettier components --write && pnpm prettier pages --write && pnpm prettier build.ts --write"
},
"devDependencies": {
"7zip-bin": "^5.2.0",
"@nuxtjs/eslint-config-typescript": "^12.1.0",
"@nuxtjs/google-fonts": "^3.2.0",
"@nuxtjs/tailwindcss": "^6.12.0",
"@pinia/nuxt": "^0.4.11",
"@types/express": "^4.17.21",
"concurrently": "^8.2.2",
"dotenv": "^16.4.5",
"electron": "^30.0.1",
"electron-builder": "^24.13.3",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-prettier": "^4.2.1",
"nuxt": "^3.11.2",
"nuxt-icon": "^0.6.10",
"prettier": "^3.2.5",
"sass": "^1.75.0",
"sass-loader": "^13.3.3",
"tsc-watch": "^6.2.0",
"typescript": "^5.4.5",
"wait-on": "^7.2.0"
},
"dependencies": {
"@fastify/cors": "^9.0.1",
"@types/crypto-js": "^4.2.2",
"@types/fluent-ffmpeg": "^2.1.24",
"@types/node-cron": "^3.0.11",
"ass-compiler": "^0.1.11",
"crypto-js": "^4.2.0",
"electron-log": "^5.1.2",
"electron-settings": "^4.0.4",
"electron-updater": "^6.1.8",
"express": "^4.19.2",
"fastify": "^4.26.2",
"fluent-ffmpeg": "^2.1.2",
"jsencrypt": "^3.3.2",
"mpd-parser": "^1.3.0",
"node-cache": "^5.1.2",
"node-cron": "^3.0.3",
"sequelize": "^6.37.3",
"sqlite3": "5.1.6"
},
"build": {
"extraResources": [
"./ffmpeg/**"
]
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,28 +1,28 @@
<template>
<div class="h-screen overflow-hidden bg-[#11111189] flex flex-col p-5 text-white font-dm" style="-webkit-app-region: drag">
<div class="relative flex flex-row items-center justify-center">
<div class="text-2xl">ADN Login</div>
</div>
<div class="flex flex-col mt-5 gap-3.5 h-full" style="-webkit-app-region: no-drag">
<div class="relative flex flex-col">
<input v-model="username" type="text" name="text" placeholder="Email" class="bg-[#5c5b5b] focus:outline-none px-3 py-3 rounded-xl text-sm text-center" />
</div>
<div class="relative flex flex-col">
<input v-model="password" type="password" name="text" placeholder="Password" class="bg-[#5c5b5b] focus:outline-none px-3 py-3 rounded-xl text-sm text-center" />
</div>
</div>
<div class="relative flex flex-col mt-auto">
<button @click="login" class="relative py-3 border-2 rounded-xl flex flex-row items-center justify-center" style="-webkit-app-region: no-drag">
<div class="flex flex-row items-center justify-center transition-all" :class="isLoggingIn ? 'opacity-0' : 'opacity-100'">
<div class="text-xl">Login</div>
<div class="h-screen overflow-hidden bg-[#11111189] flex flex-col p-5 text-white font-dm" style="-webkit-app-region: drag">
<div class="relative flex flex-row items-center justify-center">
<div class="text-2xl">ADN Login</div>
</div>
<div class="absolute flex flex-row items-center justify-center gap-1 transition-all" :class="isLoggingIn ? 'opacity-100' : 'opacity-0'">
<Icon name="mdi:loading" class="h-6 w-6 animate-spin" />
<div class="text-xl">Logging in</div>
<div class="flex flex-col mt-5 gap-3.5 h-full" style="-webkit-app-region: no-drag">
<div class="relative flex flex-col">
<input v-model="username" type="text" name="text" placeholder="Email" class="bg-[#5c5b5b] focus:outline-none px-3 py-3 rounded-xl text-sm text-center" />
</div>
<div class="relative flex flex-col">
<input v-model="password" type="password" name="text" placeholder="Password" class="bg-[#5c5b5b] focus:outline-none px-3 py-3 rounded-xl text-sm text-center" />
</div>
</div>
<div class="relative flex flex-col mt-auto">
<button @click="login" class="relative py-3 border-2 rounded-xl flex flex-row items-center justify-center" style="-webkit-app-region: no-drag">
<div class="flex flex-row items-center justify-center transition-all" :class="isLoggingIn ? 'opacity-0' : 'opacity-100'">
<div class="text-xl">Login</div>
</div>
<div class="absolute flex flex-row items-center justify-center gap-1 transition-all" :class="isLoggingIn ? 'opacity-100' : 'opacity-0'">
<Icon name="mdi:loading" class="h-6 w-6 animate-spin" />
<div class="text-xl">Logging in</div>
</div>
</button>
</div>
</button>
</div>
</div>
</template>
<script lang="ts" setup>
@ -35,54 +35,54 @@ const password = ref<string>()
const isLoggingIn = ref<number>(0)
const login = async () => {
isLoggingIn.value++
if (!username.value) {
isLoggingIn.value--
return
}
if (!password.value) {
isLoggingIn.value--
return
}
isLoggingIn.value++
if (!username.value) {
isLoggingIn.value--
return
}
if (!password.value) {
isLoggingIn.value--
return
}
const { data, error } = await loginAccount(username.value, password.value, 'ADN')
const { data, error } = await loginAccount(username.value, password.value, 'ADN')
if (error.value) {
if (error.value) {
isLoggingIn.value--
return
}
isLoggingIn.value--
return
}
isLoggingIn.value--
close()
close()
}
</script>
<style>
.font-dm {
font-family: "DM Sans", sans-serif;
font-family: 'DM Sans', sans-serif;
}
.font-protest {
font-family: "Protest Riot", sans-serif;
font-family: 'Protest Riot', sans-serif;
font-weight: 400;
font-style: normal;
}
.font-dm-big {
font-family: "DM Sans", sans-serif;
font-family: 'DM Sans', sans-serif;
font-weight: 1000;
font-style: normal;
}
@keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
from {
opacity: 0;
}
to {
opacity: 1;
}
}
body {
animation: fadein 0.5s;
animation: fadein 0.5s;
}
</style>

View File

@ -1,28 +1,28 @@
<template>
<div class="h-screen overflow-hidden bg-[#11111189] flex flex-col p-5 text-white font-dm" style="-webkit-app-region: drag">
<div class="relative flex flex-row items-center justify-center">
<div class="text-2xl">Crunchyroll Login</div>
</div>
<div class="flex flex-col mt-5 gap-3.5 h-full" style="-webkit-app-region: no-drag">
<div class="relative flex flex-col">
<input v-model="username" type="text" name="text" placeholder="Email" class="bg-[#5c5b5b] focus:outline-none px-3 py-3 rounded-xl text-sm text-center" />
</div>
<div class="relative flex flex-col">
<input v-model="password" type="password" name="text" placeholder="Password" class="bg-[#5c5b5b] focus:outline-none px-3 py-3 rounded-xl text-sm text-center" />
</div>
</div>
<div class="relative flex flex-col mt-auto">
<button @click="login" class="relative py-3 border-2 rounded-xl flex flex-row items-center justify-center" style="-webkit-app-region: no-drag">
<div class="flex flex-row items-center justify-center transition-all" :class="isLoggingIn ? 'opacity-0' : 'opacity-100'">
<div class="text-xl">Login</div>
<div class="h-screen overflow-hidden bg-[#11111189] flex flex-col p-5 text-white font-dm" style="-webkit-app-region: drag">
<div class="relative flex flex-row items-center justify-center">
<div class="text-2xl">Crunchyroll Login</div>
</div>
<div class="absolute flex flex-row items-center justify-center gap-1 transition-all" :class="isLoggingIn ? 'opacity-100' : 'opacity-0'">
<Icon name="mdi:loading" class="h-6 w-6 animate-spin" />
<div class="text-xl">Logging in</div>
<div class="flex flex-col mt-5 gap-3.5 h-full" style="-webkit-app-region: no-drag">
<div class="relative flex flex-col">
<input v-model="username" type="text" name="text" placeholder="Email" class="bg-[#5c5b5b] focus:outline-none px-3 py-3 rounded-xl text-sm text-center" />
</div>
<div class="relative flex flex-col">
<input v-model="password" type="password" name="text" placeholder="Password" class="bg-[#5c5b5b] focus:outline-none px-3 py-3 rounded-xl text-sm text-center" />
</div>
</div>
<div class="relative flex flex-col mt-auto">
<button @click="login" class="relative py-3 border-2 rounded-xl flex flex-row items-center justify-center" style="-webkit-app-region: no-drag">
<div class="flex flex-row items-center justify-center transition-all" :class="isLoggingIn ? 'opacity-0' : 'opacity-100'">
<div class="text-xl">Login</div>
</div>
<div class="absolute flex flex-row items-center justify-center gap-1 transition-all" :class="isLoggingIn ? 'opacity-100' : 'opacity-0'">
<Icon name="mdi:loading" class="h-6 w-6 animate-spin" />
<div class="text-xl">Logging in</div>
</div>
</button>
</div>
</button>
</div>
</div>
</template>
<script lang="ts" setup>
@ -35,54 +35,54 @@ const password = ref<string>()
const isLoggingIn = ref<number>(0)
const login = async () => {
isLoggingIn.value++
if (!username.value) {
isLoggingIn.value--
return
}
if (!password.value) {
isLoggingIn.value--
return
}
isLoggingIn.value++
if (!username.value) {
isLoggingIn.value--
return
}
if (!password.value) {
isLoggingIn.value--
return
}
const { data, error } = await loginAccount(username.value, password.value, 'CR')
const { data, error } = await loginAccount(username.value, password.value, 'CR')
if (error.value) {
if (error.value) {
isLoggingIn.value--
return
}
isLoggingIn.value--
return
}
isLoggingIn.value--
close()
close()
}
</script>
<style>
.font-dm {
font-family: "DM Sans", sans-serif;
font-family: 'DM Sans', sans-serif;
}
.font-protest {
font-family: "Protest Riot", sans-serif;
font-family: 'Protest Riot', sans-serif;
font-weight: 400;
font-style: normal;
}
.font-dm-big {
font-family: "DM Sans", sans-serif;
font-family: 'DM Sans', sans-serif;
font-weight: 1000;
font-style: normal;
}
@keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
from {
opacity: 0;
}
to {
opacity: 1;
}
}
body {
animation: fadein 0.5s;
animation: fadein 0.5s;
}
</style>

View File

@ -1,70 +1,74 @@
<template>
<div class="relative h-screen overflow-hidden">
<Updater />
<MainHeader />
<div class="flex flex-col text-white gap-5 mt-14 p-5 overflow-y-scroll h-[calc(100vh-3.5rem)]">
<!-- <button @click="deletePlaylist">
<div class="relative h-screen overflow-hidden">
<Updater />
<MainHeader />
<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" :style="`width: calc((${p.partsdownloaded} / ${p.partsleft}) * 100%);`"></div>
<div class="absolute h-full w-full flex flex-row gap-3 p-3.5">
<div v-if="p.service === 'CR'" class="flex w-48 min-w-48">
<img :src="(p.media as CrunchyEpisode).images.thumbnail[0].find((p) => p.height === 1080)?.source" alt="Image" class="object-cover rounded-lg" />
</div>
<div v-if="p.service === 'ADN'" class="flex min-w-52 w-52">
<img :src="(p.media as ADNEpisode).image2x" alt="Image" class="object-cover rounded-lg" />
</div>
<div class="flex flex-col w-full">
<div class="flex flex-row h-full">
<div class="flex flex-col">
<div v-if="p.status === 'waiting'" class="flex flex-row items-center justify-center gap-1 text-xs capitalize p-1.5 bg-[#866332] rounded-lg">
<Icon name="mdi:clock" class="h-3.5 w-3.5 text-white" />
{{ p.status }}
<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"
:style="`width: calc((${p.partsdownloaded} / ${p.partsleft}) * 100%);`"
></div>
<div class="absolute h-full w-full flex flex-row gap-3 p-3.5">
<div v-if="p.service === 'CR'" class="flex w-48 min-w-48">
<img :src="(p.media as CrunchyEpisode).images.thumbnail[0].find((p) => p.height === 1080)?.source" alt="Image" class="object-cover rounded-lg" />
</div>
<div v-if="p.service === 'ADN'" class="flex min-w-52 w-52">
<img :src="(p.media as ADNEpisode).image2x" alt="Image" class="object-cover rounded-lg" />
</div>
<div class="flex flex-col w-full">
<div class="flex flex-row h-full">
<div class="flex flex-col">
<div v-if="p.status === 'waiting'" class="flex flex-row items-center justify-center gap-1 text-xs capitalize p-1.5 bg-[#866332] rounded-lg">
<Icon name="mdi:clock" class="h-3.5 w-3.5 text-white" />
{{ p.status }}
</div>
<div v-if="p.status === 'preparing'" class="flex flex-row items-center justify-center gap-1 text-xs capitalize p-1.5 bg-[#866332] rounded-lg">
<Icon name="mdi:clock" class="h-3.5 w-3.5 text-white" />
{{ p.status }}
</div>
<div v-if="p.status === 'downloading'" class="flex flex-row items-center justify-center gap-1 text-xs capitalize p-1.5 bg-[#60501b] rounded-lg">
<Icon name="mdi:loading" class="h-3.5 w-3.5 text-white animate-spin" />
{{ p.status }}
</div>
<div v-if="p.status === 'merging'" class="flex flex-row items-center justify-center gap-1 text-xs capitalize p-1.5 bg-[#866332] rounded-lg">
<Icon name="mdi:loading" class="h-3.5 w-3.5 text-white animate-spin" />
{{ p.status }}
</div>
<div v-if="p.status === 'completed'" class="flex flex-row items-center justify-center gap-1 text-xs capitalize p-1.5 bg-[#266326] rounded-lg">
<Icon name="material-symbols:check" class="h-3.5 w-3.5 text-white" />
{{ p.status }}
</div>
</div>
<div class="text-xs capitalize ml-auto">
{{ p.service === 'CR' ? 'Crunchyroll' : 'ADN' }}
</div>
</div>
<div v-if="p.service === 'CR'" class="text-base capitalize h-full flex items-center">
{{ (p.media as CrunchyEpisode).series_title }} Season {{ (p.media as CrunchyEpisode).season_number }} Episode
{{ (p.media as CrunchyEpisode).episode_number }}
</div>
<div v-if="p.service === 'ADN'" class="text-base capitalize h-full">
{{ (p.media as ADNEpisode).show.title }} Season {{ (p.media as ADNEpisode).season ? (p.media as ADNEpisode).season : 1 }} Episode
{{ (p.media as ADNEpisode).shortNumber }}
</div>
<div class="flex flex-row gap-2 h-full items-end">
<div class="text-xs">{{ p.quality }}p</div>
<div class="text-xs uppercase">{{ p.format }}</div>
<div class="text-xs">Dubs: {{ p.dub.map((t) => t.name).join(', ') }}</div>
<div class="text-xs">Subs: {{ p.sub.length !== 0 ? p.sub.map((t) => t.name).join(', ') : '-' }}</div>
<div class="flex flex-col ml-auto gap-0.5">
<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">{{ p.downloadspeed }} MB/s</div>
</div>
</div>
</div>
</div>
<div v-if="p.status === 'preparing'" class="flex flex-row items-center justify-center gap-1 text-xs capitalize p-1.5 bg-[#866332] rounded-lg">
<Icon name="mdi:clock" class="h-3.5 w-3.5 text-white" />
{{ p.status }}
</div>
<div v-if="p.status === 'downloading'" class="flex flex-row items-center justify-center gap-1 text-xs capitalize p-1.5 bg-[#60501b] rounded-lg">
<Icon name="mdi:loading" class="h-3.5 w-3.5 text-white animate-spin" />
{{ p.status }}
</div>
<div v-if="p.status === 'merging'" class="flex flex-row items-center justify-center gap-1 text-xs capitalize p-1.5 bg-[#866332] rounded-lg">
<Icon name="mdi:loading" class="h-3.5 w-3.5 text-white animate-spin" />
{{ p.status }}
</div>
<div v-if="p.status === 'completed'" class="flex flex-row items-center justify-center gap-1 text-xs capitalize p-1.5 bg-[#266326] rounded-lg">
<Icon name="material-symbols:check" class="h-3.5 w-3.5 text-white" />
{{ p.status }}
</div>
</div>
<div class="text-xs capitalize ml-auto">
{{ p.service === 'CR' ? 'Crunchyroll' : 'ADN' }}
</div>
</div>
<div v-if="p.service === 'CR'" class="text-base capitalize h-full flex items-center">
{{ (p.media as CrunchyEpisode).series_title }} Season {{ (p.media as CrunchyEpisode).season_number }} Episode {{ (p.media as CrunchyEpisode).episode_number }}
</div>
<div v-if="p.service === 'ADN'" class="text-base capitalize h-full">
{{ (p.media as ADNEpisode).show.title }} Season {{ (p.media as ADNEpisode).season ? (p.media as ADNEpisode).season : 1 }} Episode
{{ (p.media as ADNEpisode).shortNumber }}
</div>
<div class="flex flex-row gap-2 h-full items-end">
<div class="text-xs">{{ p.quality }}p</div>
<div class="text-xs uppercase">{{ p.format }}</div>
<div class="text-xs">Dubs: {{ p.dub.map((t) => t.name).join(', ') }}</div>
<div class="text-xs">Subs: {{ p.sub.length !== 0 ? p.sub.map((t) => t.name).join(', ') : '-' }}</div>
<div class="flex flex-col ml-auto gap-0.5">
<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">{{ p.downloadspeed }} MB/s</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script lang="ts" setup>
@ -73,144 +77,144 @@ import type { CrunchyEpisode } from '~/components/Episode/Types'
import Updater from '~/components/Updater.vue'
const playlist = ref<
Array<{
id: number
status: string
media: CrunchyEpisode | ADNEpisode
dub: Array<{ locale: string; name: string }>
sub: Array<{ locale: string; name: string }>
dir: string
partsleft: number
partsdownloaded: number
downloadspeed: number
quality: number
service: string
format: string
}>
Array<{
id: number
status: string
media: CrunchyEpisode | ADNEpisode
dub: Array<{ locale: string; name: string }>
sub: Array<{ locale: string; name: string }>
dir: string
partsleft: number
partsdownloaded: number
downloadspeed: number
quality: number
service: string
format: string
}>
>()
const getPlaylist = async () => {
const { data, error } = await useFetch<
Array<{
id: number
status: string
media: CrunchyEpisode | ADNEpisode
dub: Array<{ locale: string; name: string }>
sub: Array<{ locale: string; name: string }>
dir: string
partsleft: number
partsdownloaded: number
downloadspeed: number
quality: number
service: string
format: string
}>
>('http://localhost:8080/api/service/playlist')
const { data, error } = await useFetch<
Array<{
id: number
status: string
media: CrunchyEpisode | ADNEpisode
dub: Array<{ locale: string; name: string }>
sub: Array<{ locale: string; name: string }>
dir: string
partsleft: number
partsdownloaded: number
downloadspeed: number
quality: number
service: string
format: string
}>
>('http://localhost:8080/api/service/playlist')
if (error.value) {
alert(error.value)
return
}
if (error.value) {
alert(error.value)
return
}
if (!data.value) {
return
}
if (!data.value) {
return
}
playlist.value = data.value
playlist.value = data.value
}
const deletePlaylist = async () => {
const { data, error } = await useFetch('http://localhost:8080/api/service/playlist', {
method: 'delete'
})
const { data, error } = await useFetch('http://localhost:8080/api/service/playlist', {
method: 'delete'
})
if (error.value) {
alert(error.value)
return
}
if (error.value) {
alert(error.value)
return
}
if (!data.value) {
return
}
if (!data.value) {
return
}
}
onMounted(() => {
getPlaylist()
getPlaylist()
setInterval(getPlaylist, 1000)
setInterval(getPlaylist, 1000)
})
</script>
<style>
body {
background: none;
background-color: none;
background: transparent;
background-color: transparent;
background: none;
background-color: none;
background: transparent;
background-color: transparent;
}
.font-dm {
font-family: 'DM Sans', sans-serif;
font-family: 'DM Sans', sans-serif;
}
.font-protest {
font-family: 'Protest Riot', sans-serif;
font-weight: 400;
font-style: normal;
font-family: 'Protest Riot', sans-serif;
font-weight: 400;
font-style: normal;
}
.font-dm-big {
font-family: 'DM Sans', sans-serif;
font-weight: 1000;
font-style: normal;
font-family: 'DM Sans', sans-serif;
font-weight: 1000;
font-style: normal;
}
.loading-a {
animation: animation infinite 3s;
animation: animation infinite 3s;
}
::-webkit-scrollbar-track {
background: #383838;
background: #383838;
}
/* Handle */
::-webkit-scrollbar-thumb {
background: #cac9c9;
background: #cac9c9;
}
/* Handle on hover */
::-webkit-scrollbar-thumb:hover {
background: #555;
background: #555;
}
::-webkit-scrollbar {
width: 10px;
width: 10px;
}
@keyframes animation {
0% {
left: 0%;
}
0% {
left: 0%;
}
50% {
left: 88%;
}
50% {
left: 88%;
}
100% {
left: 0%;
}
100% {
left: 0%;
}
}
@keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
from {
opacity: 0;
}
to {
opacity: 1;
}
}
body {
animation: fadein 0.5s;
animation: fadein 0.5s;
}
</style>

View File

@ -1,19 +1,19 @@
<template>
<div class="h-screen bg-[#111111] flex flex-col p-5 text-white" style="-webkit-app-region: drag">
<div class="flex flex-row items-center justify-center">
<div class="text-2xl">Settings</div>
<div class="h-screen bg-[#111111] flex flex-col p-5 text-white" style="-webkit-app-region: drag">
<div class="flex flex-row items-center justify-center">
<div class="text-2xl">Settings</div>
</div>
<div class="flex flex-row mt-2" style="-webkit-app-region: no-drag">
<button
v-for="(option, index) in options"
@click="activeIndex = index"
class="w-full flex items-center justify-center py-2 border-b-2 transition-all"
:class="activeIndex === index ? 'border-[#ce6104]' : 'border-[#ce620428]'"
>
{{ option }}
</button>
</div>
</div>
<div class="flex flex-row mt-2" style="-webkit-app-region: no-drag">
<button
v-for="(option, index) in options"
@click="activeIndex = index"
class="w-full flex items-center justify-center py-2 border-b-2 transition-all"
:class="activeIndex === index ? 'border-[#ce6104]' : 'border-[#ce620428]'"
>
{{ option }}
</button>
</div>
</div>
</template>
<script lang="ts" setup>
@ -23,15 +23,15 @@ const activeIndex = ref(0)
<style>
@keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
from {
opacity: 0;
}
to {
opacity: 1;
}
}
body {
animation: fadein 0.5s;
animation: fadein 0.5s;
}
</style>

File diff suppressed because it is too large Load Diff

View File

@ -1,2 +0,0 @@
@echo off
wait-on http://localhost:3000 && electron ./.output/src/electron/background.js

View File

@ -1,46 +1,45 @@
import fastify from "fastify";
import cors from "@fastify/cors";
import NodeCache from "node-cache";
import crunchyrollRoutes from "./routes/crunchyroll/crunchyroll.route";
import { sequelize } from "./db/database";
import serviceRoutes from "./routes/service/service.route";
(async () => {
import fastify from 'fastify'
import cors from '@fastify/cors'
import NodeCache from 'node-cache'
import crunchyrollRoutes from './routes/crunchyroll/crunchyroll.route'
import { sequelize } from './db/database'
import serviceRoutes from './routes/service/service.route'
;(async () => {
try {
await sequelize.authenticate();
console.log("Connection has been established successfully.");
await sequelize.authenticate()
console.log('Connection has been established successfully.')
} catch (error) {
console.error("Unable to connect to the database:", error);
console.error('Unable to connect to the database:', error)
}
try {
await sequelize.sync();
console.log("All models were synchronized successfully.");
await sequelize.sync()
console.log('All models were synchronized successfully.')
} catch (error) {
console.log("Failed to synchronize Models");
console.log('Failed to synchronize Models')
}
})();
})()
const CacheController = new NodeCache({ stdTTL: 100, checkperiod: 120 });
const CacheController = new NodeCache({ stdTTL: 100, checkperiod: 120 })
export const server = fastify();
export const server = fastify()
// Cors registration
server.register(cors, {
origin: "*",
methods: ["GET", "POST", "PUT", "DELETE"],
allowedHeaders: ["Content-Type", "Authorization"],
});
origin: '*',
methods: ['GET', 'POST', 'PUT', 'DELETE'],
allowedHeaders: ['Content-Type', 'Authorization']
})
// Cache Controller Type
declare module "fastify" {
declare module 'fastify' {
interface FastifyInstance {
CacheController: NodeCache;
CacheController: NodeCache
}
}
// Cache Controller
server.decorate("CacheController", CacheController);
server.decorate('CacheController', CacheController)
// Routes
server.register(crunchyrollRoutes, { prefix: 'api/crunchyroll' })
@ -49,11 +48,11 @@ server.register(serviceRoutes, { prefix: 'api/service' })
function startAPI() {
server.listen({ port: 8080 }, (err, address) => {
if (err) {
console.error(err);
return;
console.error(err)
return
}
console.log(`Server is listening on ${address}`);
});
console.log(`Server is listening on ${address}`)
})
}
export default startAPI;
export default startAPI

View File

@ -4,139 +4,139 @@ import { CrunchyEpisode } from '../types/crunchyroll'
import { ADNEpisode } from '../types/adn'
const sequelize = new Sequelize({
dialect: 'sqlite',
storage: app.getPath('documents') + '/crd-dbv2.db'
dialect: 'sqlite',
storage: app.getPath('documents') + '/crd-dbv2.db'
})
interface AccountAttributes {
id: number
username: string
password: string
service: string
id: number
username: string
password: string
service: string
}
interface AccountCreateAttributes {
username: string
password: string
service: string
username: string
password: string
service: string
}
interface AccountCreateAttributes {
username: string
password: string
service: string
username: string
password: string
service: string
}
interface PlaylistAttributes {
id: number
status: 'waiting' | 'preparing' | 'downloading' | 'merging' | 'completed' | 'failed'
media: CrunchyEpisode | ADNEpisode
dub: Array<string>
sub: Array<string>
hardsub: boolean
quality: 1080 | 720 | 480 | 360 | 240
dir: string
failedreason: string,
service: 'CR' | 'ADN',
format: 'mp4' | 'mkv'
id: number
status: 'waiting' | 'preparing' | 'downloading' | 'merging' | 'completed' | 'failed'
media: CrunchyEpisode | ADNEpisode
dub: Array<string>
sub: Array<string>
hardsub: boolean
quality: 1080 | 720 | 480 | 360 | 240
dir: string
failedreason: string
service: 'CR' | 'ADN'
format: 'mp4' | 'mkv'
}
interface PlaylistCreateAttributes {
media: CrunchyEpisode | ADNEpisode
dub: Array<string>
sub: Array<string>
dir: string
quality: 1080 | 720 | 480 | 360 | 240
hardsub: boolean
status: 'waiting' | 'preparing' | 'downloading' | 'merging' | 'completed' | 'failed',
service: 'CR' | 'ADN',
format: 'mp4' | 'mkv'
media: CrunchyEpisode | ADNEpisode
dub: Array<string>
sub: Array<string>
dir: string
quality: 1080 | 720 | 480 | 360 | 240
hardsub: boolean
status: 'waiting' | 'preparing' | 'downloading' | 'merging' | 'completed' | 'failed'
service: 'CR' | 'ADN'
format: 'mp4' | 'mkv'
}
const Account: ModelDefined<AccountAttributes, AccountCreateAttributes> = sequelize.define('Accounts', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: DataTypes.INTEGER
},
username: {
allowNull: false,
type: DataTypes.STRING
},
password: {
allowNull: false,
type: DataTypes.STRING
},
service: {
allowNull: false,
type: DataTypes.STRING
},
createdAt: {
allowNull: false,
type: DataTypes.DATE
},
updatedAt: {
allowNull: false,
type: DataTypes.DATE
}
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: DataTypes.INTEGER
},
username: {
allowNull: false,
type: DataTypes.STRING
},
password: {
allowNull: false,
type: DataTypes.STRING
},
service: {
allowNull: false,
type: DataTypes.STRING
},
createdAt: {
allowNull: false,
type: DataTypes.DATE
},
updatedAt: {
allowNull: false,
type: DataTypes.DATE
}
})
const Playlist: ModelDefined<PlaylistAttributes, PlaylistCreateAttributes> = sequelize.define('Playlist', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: DataTypes.INTEGER
},
status: {
allowNull: false,
type: DataTypes.STRING
},
media: {
allowNull: false,
type: DataTypes.JSON
},
dub: {
allowNull: false,
type: DataTypes.JSON
},
sub: {
allowNull: false,
type: DataTypes.JSON
},
dir: {
allowNull: false,
type: DataTypes.STRING
},
hardsub: {
allowNull: false,
type: DataTypes.BOOLEAN
},
failedreason: {
allowNull: true,
type: DataTypes.STRING
},
quality: {
allowNull: true,
type: DataTypes.BOOLEAN
},
service: {
allowNull: true,
type: DataTypes.STRING
},
format: {
allowNull: true,
type: DataTypes.STRING
},
createdAt: {
allowNull: false,
type: DataTypes.DATE
},
updatedAt: {
allowNull: false,
type: DataTypes.DATE
}
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: DataTypes.INTEGER
},
status: {
allowNull: false,
type: DataTypes.STRING
},
media: {
allowNull: false,
type: DataTypes.JSON
},
dub: {
allowNull: false,
type: DataTypes.JSON
},
sub: {
allowNull: false,
type: DataTypes.JSON
},
dir: {
allowNull: false,
type: DataTypes.STRING
},
hardsub: {
allowNull: false,
type: DataTypes.BOOLEAN
},
failedreason: {
allowNull: true,
type: DataTypes.STRING
},
quality: {
allowNull: true,
type: DataTypes.BOOLEAN
},
service: {
allowNull: true,
type: DataTypes.STRING
},
format: {
allowNull: true,
type: DataTypes.STRING
},
createdAt: {
allowNull: false,
type: DataTypes.DATE
},
updatedAt: {
allowNull: false,
type: DataTypes.DATE
}
})
export { sequelize, Account, Playlist }

View File

@ -8,302 +8,301 @@ import { loggedInCheck } from '../service/service.service'
import { parse as mpdParse, parse } from 'mpd-parser'
export async function adnLogin(user: string, passw: string) {
const cachedData:
| {
accessToken: string
}
| undefined = server.CacheController.get('adntoken')
const cachedData:
| {
accessToken: string
}
| undefined = server.CacheController.get('adntoken')
if (!cachedData) {
var { data, error } = await adnLoginFetch(user, passw)
if (!cachedData) {
var { data, error } = await adnLoginFetch(user, passw)
if (error) {
messageBox('error', ['Cancel'], 2, 'Failed to login', 'Failed to login to ADN', error.error as string)
return { data: null, error: error.error }
if (error) {
messageBox('error', ['Cancel'], 2, 'Failed to login', 'Failed to login to ADN', error.error as string)
return { data: null, error: error.error }
}
if (!data) {
messageBox('error', ['Cancel'], 2, 'Failed to login', 'Failed to login to ADN', 'ADN returned null')
return { data: null, error: 'ADN returned null' }
}
if (!data.accessToken) {
messageBox('error', ['Cancel'], 2, 'Failed to login', 'Failed to login to ADN', 'ADN returned malformed data')
return { data: null, error: 'ADN returned malformed data' }
}
server.CacheController.set('adntoken', data, 300)
return { data: data, error: null }
}
if (!data) {
messageBox('error', ['Cancel'], 2, 'Failed to login', 'Failed to login to ADN', 'ADN returned null')
return { data: null, error: 'ADN returned null' }
}
if (!data.accessToken) {
messageBox('error', ['Cancel'], 2, 'Failed to login', 'Failed to login to ADN', 'ADN returned malformed data')
return { data: null, error: 'ADN returned malformed data' }
}
server.CacheController.set('adntoken', data, 300)
return { data: data, error: null }
}
return { data: cachedData, error: null }
return { data: cachedData, error: null }
}
async function adnLoginFetch(user: string, passw: string) {
const headers = {
'Content-Type': 'application/json'
}
const headers = {
'Content-Type': 'application/json'
}
const body = {
username: user,
password: passw,
source: 'Web',
rememberMe: true
}
const body = {
username: user,
password: passw,
source: 'Web',
rememberMe: true
}
const { data, error } = await useFetch<{
accessToken: string
}>('https://gw.api.animationdigitalnetwork.fr/authentication/login', {
type: 'POST',
body: JSON.stringify(body),
header: headers
})
const { data, error } = await useFetch<{
accessToken: string
}>('https://gw.api.animationdigitalnetwork.fr/authentication/login', {
type: 'POST',
body: JSON.stringify(body),
header: headers
})
if (error) {
return { data: null, error: error }
}
if (error) {
return { data: null, error: error }
}
if (!data) {
return { data: null, error: null }
}
if (!data) {
return { data: null, error: null }
}
return { data: data, error: null }
return { data: data, error: null }
}
export async function getEpisodeADN(q: number) {
const cachedData = server.CacheController.get(`getepisodeadn-${q}`)
const cachedData = server.CacheController.get(`getepisodeadn-${q}`)
if (cachedData) {
return cachedData
}
try {
const response = await fetch(`https://gw.api.animationdigitalnetwork.fr/video/${q}/public`, {
method: 'GET',
headers: {
'x-target-distribution': 'de'
}
})
if (response.ok) {
const data: {
video: Array<any>
} = JSON.parse(await response.text())
server.CacheController.set(`getepisodeadn-${q}`, data.video, 1000)
return data.video
} else {
throw new Error('Failed to fetch ADN')
if (cachedData) {
return cachedData
}
try {
const response = await fetch(`https://gw.api.animationdigitalnetwork.fr/video/${q}/public`, {
method: 'GET',
headers: {
'x-target-distribution': 'de'
}
})
if (response.ok) {
const data: {
video: Array<any>
} = JSON.parse(await response.text())
server.CacheController.set(`getepisodeadn-${q}`, data.video, 1000)
return data.video
} else {
throw new Error('Failed to fetch ADN')
}
} catch (e) {
throw new Error(e as string)
}
} catch (e) {
throw new Error(e as string)
}
}
export async function getPlayerConfigADN(id: number, geo: 'de' | 'fr') {
const account = await loggedInCheck('ADN')
const account = await loggedInCheck('ADN')
if (!account) return
if (!account) return
const token = await adnLogin(account.username, account.password)
const token = await adnLogin(account.username, account.password)
if (!token.data?.accessToken) return
if (!token.data?.accessToken) return
try {
const response = await fetch(`https://gw.api.animationdigitalnetwork.fr/player/video/${id}/configuration`, {
method: 'GET',
headers: {
'x-target-distribution': geo,
'Content-Type': 'application/json',
Authorization: `Bearer ${token.data.accessToken}`
}
})
try {
const response = await fetch(`https://gw.api.animationdigitalnetwork.fr/player/video/${id}/configuration`, {
method: 'GET',
headers: {
'x-target-distribution': geo,
'Content-Type': 'application/json',
Authorization: `Bearer ${token.data.accessToken}`
}
})
if (response.ok) {
const data: ADNPlayerConfig = JSON.parse(await response.text())
if (response.ok) {
const data: ADNPlayerConfig = JSON.parse(await response.text())
return data
} else {
throw new Error('Failed to fetch ADN')
return data
} else {
throw new Error('Failed to fetch ADN')
}
} catch (e) {
throw new Error(e as string)
}
} catch (e) {
throw new Error(e as string)
}
}
async function getPlayerToken(id: number, geo: 'de' | 'fr') {
const r = await getPlayerConfigADN(id, geo)
const r = await getPlayerConfigADN(id, geo)
if (!r) return
if (!r) return
try {
const response = await fetch(`https://gw.api.animationdigitalnetwork.fr/player/refresh/token`, {
method: 'POST',
headers: {
'x-target-distribution': geo,
'Content-Type': 'application/json',
'X-Player-Refresh-Token': r.player.options.user.refreshToken
}
})
try {
const response = await fetch(`https://gw.api.animationdigitalnetwork.fr/player/refresh/token`, {
method: 'POST',
headers: {
'x-target-distribution': geo,
'Content-Type': 'application/json',
'X-Player-Refresh-Token': r.player.options.user.refreshToken
}
})
if (response.ok) {
const data: {
token: string
accessToken: string
refreshToken: string
} = JSON.parse(await response.text())
if (response.ok) {
const data: {
token: string
accessToken: string
refreshToken: string
} = JSON.parse(await response.text())
return data
} else {
throw new Error('Failed to fetch ADN')
return data
} else {
throw new Error('Failed to fetch ADN')
}
} catch (e) {
throw new Error(e as string)
}
} catch (e) {
throw new Error(e as string)
}
}
function randomHexaString(length: number) {
const characters = '0123456789abcdef'
let result = ''
for (let i = 0; i < length; i++) {
result += characters[Math.floor(Math.random() * characters.length)]
}
return result
const characters = '0123456789abcdef'
let result = ''
for (let i = 0; i < length; i++) {
result += characters[Math.floor(Math.random() * characters.length)]
}
return result
}
async function getPlayerEncryptedToken(id: number, geo: 'de' | 'fr') {
const token = await getPlayerToken(id, geo)
const token = await getPlayerToken(id, geo)
if (!token) return
if (!token) return
var key = new JSEncrypt()
var random = randomHexaString(16)
var key = new JSEncrypt()
var random = randomHexaString(16)
key.setPublicKey(
'-----BEGIN PUBLIC KEY-----MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCbQrCJBRmaXM4gJidDmcpWDssgnumHinCLHAgS4buMtdH7dEGGEUfBofLzoEdt1jqcrCDT6YNhM0aFCqbLOPFtx9cg/X2G/G5bPVu8cuFM0L+ehp8s6izK1kjx3OOPH/kWzvstM5tkqgJkNyNEvHdeJl6KhS+IFEqwvZqgbBpKuwIDAQAB-----END PUBLIC KEY-----'
)
key.setPublicKey(
'-----BEGIN PUBLIC KEY-----MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCbQrCJBRmaXM4gJidDmcpWDssgnumHinCLHAgS4buMtdH7dEGGEUfBofLzoEdt1jqcrCDT6YNhM0aFCqbLOPFtx9cg/X2G/G5bPVu8cuFM0L+ehp8s6izK1kjx3OOPH/kWzvstM5tkqgJkNyNEvHdeJl6KhS+IFEqwvZqgbBpKuwIDAQAB-----END PUBLIC KEY-----'
)
const data = {
k: random,
t: String(token.token)
}
const data = {
k: random,
t: String(token.token)
}
const finisheddata = JSON.stringify(data)
const finisheddata = JSON.stringify(data)
const encryptedData = key.encrypt(finisheddata) || ''
const encryptedData = key.encrypt(finisheddata) || ''
return { data: encryptedData, random: random }
return { data: encryptedData, random: random }
}
export async function adnGetPlaylist(animeid: number, geo: 'de' | 'fr') {
const token = await getPlayerEncryptedToken(animeid, geo)
const token = await getPlayerEncryptedToken(animeid, geo)
if (!token) return
if (!token) return
try {
const response = await fetch(`https://gw.api.animationdigitalnetwork.fr/player/video/${animeid}/link`, {
method: 'GET',
headers: {
'x-target-distribution': geo,
'X-Player-Token': token.data
}
})
try {
const response = await fetch(`https://gw.api.animationdigitalnetwork.fr/player/video/${animeid}/link`, {
method: 'GET',
headers: {
'x-target-distribution': geo,
'X-Player-Token': token.data
}
})
if (response.ok) {
const data: ADNLink = await JSON.parse(await response.text())
return { data: data, secret: token.random }
} else {
const data: { message: string, code: string, statusCode: string} = JSON.parse(await response.text())
if (response.ok) {
const data: ADNLink = await JSON.parse(await response.text())
return { data: data, secret: token.random }
} else {
const data: { message: string; code: string; statusCode: string } = JSON.parse(await response.text())
messageBox('error', ['Cancel'], 2, 'Failed to fetch Playlist', 'Failed to fetch ADN Playlist', `${data.message} - ${data.code}`)
messageBox('error', ['Cancel'], 2, 'Failed to fetch Playlist', 'Failed to fetch ADN Playlist', `${data.message} - ${data.code}`)
return null
return null
}
} catch (e) {
throw new Error(e as string)
}
} catch (e) {
throw new Error(e as string)
}
}
export async function adnGetM3U8Playlist(url: string) {
try {
const response = await fetch(url, {
method: 'GET',
})
try {
const response = await fetch(url, {
method: 'GET'
})
if (response.ok) {
const data: { location: string } = await JSON.parse(await response.text())
if (response.ok) {
const data: { location: string } = await JSON.parse(await response.text())
const mu8 = await fetch(data.location, {
method: 'GET',
})
const mu8 = await fetch(data.location, {
method: 'GET'
})
const playlist = await mu8.text()
const playlist = await mu8.text()
const url = await extractURLFromPlaylist(playlist)
const url = await extractURLFromPlaylist(playlist)
const partsraw = await fetch(url, {
method: 'GET',
})
const partsraw = await fetch(url, {
method: 'GET'
})
const parts = await partsraw.text()
const parts = await partsraw.text()
const baseurl = await extractBaseURL(url);
const baseurl = await extractBaseURL(url)
const partsArray = await extractSequenceURLs(parts, baseurl)
const partsArray = await extractSequenceURLs(parts, baseurl)
return partsArray
return partsArray
}
} catch (e) {
throw new Error(e as string)
}
} catch (e) {
throw new Error(e as string)
}
}
async function extractURLFromPlaylist(playlist: string) {
var startIndex = playlist.indexOf("http");
var endIndex = playlist.indexOf(" ", startIndex);
var extractedURL = playlist.slice(startIndex, endIndex);
return extractedURL;
var startIndex = playlist.indexOf('http')
var endIndex = playlist.indexOf(' ', startIndex)
var extractedURL = playlist.slice(startIndex, endIndex)
return extractedURL
}
async function extractBaseURL(playlistURL: string) {
var baseURL = playlistURL.substring(0, playlistURL.lastIndexOf("/") + 1);
return baseURL;
var baseURL = playlistURL.substring(0, playlistURL.lastIndexOf('/') + 1)
return baseURL
}
async function extractSequenceURLs(playlistText: string, baseURL: string) {
var sequenceURLs: Array<{ filename: string, url: string }> = [];
var matches = playlistText.match(/sequence_\d+\.ts/g);
if (matches) {
matches.forEach(function(match) {
sequenceURLs.push({ filename: match, url: baseURL + match });
});
}
return sequenceURLs;
var sequenceURLs: Array<{ filename: string; url: string }> = []
var matches = playlistText.match(/sequence_\d+\.ts/g)
if (matches) {
matches.forEach(function (match) {
sequenceURLs.push({ filename: match, url: baseURL + match })
})
}
return sequenceURLs
}
export async function parseSubs(url: string, secret: string) {
const response = await fetch(url)
const response = await fetch(url)
const data = await response.text()
const data = await response.text()
var key = secret + '7fac1178830cfe0c'
var key = secret + '7fac1178830cfe0c'
console.log(key)
console.log(key)
var parsedSubtitle = CryptoJS.enc.Base64.parse(data.substring(0, 24))
var sec = CryptoJS.enc.Hex.parse(key)
var som = data.substring(24)
var parsedSubtitle = CryptoJS.enc.Base64.parse(data.substring(0, 24))
var sec = CryptoJS.enc.Hex.parse(key)
var som = data.substring(24)
try {
// Fuck You ADN
var decrypted: any = CryptoJS.AES.decrypt(som, sec, { iv: parsedSubtitle })
decrypted = decrypted.toString(CryptoJS.enc.Utf8)
return decrypted
} catch (error) {
console.error('Error decrypting subtitles:', error)
return null
}
try {
// Fuck You ADN
var decrypted: any = CryptoJS.AES.decrypt(som, sec, { iv: parsedSubtitle })
decrypted = decrypted.toString(CryptoJS.enc.Utf8)
return decrypted
} catch (error) {
console.error('Error decrypting subtitles:', error)
return null
}
}

View File

@ -6,17 +6,17 @@ import { CrunchyEpisodes, CrunchySeason } from '../../types/crunchyroll'
import { loggedInCheck } from '../service/service.service'
export async function loginController(request: FastifyRequest, reply: FastifyReply) {
const account = await loggedInCheck('CR')
const account = await loggedInCheck('CR')
if (!account) {
return reply.code(401).send({ message: 'Not Logged in' })
}
if (!account) {
return reply.code(401).send({ message: 'Not Logged in' })
}
const { data, error } = await crunchyLogin(account.username, account.password)
const { data, error } = await crunchyLogin(account.username, account.password)
if (error) {
reply.code(400).send(error)
}
if (error) {
reply.code(400).send(error)
}
return reply.code(200).send(data)
}
return reply.code(200).send(data)
}

View File

@ -2,20 +2,20 @@ import type { FastifyInstance } from 'fastify'
import { loginController } from './crunchyroll.controller'
async function crunchyrollRoutes(server: FastifyInstance) {
server.post(
'/login',
{
schema: {
response: {
'4xx': {
error: { type: 'string' },
message: { type: 'string' }
}
}
}
},
loginController
)
server.post(
'/login',
{
schema: {
response: {
'4xx': {
error: { type: 'string' },
message: { type: 'string' }
}
}
}
},
loginController
)
}
export default crunchyrollRoutes

View File

@ -7,15 +7,76 @@ import { loggedInCheck } from '../service/service.service'
import { app } from 'electron'
const crErrors = [
{
error: 'invalid_grant',
response: 'Email/Password is wrong'
}
{
error: 'invalid_grant',
response: 'Email/Password is wrong'
}
]
export async function crunchyLogin(user: string, passw: string) {
const cachedData:
| {
const cachedData:
| {
access_token: string
refresh_token: string
expires_in: number
token_type: string
scope: string
country: string
account_id: string
profile_id: string
}
| undefined = server.CacheController.get('crtoken')
if (!cachedData) {
var { data, error } = await crunchyLoginFetch(user, passw)
if (error) {
messageBox(
'error',
['Cancel'],
2,
'Failed to login',
'Failed to login to Crunchyroll',
crErrors.find((r) => r.error === (error?.error as string)) ? crErrors.find((r) => r.error === (error?.error as string))?.response : (error.error as string)
)
return { data: null, error: error.error }
}
if (!data) {
messageBox('error', ['Cancel'], 2, 'Failed to login', 'Failed to login to Crunchyroll', 'Crunchyroll returned null')
return { data: null, error: 'Crunchyroll returned null' }
}
if (!data.access_token) {
messageBox('error', ['Cancel'], 2, 'Failed to login', 'Failed to login to Crunchyroll', 'Crunchyroll returned malformed data')
return { data: null, error: 'Crunchyroll returned malformed data' }
}
server.CacheController.set('crtoken', data, data.expires_in - 30)
return { data: data, error: null }
}
return { data: cachedData, error: null }
}
async function crunchyLoginFetch(user: string, passw: string) {
const headers = {
Authorization: 'Basic dC1rZGdwMmg4YzNqdWI4Zm4wZnE6eWZMRGZNZnJZdktYaDRKWFMxTEVJMmNDcXUxdjVXYW4=',
'Content-Type': 'application/x-www-form-urlencoded',
'User-Agent': 'Crunchyroll/3.46.2 Android/13 okhttp/4.12.0'
}
const body: any = {
username: user,
password: passw,
grant_type: 'password',
scope: 'offline_access',
device_name: 'RMX2170',
device_type: 'realme RMX2170'
}
const { data, error } = await useFetch<{
access_token: string
refresh_token: string
expires_in: number
@ -24,157 +85,96 @@ export async function crunchyLogin(user: string, passw: string) {
country: string
account_id: string
profile_id: string
}
| undefined = server.CacheController.get('crtoken')
if (!cachedData) {
var { data, error } = await crunchyLoginFetch(user, passw)
}>('https://beta-api.crunchyroll.com/auth/v1/token', {
type: 'POST',
body: new URLSearchParams(body).toString(),
header: headers,
credentials: 'same-origin'
})
if (error) {
messageBox(
'error',
['Cancel'],
2,
'Failed to login',
'Failed to login to Crunchyroll',
crErrors.find((r) => r.error === (error?.error as string)) ? crErrors.find((r) => r.error === (error?.error as string))?.response : (error.error as string)
)
return { data: null, error: error.error }
return { data: null, error: error }
}
if (!data) {
messageBox('error', ['Cancel'], 2, 'Failed to login', 'Failed to login to Crunchyroll', 'Crunchyroll returned null')
return { data: null, error: 'Crunchyroll returned null' }
return { data: null, error: null }
}
if (!data.access_token) {
messageBox('error', ['Cancel'], 2, 'Failed to login', 'Failed to login to Crunchyroll', 'Crunchyroll returned malformed data')
return { data: null, error: 'Crunchyroll returned malformed data' }
}
server.CacheController.set('crtoken', data, data.expires_in - 30)
return { data: data, error: null }
}
return { data: cachedData, error: null }
}
async function crunchyLoginFetch(user: string, passw: string) {
const headers = {
Authorization: 'Basic dC1rZGdwMmg4YzNqdWI4Zm4wZnE6eWZMRGZNZnJZdktYaDRKWFMxTEVJMmNDcXUxdjVXYW4=',
'Content-Type': 'application/x-www-form-urlencoded',
'User-Agent': 'Crunchyroll/3.46.2 Android/13 okhttp/4.12.0'
}
const body: any = {
username: user,
password: passw,
grant_type: 'password',
scope: 'offline_access',
device_name: 'RMX2170',
device_type: 'realme RMX2170'
}
const { data, error } = await useFetch<{
access_token: string
refresh_token: string
expires_in: number
token_type: string
scope: string
country: string
account_id: string
profile_id: string
}>('https://beta-api.crunchyroll.com/auth/v1/token', {
type: 'POST',
body: new URLSearchParams(body).toString(),
header: headers,
credentials: 'same-origin'
})
if (error) {
return { data: null, error: error }
}
if (!data) {
return { data: null, error: null }
}
return { data: data, error: null }
}
export async function crunchyGetPlaylist(q: string) {
const account = await loggedInCheck('CR')
const account = await loggedInCheck('CR')
if (!account) return
if (!account) return
const { data, error } = await crunchyLogin(account.username, account.password)
const { data, error } = await crunchyLogin(account.username, account.password)
if (!data) return
if (!data) return
const headers = {
Authorization: `Bearer ${data.access_token}`,
'X-Cr-Disable-Drm': 'true'
}
const query: any = {
q: q,
n: 100,
type: 'series',
ratings: false,
locale: 'de-DE'
}
try {
const response = await fetch(`https://cr-play-service.prd.crunchyrollsvc.com/v1/${q}/console/switch/play`, {
method: 'GET',
headers: headers
})
if (response.ok) {
const data: VideoPlaylist = JSON.parse(await response.text())
data.hardSubs = Object.values((data as any).hardSubs)
data.subtitles = Object.values((data as any).subtitles)
return data
} else {
throw new Error(await response.text())
const headers = {
Authorization: `Bearer ${data.access_token}`,
'X-Cr-Disable-Drm': 'true'
}
const query: any = {
q: q,
n: 100,
type: 'series',
ratings: false,
locale: 'de-DE'
}
try {
const response = await fetch(`https://cr-play-service.prd.crunchyrollsvc.com/v1/${q}/console/switch/play`, {
method: 'GET',
headers: headers
})
if (response.ok) {
const data: VideoPlaylist = JSON.parse(await response.text())
data.hardSubs = Object.values((data as any).hardSubs)
data.subtitles = Object.values((data as any).subtitles)
return data
} else {
throw new Error(await response.text())
}
} catch (e) {
throw new Error(e as string)
}
} catch (e) {
throw new Error(e as string)
}
}
export async function crunchyGetPlaylistMPD(q: string) {
const account = await loggedInCheck('CR')
const account = await loggedInCheck('CR')
if (!account) return
if (!account) return
const { data, error } = await crunchyLogin(account.username, account.password)
const { data, error } = await crunchyLogin(account.username, account.password)
if (!data) return
if (!data) return
const headers = {
Authorization: `Bearer ${data.access_token}`,
'X-Cr-Disable-Drm': 'true'
}
try {
const response = await fetch(q, {
method: 'GET',
headers: headers
})
if (response.ok) {
const parsed = mpdParse(await response.text())
return parsed
} else {
throw new Error(await response.text())
const headers = {
Authorization: `Bearer ${data.access_token}`,
'X-Cr-Disable-Drm': 'true'
}
try {
const response = await fetch(q, {
method: 'GET',
headers: headers
})
if (response.ok) {
const parsed = mpdParse(await response.text())
return parsed
} else {
throw new Error(await response.text())
}
} catch (e) {
throw new Error(e as string)
}
} catch (e) {
throw new Error(e as string)
}
}

View File

@ -1,110 +1,111 @@
import { FastifyReply, FastifyRequest } from "fastify"
import { crunchyLogin } from "../crunchyroll/crunchyroll.service"
import { addEpisodeToPlaylist, getDownloading, getPlaylist, loggedInCheck, safeLoginData } from "./service.service"
import { CrunchyEpisodes } from "../../types/crunchyroll"
import { adnLogin } from "../adn/adn.service"
import { FastifyReply, FastifyRequest } from 'fastify'
import { crunchyLogin } from '../crunchyroll/crunchyroll.service'
import { addEpisodeToPlaylist, getDownloading, getPlaylist, loggedInCheck, safeLoginData } from './service.service'
import { CrunchyEpisodes } from '../../types/crunchyroll'
import { adnLogin } from '../adn/adn.service'
export async function checkLoginController(request: FastifyRequest<{
Params: {
id: string
export async function checkLoginController(
request: FastifyRequest<{
Params: {
id: string
}
}>,
reply: FastifyReply
) {
const account = await loggedInCheck(request.params.id)
if (!account) {
return reply.code(401).send({ message: 'Not Logged in' })
}
}>, reply: FastifyReply) {
const account = await loggedInCheck(request.params.id)
if (!account) {
return reply.code(401).send({ message: 'Not Logged in' })
}
return reply.code(200).send({ message: 'Logged in' })
return reply.code(200).send({ message: 'Logged in' })
}
export async function loginController(
request: FastifyRequest<{
Body: {
user: string
password: string
},
Params: {
id: string
}
}>,
reply: FastifyReply
request: FastifyRequest<{
Body: {
user: string
password: string
}
Params: {
id: string
}
}>,
reply: FastifyReply
) {
const body = request.body
const params = request.params
const body = request.body
const params = request.params
const account = await loggedInCheck(params.id)
const account = await loggedInCheck(params.id)
if (account) {
return reply.code(404).send({ message: 'Already Logged In' })
}
if (account) {
return reply.code(404).send({ message: 'Already Logged In' })
}
var responseData
var responseError
var responseData
var responseError
if (params.id === 'CR') {
const { data, error } = await crunchyLogin(body.user, body.password)
responseError = error,
responseData = data
}
if (params.id === 'CR') {
const { data, error } = await crunchyLogin(body.user, body.password)
;(responseError = error), (responseData = data)
}
if (params.id === 'ADN') {
const { data, error } = await adnLogin(body.user, body.password)
responseError = error,
responseData = data
}
if (params.id === 'ADN') {
const { data, error } = await adnLogin(body.user, body.password)
;(responseError = error), (responseData = data)
}
if (responseError || !responseData) {
return reply.code(404).send({
message: 'Invalid Email or Password'
})
}
if (responseError || !responseData) {
return reply.code(404).send({
message: 'Invalid Email or Password'
})
}
await safeLoginData(body.user, body.password, params.id)
await safeLoginData(body.user, body.password, params.id)
return reply.code(200).send()
return reply.code(200).send()
}
export async function addPlaylistController(
request: FastifyRequest<{
Body: {
episodes: CrunchyEpisodes
dubs: Array<string>
subs: Array<string>
dir: string
hardsub: boolean
quality: 1080 | 720 | 480 | 360 | 240
service: 'CR' | 'ADN'
format: 'mp4' | 'mkv'
}
}>,
reply: FastifyReply
request: FastifyRequest<{
Body: {
episodes: CrunchyEpisodes
dubs: Array<string>
subs: Array<string>
dir: string
hardsub: boolean
quality: 1080 | 720 | 480 | 360 | 240
service: 'CR' | 'ADN'
format: 'mp4' | 'mkv'
}
}>,
reply: FastifyReply
) {
const body = request.body
const body = request.body
for (const e of body.episodes) {
await addEpisodeToPlaylist(e, body.subs, body.dubs, body.dir, body.hardsub, 'waiting', body.quality, body.service, body.format)
}
for (const e of body.episodes) {
await addEpisodeToPlaylist(e, body.subs, body.dubs, body.dir, body.hardsub, 'waiting', body.quality, body.service, body.format)
}
return reply.code(201).send()
return reply.code(201).send()
}
export async function getPlaylistController(request: FastifyRequest, reply: FastifyReply) {
const playlist = await getPlaylist()
const playlist = await getPlaylist()
for (const v of playlist) {
if (v.dataValues.status === 'downloading') {
const found = await getDownloading(v.dataValues.id)
if (found) {
;(v as any).dataValues = {
...v.dataValues,
partsleft: found.partsToDownload,
partsdownloaded: found.downloadedParts,
downloadspeed: found.downloadSpeed.toFixed(2)
for (const v of playlist) {
if (v.dataValues.status === 'downloading') {
const found = await getDownloading(v.dataValues.id)
if (found) {
;(v as any).dataValues = {
...v.dataValues,
partsleft: found.partsToDownload,
partsdownloaded: found.downloadedParts,
downloadspeed: found.downloadSpeed.toFixed(2)
}
}
}
}
}
}
return reply.code(200).send(playlist.reverse())
return reply.code(200).send(playlist.reverse())
}

View File

@ -1,63 +1,63 @@
import { FastifyInstance } from "fastify"
import { addPlaylistController, checkLoginController, getPlaylistController, loginController } from "./service.controller"
import { FastifyInstance } from 'fastify'
import { addPlaylistController, checkLoginController, getPlaylistController, loginController } from './service.controller'
async function serviceRoutes(server: FastifyInstance) {
server.post(
'/login/:id',
{
schema: {
response: {
'4xx': {
error: { type: 'string' },
message: { type: 'string' }
'/login/:id',
{
schema: {
response: {
'4xx': {
error: { type: 'string' },
message: { type: 'string' }
}
}
}
}
}
},
loginController
},
loginController
),
server.get(
'/check/:id',
{
schema: {
response: {
'4xx': {
error: { type: 'string' },
message: { type: 'string' }
}
}
}
},
checkLoginController
),
server.post(
'/playlist',
{
schema: {
response: {
'4xx': {
error: { type: 'string' },
message: { type: 'string' }
}
}
}
},
addPlaylistController
)
server.get(
'/check/:id',
{
schema: {
response: {
'4xx': {
error: { type: 'string' },
message: { type: 'string' }
'/playlist',
{
schema: {
response: {
'4xx': {
error: { type: 'string' },
message: { type: 'string' }
}
}
}
}
}
},
checkLoginController
),
server.post(
'/playlist',
{
schema: {
response: {
'4xx': {
error: { type: 'string' },
message: { type: 'string' }
}
}
}
},
addPlaylistController
},
getPlaylistController
)
server.get(
'/playlist',
{
schema: {
response: {
'4xx': {
error: { type: 'string' },
message: { type: 'string' }
}
}
}
},
getPlaylistController
)
}
export default serviceRoutes
}
export default serviceRoutes

File diff suppressed because it is too large Load Diff

View File

@ -1,38 +1,38 @@
type ErrorType = {
error: string
error: string
} | null
export async function useFetch<T>(
url: string,
options: {
type: 'GET' | 'PUT' | 'POST' | 'DELETE'
header: HeadersInit
body: BodyInit
query?: { [key: string]: string }
credentials?: RequestCredentials
}
): Promise<{ data: T | null; error: ErrorType }> {
const querystring = new URLSearchParams(options.query)
const raw = await fetch(`${url}${querystring ? querystring : ''}`, {
method: options.type,
headers: options.header,
body: options.body,
credentials: options.credentials
})
if (!raw.ok) {
const errorText = await raw.text()
let errorData: ErrorType = null
try {
errorData = JSON.parse(errorText)
} catch (error) {
console.error('Error parsing error text:', error)
url: string,
options: {
type: 'GET' | 'PUT' | 'POST' | 'DELETE'
header: HeadersInit
body: BodyInit
query?: { [key: string]: string }
credentials?: RequestCredentials
}
return { data: null, error: errorData }
}
): Promise<{ data: T | null; error: ErrorType }> {
const querystring = new URLSearchParams(options.query)
const data = await raw.json()
const raw = await fetch(`${url}${querystring ? querystring : ''}`, {
method: options.type,
headers: options.header,
body: options.body,
credentials: options.credentials
})
return { data: data, error: null }
if (!raw.ok) {
const errorText = await raw.text()
let errorData: ErrorType = null
try {
errorData = JSON.parse(errorText)
} catch (error) {
console.error('Error parsing error text:', error)
}
return { data: null, error: errorData }
}
const data = await raw.json()
return { data: data, error: null }
}

View File

@ -7,84 +7,84 @@ import { getFFMPEGPath } from './ffmpeg'
const ffmpegP = getFFMPEGPath()
export async function downloadMPDAudio(parts: { filename: string; url: string }[], dir: string, name: string) {
const path = await createFolder()
const path = await createFolder()
const maxParallelDownloads = 5
const downloadPromises = []
const maxParallelDownloads = 5
const downloadPromises = []
for (const [index, part] of parts.entries()) {
let retries = 0
for (const [index, part] of parts.entries()) {
let retries = 0
const downloadPromise = async () => {
let downloadSuccess = false
while (!downloadSuccess) {
try {
const stream = fs.createWriteStream(`${path}/${part.filename}`)
await fetchAndPipe(part.url, stream, index + 1)
downloadSuccess = true
} catch (error) {
retries++
console.error(`Failed to download part ${part.filename}, retrying (${retries})...`)
await new Promise((resolve) => setTimeout(resolve, 1000))
const downloadPromise = async () => {
let downloadSuccess = false
while (!downloadSuccess) {
try {
const stream = fs.createWriteStream(`${path}/${part.filename}`)
await fetchAndPipe(part.url, stream, index + 1)
downloadSuccess = true
} catch (error) {
retries++
console.error(`Failed to download part ${part.filename}, retrying (${retries})...`)
await new Promise((resolve) => setTimeout(resolve, 1000))
}
}
}
downloadPromises.push(downloadPromise())
if (downloadPromises.length === maxParallelDownloads || index === parts.length - 1) {
await Promise.all(downloadPromises)
downloadPromises.length = 0
}
}
}
downloadPromises.push(downloadPromise())
if (downloadPromises.length === maxParallelDownloads || index === parts.length - 1) {
await Promise.all(downloadPromises)
downloadPromises.length = 0
}
}
return await mergePartsAudio(parts, path, dir, name)
return await mergePartsAudio(parts, path, dir, name)
}
async function fetchAndPipe(url: string, stream: fs.WriteStream, index: number) {
const { body } = await fetch(url)
const readableStream = Readable.from(body as any)
const { body } = await fetch(url)
const readableStream = Readable.from(body as any)
return new Promise<void>((resolve, reject) => {
readableStream
.pipe(stream)
.on('finish', () => {
console.log(`Fragment ${index} downloaded`)
resolve()
})
.on('error', (error) => {
reject(error)
})
})
return new Promise<void>((resolve, reject) => {
readableStream
.pipe(stream)
.on('finish', () => {
console.log(`Fragment ${index} downloaded`)
resolve()
})
.on('error', (error) => {
reject(error)
})
})
}
async function mergePartsAudio(parts: { filename: string; url: string }[], tmp: string, dir: string, name: string) {
try {
const list: Array<string> = []
try {
const list: Array<string> = []
for (const [index, part] of parts.entries()) {
list.push(`${tmp}/${part.filename}`)
}
for (const [index, part] of parts.entries()) {
list.push(`${tmp}/${part.filename}`)
}
const concatenatedFile = `${tmp}/main.m4s`
await concatenateTSFiles(list, concatenatedFile)
const concatenatedFile = `${tmp}/main.m4s`
await concatenateTSFiles(list, concatenatedFile)
return new Promise((resolve, reject) => {
if (!ffmpegP.ffmpeg || !ffmpegP.ffprobe) return
Ffmpeg()
.setFfmpegPath(ffmpegP.ffmpeg)
.setFfprobePath(ffmpegP.ffprobe)
.input(concatenatedFile)
.outputOptions('-c copy')
.save(`${dir}/${name}.aac`)
.on('end', async () => {
console.log('Merging finished')
await deleteFolder(tmp)
return new Promise((resolve, reject) => {
if (!ffmpegP.ffmpeg || !ffmpegP.ffprobe) return
Ffmpeg()
.setFfmpegPath(ffmpegP.ffmpeg)
.setFfprobePath(ffmpegP.ffprobe)
.input(concatenatedFile)
.outputOptions('-c copy')
.save(`${dir}/${name}.aac`)
.on('end', async () => {
console.log('Merging finished')
await deleteFolder(tmp)
return resolve(`${dir}/${name}.aac`)
return resolve(`${dir}/${name}.aac`)
})
})
})
} catch (error) {
console.error('Error merging parts:', error)
}
} catch (error) {
console.error('Error merging parts:', error)
}
}

View File

@ -1,37 +1,37 @@
import fs from 'fs'
export async function concatenateTSFiles(inputFiles: Array<string>, outputFile: string) {
return new Promise<void>((resolve, reject) => {
const writeStream = fs.createWriteStream(outputFile)
return new Promise<void>((resolve, reject) => {
const writeStream = fs.createWriteStream(outputFile)
writeStream.on('error', (error) => {
reject(error)
writeStream.on('error', (error) => {
reject(error)
})
writeStream.on('finish', () => {
console.log('TS files concatenated successfully!')
resolve()
})
const processNextFile = (index: number) => {
if (index >= inputFiles.length) {
writeStream.end()
return
}
const readStream = fs.createReadStream(inputFiles[index])
readStream.on('error', (error) => {
reject(error)
})
readStream.pipe(writeStream, { end: false })
readStream.on('end', () => {
processNextFile(index + 1)
})
}
processNextFile(0)
})
writeStream.on('finish', () => {
console.log('TS files concatenated successfully!')
resolve()
})
const processNextFile = (index: number) => {
if (index >= inputFiles.length) {
writeStream.end()
return
}
const readStream = fs.createReadStream(inputFiles[index])
readStream.on('error', (error) => {
reject(error)
})
readStream.pipe(writeStream, { end: false })
readStream.on('end', () => {
processNextFile(index + 1)
})
}
processNextFile(0)
})
}

View File

@ -6,22 +6,22 @@ const appPath = app.getAppPath()
const resourcesPath = path.dirname(appPath)
const ffmpegPath = path.join(resourcesPath, 'ffmpeg')
if (isDev) {
require('dotenv').config()
require('dotenv').config()
}
export function getFFMPEGPath() {
if (isDev) {
const ffmpeg = process.env.FFMPEG_PATH
const ffprobe = process.env.FFPROBE_PATH
if (isDev) {
const ffmpeg = process.env.FFMPEG_PATH
const ffprobe = process.env.FFPROBE_PATH
console.log(ffmpeg)
console.log(ffprobe)
console.log(ffmpeg)
console.log(ffprobe)
return { ffmpeg: ffmpeg, ffprobe: ffprobe }
} else {
const ffmpeg = path.join(ffmpegPath, 'ffmpeg.exe')
const ffprobe = path.join(ffmpegPath, 'ffprobe.exe')
return { ffmpeg: ffmpeg, ffprobe: ffprobe }
} else {
const ffmpeg = path.join(ffmpegPath, 'ffmpeg.exe')
const ffprobe = path.join(ffmpegPath, 'ffprobe.exe')
return { ffmpeg: ffmpeg, ffprobe: ffprobe }
}
return { ffmpeg: ffmpeg, ffprobe: ffprobe }
}
}

View File

@ -3,71 +3,71 @@ import { app } from 'electron'
import fs from 'fs'
export async function createFolder() {
const tempFolderPath = path.join(app.getPath('documents'), `crd-tmp-${(Math.random() + 1).toString(36).substring(2)}`)
try {
await fs.promises.mkdir(tempFolderPath, { recursive: true })
return tempFolderPath
} catch (error) {
console.error('Error creating temporary folder:', error)
throw error
}
const tempFolderPath = path.join(app.getPath('documents'), `crd-tmp-${(Math.random() + 1).toString(36).substring(2)}`)
try {
await fs.promises.mkdir(tempFolderPath, { recursive: true })
return tempFolderPath
} catch (error) {
console.error('Error creating temporary folder:', error)
throw error
}
}
export async function checkDirectoryExistence(dir: string) {
try {
await fs.promises.access(dir)
console.log(`Directory ${dir} exists.`)
return true
} catch (error) {
console.log(`Directory ${dir} does not exist.`)
return false
}
try {
await fs.promises.access(dir)
console.log(`Directory ${dir} exists.`)
return true
} catch (error) {
console.log(`Directory ${dir} does not exist.`)
return false
}
}
export async function createFolderName(name: string, dir: string) {
var folderPath
var folderPath
const dirExists = await checkDirectoryExistence(dir)
const dirExists = await checkDirectoryExistence(dir)
if (dirExists) {
folderPath = path.join(dir, name)
} else {
folderPath = path.join(app.getPath('documents'), name)
}
try {
await fs.promises.access(folderPath)
return folderPath
} catch (error) {
try {
await fs.promises.mkdir(folderPath, { recursive: true })
return folderPath
} catch (mkdirError) {
console.error('Error creating season folder:', mkdirError)
throw mkdirError
if (dirExists) {
folderPath = path.join(dir, name)
} else {
folderPath = path.join(app.getPath('documents'), name)
}
try {
await fs.promises.access(folderPath)
return folderPath
} catch (error) {
try {
await fs.promises.mkdir(folderPath, { recursive: true })
return folderPath
} catch (mkdirError) {
console.error('Error creating season folder:', mkdirError)
throw mkdirError
}
}
}
}
export async function deleteFolder(folderPath: string) {
fs.rmSync(folderPath, { recursive: true, force: true })
fs.rmSync(folderPath, { recursive: true, force: true })
}
export async function deleteTemporaryFolders() {
const documentsPath = app.getPath('documents');
const folderPrefix = 'crd-tmp-';
const documentsPath = app.getPath('documents')
const folderPrefix = 'crd-tmp-'
try {
const files = await fs.promises.readdir(documentsPath);
const tempFolders = files.filter(file => file.startsWith(folderPrefix));
try {
const files = await fs.promises.readdir(documentsPath)
const tempFolders = files.filter((file) => file.startsWith(folderPrefix))
for (const folder of tempFolders) {
const folderPath = path.join(documentsPath, folder);
await deleteFolder(folderPath);
console.log(`Temporary folder ${folder} deleted.`);
for (const folder of tempFolders) {
const folderPath = path.join(documentsPath, folder)
await deleteFolder(folderPath)
console.log(`Temporary folder ${folder} deleted.`)
}
} catch (error) {
console.error('Error deleting temporary folders:', error)
throw error
}
} catch (error) {
console.error('Error deleting temporary folders:', error);
throw error;
}
}

View File

@ -5,144 +5,144 @@ import { finished } from 'stream/promises'
import CryptoJS from 'crypto-js'
export async function downloadCRSub(
sub: {
format: string
language: string
url: string
isDub: boolean
},
dir: string,
qual: 1080 | 720 | 480 | 360 | 240
sub: {
format: string
language: string
url: string
isDub: boolean
},
dir: string,
qual: 1080 | 720 | 480 | 360 | 240
) {
const path = `${dir}/${sub.language}${sub.isDub ? `-FORCED` : ''}.${sub.format}`
var qualX
var qualY
const path = `${dir}/${sub.language}${sub.isDub ? `-FORCED` : ''}.${sub.format}`
var qualX
var qualY
switch (qual) {
case 1080:
qualX = 1920
qualY = 1080
break
case 720:
qualX = 1280
qualY = 720
break
case 480:
qualX = 720
qualY = 480
break
case 360:
qualX = 640
qualY = 360
break
case 240:
qualX = 426
qualY = 240
break
}
switch (qual) {
case 1080:
qualX = 1920
qualY = 1080
break
case 720:
qualX = 1280
qualY = 720
break
case 480:
qualX = 720
qualY = 480
break
case 360:
qualX = 640
qualY = 360
break
case 240:
qualX = 426
qualY = 240
break
}
const stream = fs.createWriteStream(path)
const response = await fetch(sub.url)
const stream = fs.createWriteStream(path)
const response = await fetch(sub.url)
var parsedASS = parse(await response.text())
var parsedASS = parse(await response.text())
parsedASS.info['Original Script'] = 'crd [https://github.com/stratuma/]'
parsedASS.info['Original Script'] = 'crd [https://github.com/stratuma/]'
for (const s of parsedASS.styles.style) {
;(s.Fontsize = String(Math.round((parseInt(s.Fontsize) / parseInt(parsedASS.info.PlayResY)) * qualY))),
(s.Outline = String(Math.round((parseInt(s.Outline) / parseInt(parsedASS.info.PlayResY)) * qualY))),
(s.MarginL = String(Math.round((parseInt(s.MarginL) / parseInt(parsedASS.info.PlayResY)) * qualY))),
(s.MarginR = String(Math.round((parseInt(s.MarginR) / parseInt(parsedASS.info.PlayResY)) * qualY))),
(s.MarginV = String(Math.round((parseInt(s.MarginV) / parseInt(parsedASS.info.PlayResY)) * qualY)))
}
for (const s of parsedASS.styles.style) {
;(s.Fontsize = String(Math.round((parseInt(s.Fontsize) / parseInt(parsedASS.info.PlayResY)) * qualY))),
(s.Outline = String(Math.round((parseInt(s.Outline) / parseInt(parsedASS.info.PlayResY)) * qualY))),
(s.MarginL = String(Math.round((parseInt(s.MarginL) / parseInt(parsedASS.info.PlayResY)) * qualY))),
(s.MarginR = String(Math.round((parseInt(s.MarginR) / parseInt(parsedASS.info.PlayResY)) * qualY))),
(s.MarginV = String(Math.round((parseInt(s.MarginV) / parseInt(parsedASS.info.PlayResY)) * qualY)))
}
parsedASS.info.PlayResX = String(qualX)
parsedASS.info.PlayResY = String(qualY)
parsedASS.info.PlayResX = String(qualX)
parsedASS.info.PlayResY = String(qualY)
const fixed = stringify(parsedASS)
const fixed = stringify(parsedASS)
const resampledSubs = resamplePOSSubtitle(fixed, 640, 360, qualX, qualY)
const resampledSubs = resamplePOSSubtitle(fixed, 640, 360, qualX, qualY)
const readableStream = Readable.from([resampledSubs])
const readableStream = Readable.from([resampledSubs])
await finished(readableStream.pipe(stream))
console.log(`Sub ${sub.language}.${sub.format} downloaded`)
await finished(readableStream.pipe(stream))
console.log(`Sub ${sub.language}.${sub.format} downloaded`)
return path
return path
}
function resamplePOSSubtitle(subtitle: string, ox: number, oy: number, nx: number, ny: number) {
let lines = subtitle.split('\n')
let lines = subtitle.split('\n')
for (let i = 0; i < lines.length; i++) {
let line = lines[i]
for (let i = 0; i < lines.length; i++) {
let line = lines[i]
if (line.includes('pos(')) {
let posMatches = line.matchAll(/pos\((-?\d+(?:\.\d+)?),(-?\d+(?:\.\d+)?)\)/g)
for (let posMatch of posMatches) {
let oldX = parseInt(posMatch[1])
let oldY = parseInt(posMatch[2])
if (line.includes('pos(')) {
let posMatches = line.matchAll(/pos\((-?\d+(?:\.\d+)?),(-?\d+(?:\.\d+)?)\)/g)
for (let posMatch of posMatches) {
let oldX = parseInt(posMatch[1])
let oldY = parseInt(posMatch[2])
let newX = Math.round((oldX / ox) * nx)
let newY = Math.round((oldY / oy) * ny)
let newX = Math.round((oldX / ox) * nx)
let newY = Math.round((oldY / oy) * ny)
let newPos = `pos(${newX},${newY})`
let newPos = `pos(${newX},${newY})`
line = line.replace(posMatch[0], newPos)
}
lines[i] = line
line = line.replace(posMatch[0], newPos)
}
lines[i] = line
}
if (line.includes('move(')) {
let posMatches = line.matchAll(/move\((-?\d+(?:\.\d+)?),(-?\d+(?:\.\d+)?),(-?\d+(?:\.\d+)?),(-?\d+(?:\.\d+)?),(-?\d+(?:\.\d+)?),(-?\d+(?:\.\d+)?)/g)
for (let posMatch of posMatches) {
let fromX = parseInt(posMatch[1])
let fromY = parseInt(posMatch[2])
let toX = parseInt(posMatch[3])
let toY = parseInt(posMatch[4])
let time1 = parseInt(posMatch[5])
let time2 = parseInt(posMatch[6])
let newFromX = Math.round((fromX / ox) * nx)
let newFromY = Math.round((fromY / oy) * ny)
let newToX = Math.round((toX / ox) * nx)
let newToY = Math.round((toY / oy) * ny)
let newMov = `move(${newFromX},${newFromY},${newToX},${newToY},${time1},${time2})`
line = line.replace(posMatch[0], newMov)
}
lines[i] = line
}
if (line.includes('\\fs')) {
let posMatches = line.matchAll(/\\fs(-?\d+(?:\.\d+)?)/g)
for (let posMatch of posMatches) {
let font = parseInt(posMatch[1])
let newFontSize = Math.round((font / oy) * ny)
let newFont = `\\fs${newFontSize}`
line = line.replace(posMatch[0], newFont)
}
lines[i] = line
}
if (line.includes('\\bord')) {
let posMatches = line.matchAll(/\\bord(-?\d+(?:\.\d+)?)/g)
for (let posMatch of posMatches) {
let oldBord = parseInt(posMatch[1])
let newBord = Math.round((oldBord / oy) * ny)
let bord = `\\bord${newBord}`
line = line.replace(posMatch[0], bord)
}
lines[i] = line
}
}
if (line.includes('move(')) {
let posMatches = line.matchAll(/move\((-?\d+(?:\.\d+)?),(-?\d+(?:\.\d+)?),(-?\d+(?:\.\d+)?),(-?\d+(?:\.\d+)?),(-?\d+(?:\.\d+)?),(-?\d+(?:\.\d+)?)/g)
for (let posMatch of posMatches) {
let fromX = parseInt(posMatch[1])
let fromY = parseInt(posMatch[2])
let toX = parseInt(posMatch[3])
let toY = parseInt(posMatch[4])
let time1 = parseInt(posMatch[5])
let time2 = parseInt(posMatch[6])
let newFromX = Math.round((fromX / ox) * nx)
let newFromY = Math.round((fromY / oy) * ny)
let newToX = Math.round((toX / ox) * nx)
let newToY = Math.round((toY / oy) * ny)
let newMov = `move(${newFromX},${newFromY},${newToX},${newToY},${time1},${time2})`
line = line.replace(posMatch[0], newMov)
}
lines[i] = line
}
if (line.includes('\\fs')) {
let posMatches = line.matchAll(/\\fs(-?\d+(?:\.\d+)?)/g)
for (let posMatch of posMatches) {
let font = parseInt(posMatch[1])
let newFontSize = Math.round((font / oy) * ny)
let newFont = `\\fs${newFontSize}`
line = line.replace(posMatch[0], newFont)
}
lines[i] = line
}
if (line.includes('\\bord')) {
let posMatches = line.matchAll(/\\bord(-?\d+(?:\.\d+)?)/g)
for (let posMatch of posMatches) {
let oldBord = parseInt(posMatch[1])
let newBord = Math.round((oldBord / oy) * ny)
let bord = `\\bord${newBord}`
line = line.replace(posMatch[0], bord)
}
lines[i] = line
}
}
return lines.join('\n')
return lines.join('\n')
}
export async function downloadADNSub(link: string, dir: string, secret: string, language: string) {
var templateASS = `[Script Info]
var templateASS = `[Script Info]
; Script generated by Aegisub 3.2.2
; http://www.aegisub.org/
Title: Deutsch
@ -167,135 +167,135 @@ Style: Default,Arial,56,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,-1,0,0,0,100
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text\n`
const path = `${dir}/${language}.ass`
const path = `${dir}/${language}.ass`
const stream = fs.createWriteStream(path)
const subURLFetch = await fetch(link)
const subURL: {
location: string
} = JSON.parse(await subURLFetch.text())
const stream = fs.createWriteStream(path)
const subURLFetch = await fetch(link)
const subURL: {
location: string
} = JSON.parse(await subURLFetch.text())
const rawSubsFetch = await fetch(subURL.location)
const rawSubs = await rawSubsFetch.text()
const rawSubsFetch = await fetch(subURL.location)
const rawSubs = await rawSubsFetch.text()
const subs = await ADNparseSub(rawSubs, secret)
const subs = await ADNparseSub(rawSubs, secret)
const parsedSubs: {
vde: Array<{
startTime: number
endTime: number
positionAligh: string
lineAlign: string
text: string
}>
vostde: Array<{
startTime: number
endTime: number
positionAligh: string
lineAlign: string
text: string
}>
vostf: Array<{
startTime: number
endTime: number
positionAligh: string
lineAlign: string
text: string
}>
vf: Array<{
startTime: number
endTime: number
positionAligh: string
lineAlign: string
text: string
}>
} = await JSON.parse(subs)
const parsedSubs: {
vde: Array<{
startTime: number
endTime: number
positionAligh: string
lineAlign: string
text: string
}>
vostde: Array<{
startTime: number
endTime: number
positionAligh: string
lineAlign: string
text: string
}>
vostf: Array<{
startTime: number
endTime: number
positionAligh: string
lineAlign: string
text: string
}>
vf: Array<{
startTime: number
endTime: number
positionAligh: string
lineAlign: string
text: string
}>
} = await JSON.parse(subs)
// if (parsedSubs.vde) {
// for (const s of parsedSubs.vde) {
// const convertedStart = convertToTimeFormat(s.startTime)
// const convertedEnd = convertToTimeFormat(s.endTime)
// if (parsedSubs.vde) {
// for (const s of parsedSubs.vde) {
// const convertedStart = convertToTimeFormat(s.startTime)
// const convertedEnd = convertToTimeFormat(s.endTime)
// templateASS =
// templateASS + `Dialogue: 0,${convertedStart},${convertedEnd},Default,,0,0,0,,${s.text.replace('\n', '\\N').replace('<i>', '{\\i1}').replace('</i>', '{\\i0}')}\n`
// }
// }
// templateASS =
// templateASS + `Dialogue: 0,${convertedStart},${convertedEnd},Default,,0,0,0,,${s.text.replace('\n', '\\N').replace('<i>', '{\\i1}').replace('</i>', '{\\i0}')}\n`
// }
// }
if (parsedSubs.vostde) {
for (const s of parsedSubs.vostde) {
const convertedStart = convertToTimeFormat(s.startTime)
const convertedEnd = convertToTimeFormat(s.endTime)
if (parsedSubs.vostde) {
for (const s of parsedSubs.vostde) {
const convertedStart = convertToTimeFormat(s.startTime)
const convertedEnd = convertToTimeFormat(s.endTime)
templateASS =
templateASS + `Dialogue: 0,${convertedStart},${convertedEnd},Default,,0,0,0,,${s.text.replace('\n', '\\N').replace('<i>', '{\\i1}').replace('</i>', '{\\i0}')}\n`
templateASS =
templateASS + `Dialogue: 0,${convertedStart},${convertedEnd},Default,,0,0,0,,${s.text.replace('\n', '\\N').replace('<i>', '{\\i1}').replace('</i>', '{\\i0}')}\n`
}
}
}
if (parsedSubs.vostf) {
for (const s of parsedSubs.vostf) {
const convertedStart = convertToTimeFormat(s.startTime)
const convertedEnd = convertToTimeFormat(s.endTime)
if (parsedSubs.vostf) {
for (const s of parsedSubs.vostf) {
const convertedStart = convertToTimeFormat(s.startTime)
const convertedEnd = convertToTimeFormat(s.endTime)
templateASS =
templateASS + `Dialogue: 0,${convertedStart},${convertedEnd},Default,,0,0,0,,${s.text.replace('\n', '\\N').replace('<i>', '{\\i1}').replace('</i>', '{\\i0}')}\n`
templateASS =
templateASS + `Dialogue: 0,${convertedStart},${convertedEnd},Default,,0,0,0,,${s.text.replace('\n', '\\N').replace('<i>', '{\\i1}').replace('</i>', '{\\i0}')}\n`
}
}
}
// Disabling Changing ASS because still broken in vlc
// Disabling Changing ASS because still broken in vlc
// parsedASS.info.PlayResX = "1920";
// parsedASS.info.PlayResY = "1080";
// parsedASS.info.PlayResX = "1920";
// parsedASS.info.PlayResY = "1080";
// for (const s of parsedASS.styles.style) {
// (s.Fontsize = "54"), (s.Outline = "4");
// }
// for (const s of parsedASS.styles.style) {
// (s.Fontsize = "54"), (s.Outline = "4");
// }
// const fixed = stringify(parsedASS)
// const fixed = stringify(parsedASS)
const readableStream = Readable.from([templateASS])
const readableStream = Readable.from([templateASS])
await finished(readableStream.pipe(stream))
console.log(`Sub downloaded`)
await finished(readableStream.pipe(stream))
console.log(`Sub downloaded`)
return path
return path
}
function convertToTimeFormat(time: number) {
var seconds: number | string = Math.floor(time)
var milliseconds = Math.round((time - seconds) * 1000)
var seconds: number | string = Math.floor(time)
var milliseconds = Math.round((time - seconds) * 1000)
var hours: number | string = Math.floor(seconds / 3600)
var minutes: number | string = Math.floor((seconds % 3600) / 60)
seconds = seconds % 60
var hours: number | string = Math.floor(seconds / 3600)
var minutes: number | string = Math.floor((seconds % 3600) / 60)
seconds = seconds % 60
hours = String(hours).padStart(2, '0')
minutes = String(minutes).padStart(2, '0')
seconds = String(seconds).padStart(2, '0')
hours = String(hours).padStart(2, '0')
minutes = String(minutes).padStart(2, '0')
seconds = String(seconds).padStart(2, '0')
milliseconds = Math.round(milliseconds / 10)
milliseconds = Math.round(milliseconds / 10)
var formattedMilliseconds = milliseconds < 10 ? '0' + milliseconds : milliseconds
var formattedMilliseconds = milliseconds < 10 ? '0' + milliseconds : milliseconds
var formattedTime = hours + ':' + minutes + ':' + seconds + '.' + formattedMilliseconds
return formattedTime
var formattedTime = hours + ':' + minutes + ':' + seconds + '.' + formattedMilliseconds
return formattedTime
}
export async function ADNparseSub(raw: string, secret: string) {
var key = secret + '7fac1178830cfe0c'
var key = secret + '7fac1178830cfe0c'
console.log(key)
console.log(key)
var parsedSubtitle = CryptoJS.enc.Base64.parse(raw.substring(0, 24))
var sec = CryptoJS.enc.Hex.parse(key)
var som = raw.substring(24)
var parsedSubtitle = CryptoJS.enc.Base64.parse(raw.substring(0, 24))
var sec = CryptoJS.enc.Hex.parse(key)
var som = raw.substring(24)
try {
// Fuck You ADN
var decrypted: any = CryptoJS.AES.decrypt(som, sec, { iv: parsedSubtitle })
decrypted = decrypted.toString(CryptoJS.enc.Utf8)
return decrypted
} catch (error) {
console.error('Error decrypting subtitles:', error)
return null
}
try {
// Fuck You ADN
var decrypted: any = CryptoJS.AES.decrypt(som, sec, { iv: parsedSubtitle })
decrypted = decrypted.toString(CryptoJS.enc.Utf8)
return decrypted
} catch (error) {
console.error('Error decrypting subtitles:', error)
return null
}
}

View File

@ -1,145 +1,145 @@
export interface ADNPlayerConfig {
player: {
image: string
options: {
user: {
hasAccess: true
profileId: number
refreshToken: string
refreshTokenUrl: string
}
chromecast: {
appId: string
refreshTokenUrl: string
}
ios: {
videoUrl: string
appUrl: string
title: string
}
video: {
startDate: string
currentDate: string
available: boolean
free: boolean
url: string
}
dock: Array<string>
preference: {
quality: string
autoplay: boolean
language: string
green: boolean
}
player: {
image: string
options: {
user: {
hasAccess: true
profileId: number
refreshToken: string
refreshTokenUrl: string
}
chromecast: {
appId: string
refreshTokenUrl: string
}
ios: {
videoUrl: string
appUrl: string
title: string
}
video: {
startDate: string
currentDate: string
available: boolean
free: boolean
url: string
}
dock: Array<string>
preference: {
quality: string
autoplay: boolean
language: string
green: boolean
}
}
}
}
}
export interface ADNLink {
links: {
streaming: {
vostde: {
mobile: string
sd: string
hd: string
fhd: string
auto: string
}
links: {
streaming: {
vostde: {
mobile: string
sd: string
hd: string
fhd: string
auto: string
}
}
subtitles: {
all: string
}
history: string
nextVideoUrl: string
previousVideoUrl: string
}
subtitles: {
all: string
video: {
guid: string
id: number
currentTime: number
duration: number
url: string
image: string
tcEpisodeStart: string
tcEpisodeEnd: string
tcIntroStart: string
tcIntroEnd: string
tcEndingStart: string
tcEndingEnd: string
}
metadata: {
title: string
subtitle: string
summary: string
rating: number
}
history: string
nextVideoUrl: string
previousVideoUrl: string
}
video: {
guid: string
id: number
currentTime: number
duration: number
url: string
image: string
tcEpisodeStart: string
tcEpisodeEnd: string
tcIntroStart: string
tcIntroEnd: string
tcEndingStart: string
tcEndingEnd: string
}
metadata: {
title: string
subtitle: string
summary: string
rating: number
}
}
export interface ADNEpisode {
id: number,
title: string,
name: string,
number: string,
shortNumber: string,
season: string,
reference: string,
type: string,
order: number,
image: string,
image2x: string,
summary: string,
releaseDate: string,
duration: number,
url: string,
urlPath: string,
embeddedUrl: string,
languages: Array<string>,
qualities: Array<string>,
rating: number,
ratingsCount: number,
commentsCount: number,
available: boolean,
download: boolean,
free: boolean,
freeWithAds: boolean,
id: number
title: string
name: string
number: string
shortNumber: string
season: string
reference: string
type: string
order: number
image: string
image2x: string
summary: string
releaseDate: string
duration: number
url: string
urlPath: string
embeddedUrl: string
languages: Array<string>
qualities: Array<string>
rating: number
ratingsCount: number
commentsCount: number
available: boolean
download: boolean
free: boolean
freeWithAds: boolean
show: {
id: number,
title: string,
type: string,
originalTitle: string,
shortTitle: string,
reference: string,
age: string,
languages: Array<string>,
summary: string,
image: string,
image2x: string,
imageHorizontal: string,
imageHorizontal2x: string,
url: string,
urlPath: string,
episodeCount: number,
genres: Array<string>,
copyright: string,
rating: number,
ratingsCount: number,
commentsCount: number,
qualities: Array<string>,
simulcast: boolean,
free: boolean,
available: boolean,
download: boolean,
basedOn: string,
tagline: Array<string>,
firstReleaseYear: string,
productionStudio: string,
countryOfOrigin: string,
productionTeam: Array<{
role: string,
name: string,
}>,
nextVideoReleaseDate: string,
indexable: boolean
id: number
title: string
type: string
originalTitle: string
shortTitle: string
reference: string
age: string
languages: Array<string>
summary: string
image: string
image2x: string
imageHorizontal: string
imageHorizontal2x: string
url: string
urlPath: string
episodeCount: number
genres: Array<string>
copyright: string
rating: number
ratingsCount: number
commentsCount: number
qualities: Array<string>
simulcast: boolean
free: boolean
available: boolean
download: boolean
basedOn: string
tagline: Array<string>
firstReleaseYear: string
productionStudio: string
countryOfOrigin: string
productionTeam: Array<{
role: string
name: string
}>
nextVideoReleaseDate: string
indexable: boolean
}
indexable: boolean
}
}

View File

@ -1,146 +1,146 @@
export interface CrunchySeason {
identifier: string
description: string
is_simulcast: boolean
subtitle_locales: Array<string>
series_id: string
id: string
audio_locales: Array<string>
title: string
versions: Array<{
identifier: string
description: string
is_simulcast: boolean
subtitle_locales: Array<string>
series_id: string
id: string
audio_locales: Array<string>
title: string
versions: Array<{
audio_locale: string
guid: string
original: boolean
variant: string
}>
season_sequence_number: number
season_number: number
maturity_ratings: Array<string>
mature_blocked: boolean
channel_id: string
is_subbed: boolean
audio_locale: string
guid: string
original: boolean
variant: string
}>
season_sequence_number: number
season_number: number
maturity_ratings: Array<string>
mature_blocked: boolean
channel_id: string
is_subbed: boolean
audio_locale: string
season_display_number: string
is_complete: boolean
season_tags: Array<string>
is_mature: boolean
is_dubbed: boolean
slug_title: string
availability_notes: string
number_of_episodes: boolean
season_display_number: string
is_complete: boolean
season_tags: Array<string>
is_mature: boolean
is_dubbed: boolean
slug_title: string
availability_notes: string
number_of_episodes: boolean
}
export interface CrunchySeasons extends Array<CrunchySeason> {}
export interface CrunchyEpisode {
closed_captions_available: boolean
availability_notes: string
next_episode_title: string
upload_date: string
versions: Array<{
audio_locale: string
guid: string
closed_captions_available: boolean
availability_notes: string
next_episode_title: string
upload_date: string
versions: Array<{
audio_locale: string
guid: string
is_premium_only: boolean
media_guid: string
original: boolean
season_guid: string
variant: string
}>
season_slug_title: string
series_title: string
season_title: string
sequence_number: number
maturity_ratings: Array<string>
slug_title: string
is_premium_only: boolean
media_guid: string
original: boolean
season_guid: string
variant: string
}>
season_slug_title: string
series_title: string
season_title: string
sequence_number: number
maturity_ratings: Array<string>
slug_title: string
is_premium_only: boolean
availability_ends: string
identifier: string
recent_variant: string
free_available_date: string
subtitle_locales: Array<string>
series_id: string
mature_blocked: boolean
duration_ms: number
availability_starts: string
audio_locale: string
images: {
thumbnail: Array<
Array<{
height: number
source: string
type: string
width: number
}>
>
}
season_sequence_number: number
season_id: string
episode_number: number
listing_id: string
available_date: string
channel_id: string
season_number: number
hd_flag: boolean
recent_audio_locale: string
available_offline: boolean
episode: string
is_subbed: boolean
media_type: string
is_clip: boolean
title: string
streams_link: string
slug: string
id: string
production_episode_id: string
is_dubbed: boolean
next_episode_id: string
series_slug_title: string
season_tags: Array<string>
premium_date: string
is_mature: boolean
premium_available_date: string
description: string
episode_air_date: string
eligible_region: string
availability_ends: string
identifier: string
recent_variant: string
free_available_date: string
subtitle_locales: Array<string>
series_id: string
mature_blocked: boolean
duration_ms: number
availability_starts: string
audio_locale: string
images: {
thumbnail: Array<
Array<{
height: number
source: string
type: string
width: number
}>
>
}
season_sequence_number: number
season_id: string
episode_number: number
listing_id: string
available_date: string
channel_id: string
season_number: number
hd_flag: boolean
recent_audio_locale: string
available_offline: boolean
episode: string
is_subbed: boolean
media_type: string
is_clip: boolean
title: string
streams_link: string
slug: string
id: string
production_episode_id: string
is_dubbed: boolean
next_episode_id: string
series_slug_title: string
season_tags: Array<string>
premium_date: string
is_mature: boolean
premium_available_date: string
description: string
episode_air_date: string
eligible_region: string
}
export interface CrunchyEpisodes extends Array<CrunchyEpisode> {}
export interface VideoPlaylist {
assetId: number
audioLocale: string
bifs: string
burnedInLocale: string
captions: string
hardSubs: Array<{
hlang: string
assetId: number
audioLocale: string
bifs: string
burnedInLocale: string
captions: string
hardSubs: Array<{
hlang: string
url: string
quality: string
}>
playbackType: string
session: {
renewSeconds: number
noNetworkRetryIntervalSeconds: number
noNetworkTimeoutSeconds: number
maximumPauseSeconds: number
endOfVideoUnloadSeconds: number
sessionExpirationSeconds: number
usesStreamLimits: boolean
}
subtitles: Array<{
format: string
language: string
url: string
}>
token: string
url: string
quality: string
}>
playbackType: string
session: {
renewSeconds: number
noNetworkRetryIntervalSeconds: number
noNetworkTimeoutSeconds: number
maximumPauseSeconds: number
endOfVideoUnloadSeconds: number
sessionExpirationSeconds: number
usesStreamLimits: boolean
}
subtitles: Array<{
format: string
language: string
url: string
}>
token: string
url: string
versions: Array<{
audio_locale: string
guid: string
is_premium_only: boolean
media_guid: string
original: boolean
season_guid: string
variant: string
}>
versions: Array<{
audio_locale: string
guid: string
is_premium_only: boolean
media_guid: string
original: boolean
season_guid: string
variant: string
}>
}

View File

@ -1,71 +1,71 @@
declare module 'mpd-parser' {
export type Segment = {
uri: string
timeline: number
duration: number
resolvedUri: string
map: {
uri: string
resolvedUri: string
}
number: number
presentationTime: number
}
export type Playlist = {
attributes: {
NAME: string
BANDWIDTH: number
CODECS: string
'PROGRAM-ID': number
// Following for video only
'FRAME-RATE'?: number
AUDIO?: string // audio stream name
SUBTITLES?: string
RESOLUTION?: {
width: number
height: number
}
}
uri: string
endList: boolean
timeline: number
resolvedUri: string
targetDuration: number
discontinuitySequence: number
discontinuityStarts: []
timelineStarts: {
start: number
timeline: number
}[]
mediaSequence: number
contentProtection?: {
[type: string]: {
pssh?: Uint8Array
}
}
segments: Segment[]
}
export type Manifest = {
allowCache: boolean
discontinuityStarts: []
segments: []
endList: true
duration: number
playlists: Playlist[]
mediaGroups: {
AUDIO: {
audio: {
[name: string]: {
language: string
autoselect: boolean
default: boolean
playlists: Playlist[]
}
export type Segment = {
uri: string
timeline: number
duration: number
resolvedUri: string
map: {
uri: string
resolvedUri: string
}
}
number: number
presentationTime: number
}
}
export function parse(manifest: string): Manifest
export type Playlist = {
attributes: {
NAME: string
BANDWIDTH: number
CODECS: string
'PROGRAM-ID': number
// Following for video only
'FRAME-RATE'?: number
AUDIO?: string // audio stream name
SUBTITLES?: string
RESOLUTION?: {
width: number
height: number
}
}
uri: string
endList: boolean
timeline: number
resolvedUri: string
targetDuration: number
discontinuitySequence: number
discontinuityStarts: []
timelineStarts: {
start: number
timeline: number
}[]
mediaSequence: number
contentProtection?: {
[type: string]: {
pssh?: Uint8Array
}
}
segments: Segment[]
}
export type Manifest = {
allowCache: boolean
discontinuityStarts: []
segments: []
endList: true
duration: number
playlists: Playlist[]
mediaGroups: {
AUDIO: {
audio: {
[name: string]: {
language: string
autoselect: boolean
default: boolean
playlists: Playlist[]
}
}
}
}
}
export function parse(manifest: string): Manifest
}

View File

@ -17,197 +17,197 @@ const modules = [titleBarActionsModule, macMenuModule, updaterModule]
var mainWindow: BrowserWindow
function createWindow() {
console.log('System info', { isProduction, platform, architucture })
mainWindow = new BrowserWindow({
title: 'Crunchyroll Downloader',
icon: __dirname + '/icon/favicon.ico',
width: 950,
height: 700,
webPreferences: {
devTools: true,
nodeIntegration: true,
contextIsolation: true,
preload: path.join(__dirname, 'preload.js')
},
titleBarStyle: 'hidden',
titleBarOverlay: {
color: 'rgba(0,0,0,0)',
symbolColor: '#ffffff',
height: 40
},
resizable: false,
fullscreen: false,
maximizable: false,
vibrancy: 'fullscreen-ui',
// Not working when unfocusing the window somehow?
backgroundMaterial: 'acrylic',
show: false
})
// Show window after loading page
mainWindow.once('ready-to-show', () => {
mainWindow.show()
})
// Closes all windows if mainwindow is being closed
mainWindow.on('closed', () => {
app.quit()
})
// Lock app to single instance
if (singleInstance(app, mainWindow)) return
// Open the DevTools.
!isProduction &&
mainWindow.webContents.openDevTools({
mode: 'bottom'
console.log('System info', { isProduction, platform, architucture })
mainWindow = new BrowserWindow({
title: 'Crunchyroll Downloader',
icon: __dirname + '/icon/favicon.ico',
width: 950,
height: 700,
webPreferences: {
devTools: true,
nodeIntegration: true,
contextIsolation: true,
preload: path.join(__dirname, 'preload.js')
},
titleBarStyle: 'hidden',
titleBarOverlay: {
color: 'rgba(0,0,0,0)',
symbolColor: '#ffffff',
height: 40
},
resizable: false,
fullscreen: false,
maximizable: false,
vibrancy: 'fullscreen-ui',
// Not working when unfocusing the window somehow?
backgroundMaterial: 'acrylic',
show: false
})
return mainWindow
// Show window after loading page
mainWindow.once('ready-to-show', () => {
mainWindow.show()
})
// Closes all windows if mainwindow is being closed
mainWindow.on('closed', () => {
app.quit()
})
// Lock app to single instance
if (singleInstance(app, mainWindow)) return
// Open the DevTools.
!isProduction &&
mainWindow.webContents.openDevTools({
mode: 'bottom'
})
return mainWindow
}
// App events
// ==========
app.whenReady().then(async () => {
startAPI()
startAPI()
const mainWindow = createWindow()
if (!mainWindow) return
const mainWindow = createWindow()
if (!mainWindow) return
// Load renderer process
await dynamicRenderer(mainWindow)
// Load renderer process
await dynamicRenderer(mainWindow)
// Initialize modules
console.log('-'.repeat(30) + '\n[+] Loading modules...')
modules.forEach((module) => {
try {
module(mainWindow)
} catch (err: any) {
console.log('[!] Module error: ', err.message || err)
}
})
// Initialize modules
console.log('-'.repeat(30) + '\n[+] Loading modules...')
modules.forEach((module) => {
try {
module(mainWindow)
} catch (err: any) {
console.log('[!] Module error: ', err.message || err)
}
})
console.log('[!] Loading modules: Done.' + '\r\n' + '-'.repeat(30))
console.log('[!] Loading modules: Done.' + '\r\n' + '-'.repeat(30))
})
export async function messageBox(
type: 'none' | 'info' | 'error' | 'question' | 'warning' | undefined,
buttons: Array<'Cancel'>,
defaultId: number,
title: string,
message: string,
detail: string | undefined
type: 'none' | 'info' | 'error' | 'question' | 'warning' | undefined,
buttons: Array<'Cancel'>,
defaultId: number,
title: string,
message: string,
detail: string | undefined
) {
const options = {
type: type as 'none' | 'info' | 'error' | 'question' | 'warning' | undefined,
buttons: buttons,
defaultId: defaultId,
title: title,
message: message,
detail: detail
}
const options = {
type: type as 'none' | 'info' | 'error' | 'question' | 'warning' | undefined,
buttons: buttons,
defaultId: defaultId,
title: title,
message: message,
detail: detail
}
const response = dialog.showMessageBox(options)
console.log(response)
const response = dialog.showMessageBox(options)
console.log(response)
}
export async function setProgressBar(c: number) {
mainWindow.setProgressBar(c)
mainWindow.setProgressBar(c)
}
ipcMain.handle('dialog:openDirectory', async () => {
const window = BrowserWindow.getFocusedWindow()
const window = BrowserWindow.getFocusedWindow()
if (!window) {
return
}
if (!window) {
return
}
const { canceled, filePaths } = await dialog.showOpenDialog(window, {
properties: ['openDirectory']
})
if (canceled) {
return await settings.get('downloadPath')
} else {
await settings.set('downloadPath', filePaths[0])
return filePaths[0]
}
const { canceled, filePaths } = await dialog.showOpenDialog(window, {
properties: ['openDirectory']
})
if (canceled) {
return await settings.get('downloadPath')
} else {
await settings.set('downloadPath', filePaths[0])
return filePaths[0]
}
})
ipcMain.handle('dialog:defaultDirectory', async () => {
const savedPath = await settings.get('downloadPath')
const savedPath = await settings.get('downloadPath')
if (!savedPath) {
const path = app.getPath('documents')
if (!savedPath) {
const path = app.getPath('documents')
await settings.set('downloadPath', path)
await settings.set('downloadPath', path)
return path
}
return path
}
return savedPath
return savedPath
})
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
if (process.platform !== 'darwin') {
app.quit()
}
})
const openWindows = new Map()
// Open New Window
ipcMain.handle(
'window:openNewWindow',
async (
events,
opt: {
title: string
url: string
width: number
height: number
'window:openNewWindow',
async (
events,
opt: {
title: string
url: string
width: number
height: number
}
) => {
if (openWindows.has(opt.title)) {
const existingWindow = openWindows.get(opt.title)
existingWindow.focus()
return
}
const newWindow = new BrowserWindow({
title: opt.title,
icon: __dirname + '/icon/favicon.ico',
width: opt.width,
height: opt.height,
webPreferences: {
devTools: true,
nodeIntegration: true,
contextIsolation: true,
preload: path.join(__dirname, 'preload.js')
},
titleBarStyle: 'hidden',
titleBarOverlay: {
color: 'rgba(0,0,0,0)',
symbolColor: '#ffffff',
height: 40
},
resizable: false,
fullscreen: false,
maximizable: false,
vibrancy: 'fullscreen-ui',
backgroundMaterial: 'acrylic',
show: false
})
newWindow.once('ready-to-show', () => {
newWindow.show()
})
newWindow.loadURL(opt.url)
openWindows.set(opt.title, newWindow)
newWindow.on('closed', () => {
openWindows.delete(opt.title)
})
}
) => {
if (openWindows.has(opt.title)) {
const existingWindow = openWindows.get(opt.title)
existingWindow.focus()
return
}
const newWindow = new BrowserWindow({
title: opt.title,
icon: __dirname + '/icon/favicon.ico',
width: opt.width,
height: opt.height,
webPreferences: {
devTools: true,
nodeIntegration: true,
contextIsolation: true,
preload: path.join(__dirname, 'preload.js')
},
titleBarStyle: 'hidden',
titleBarOverlay: {
color: 'rgba(0,0,0,0)',
symbolColor: '#ffffff',
height: 40
},
resizable: false,
fullscreen: false,
maximizable: false,
vibrancy: 'fullscreen-ui',
backgroundMaterial: 'acrylic',
show: false
})
newWindow.once('ready-to-show', () => {
newWindow.show()
})
newWindow.loadURL(opt.url)
openWindows.set(opt.title, newWindow)
newWindow.on('closed', () => {
openWindows.delete(opt.title)
})
}
)

View File

@ -12,12 +12,12 @@ const isProduction = process.env.NODE_ENV !== 'development'
// Dynamic Renderer
// ================
export default async function (mainWindow: BrowserWindow) {
if (!isProduction) return mainWindow.loadURL('http://localhost:3000/')
const app = express()
app.use('/', serveStatic(path.join(__dirname, '../../public')))
const listener = app.listen(8079, 'localhost', () => {
const port = (listener.address() as any).port
console.log('Dynamic-Renderer Listening on', port)
mainWindow.loadURL(`http://localhost:${port}`)
})
if (!isProduction) return mainWindow.loadURL('http://localhost:3000/')
const app = express()
app.use('/', serveStatic(path.join(__dirname, '../../public')))
const listener = app.listen(8079, 'localhost', () => {
const port = (listener.address() as any).port
console.log('Dynamic-Renderer Listening on', port)
mainWindow.loadURL(`http://localhost:${port}`)
})
}

View File

@ -7,54 +7,54 @@ const template: (Electron.MenuItemConstructorOptions | Electron.MenuItem)[] = []
// Module
// ======
export default (mainWindow: BrowserWindow) => {
const isDevelopment = process.env.NODE_ENV === 'development'
if (process.platform === 'darwin') {
// OS X
const name = 'electron-nuxt3'
template.unshift({
label: name,
submenu: [
{
label: 'About ' + name,
role: 'about'
},
{
label: 'Quit',
accelerator: 'Command+Q',
click() {
app.quit()
}
},
{
label: 'Reload',
accelerator: 'Command+R',
click() {
// Reload the current window
if (mainWindow) {
mainWindow.reload()
}
}
},
...(isDevelopment
? [
{
label: 'Toggle Developer Tools',
accelerator: 'Alt+Command+I',
click() {
// Open the DevTools.
if (mainWindow) {
mainWindow.webContents.toggleDevTools()
}
}
}
const isDevelopment = process.env.NODE_ENV === 'development'
if (process.platform === 'darwin') {
// OS X
const name = 'electron-nuxt3'
template.unshift({
label: name,
submenu: [
{
label: 'About ' + name,
role: 'about'
},
{
label: 'Quit',
accelerator: 'Command+Q',
click() {
app.quit()
}
},
{
label: 'Reload',
accelerator: 'Command+R',
click() {
// Reload the current window
if (mainWindow) {
mainWindow.reload()
}
}
},
...(isDevelopment
? [
{
label: 'Toggle Developer Tools',
accelerator: 'Alt+Command+I',
click() {
// Open the DevTools.
if (mainWindow) {
mainWindow.webContents.toggleDevTools()
}
}
}
]
: [])
]
: [])
]
})
})
const menu = Menu.buildFromTemplate(template)
Menu.setApplicationMenu(menu)
const menu = Menu.buildFromTemplate(template)
Menu.setApplicationMenu(menu)
console.log('[-] MODULE::macMenu Initialized')
}
console.log('[-] MODULE::macMenu Initialized')
}
}

View File

@ -3,48 +3,48 @@ import { ipcMain, BrowserWindow } from 'electron'
// Helpers
// =======
const getWindowFromEvent = (event: Electron.IpcMainInvokeEvent) => {
const webContents = event.sender
const win = BrowserWindow.fromWebContents(webContents)
return win
const webContents = event.sender
const win = BrowserWindow.fromWebContents(webContents)
return win
}
// Module
// ======
export default (mainWindow: BrowserWindow) => {
ipcMain.handle('isMaximized:app', (event) => {
const win = getWindowFromEvent(event)
return win?.isMaximized()
})
ipcMain.handle('isMaximized:app', (event) => {
const win = getWindowFromEvent(event)
return win?.isMaximized()
})
ipcMain.handle('titlebar:action', (event, action: 'toggleMaximize' | 'minimize') => {
const win = getWindowFromEvent(event)
if (!win) return
switch (action) {
case 'toggleMaximize':
win.isMaximized() ? win.unmaximize() : win.maximize()
break
case 'minimize':
win.minimize()
break
}
})
ipcMain.handle('titlebar:action', (event, action: 'toggleMaximize' | 'minimize') => {
const win = getWindowFromEvent(event)
if (!win) return
switch (action) {
case 'toggleMaximize':
win.isMaximized() ? win.unmaximize() : win.maximize()
break
case 'minimize':
win.minimize()
break
}
})
ipcMain.handle('close:app', (event) => {
const win = getWindowFromEvent(event)
if (!win) return
win.close()
})
ipcMain.handle('close:app', (event) => {
const win = getWindowFromEvent(event)
if (!win) return
win.close()
})
ipcMain.handle('get:windowVisible', (_event) => {
return mainWindow.isVisible()
})
ipcMain.handle('get:windowVisible', (_event) => {
return mainWindow.isVisible()
})
mainWindow.on('maximize', () => mainWindow.webContents.send('window:maximizeChanged', true))
mainWindow.on('unmaximize', () => mainWindow.webContents.send('window:maximizeChanged', false))
mainWindow.on('enter-full-screen', () => mainWindow.webContents.send('window:fullscreenChanged', true))
mainWindow.on('leave-full-screen', () => mainWindow.webContents.send('window:fullscreenChanged', false))
mainWindow.on('maximize', () => mainWindow.webContents.send('window:maximizeChanged', true))
mainWindow.on('unmaximize', () => mainWindow.webContents.send('window:maximizeChanged', false))
mainWindow.on('enter-full-screen', () => mainWindow.webContents.send('window:fullscreenChanged', true))
mainWindow.on('leave-full-screen', () => mainWindow.webContents.send('window:fullscreenChanged', false))
console.log('[-] MODULE::titleBarActions Initialized')
console.log('[-] MODULE::titleBarActions Initialized')
}
// https://www.electronjs.org/docs/latest/tutorial/ipc

View File

@ -2,7 +2,7 @@ import { BrowserWindow, ipcMain } from 'electron'
import { autoUpdater } from 'electron-updater'
import log from 'electron-log'
var status: { status: string, info: any } = { status: "", info: null }
var status: { status: string; info: any } = { status: '', info: null }
autoUpdater.logger = log
;(autoUpdater.logger as typeof log).transports.file.level = 'info'
@ -11,54 +11,57 @@ autoUpdater.autoDownload = false
autoUpdater.autoInstallOnAppQuit = false
ipcMain.handle('updater:getUpdateStatus', async () => {
return status
return status
})
export default (mainWindow: BrowserWindow) => {
let readyToInstall = false
function updateStatus(statusA: string, info?: any) {
status = { status: statusA, info: info }
}
let readyToInstall = false
function updateStatus(statusA: string, info?: any) {
status = { status: statusA, info: info }
}
autoUpdater.on('checking-for-update', () => {
updateStatus('check-for-update')
})
autoUpdater.on('update-available', (_info) => {
updateStatus('update-available', _info)
})
autoUpdater.on('update-not-available', (_info) => {
updateStatus('update-not-available', _info)
})
autoUpdater.on('error', (_err) => {
updateStatus('update-error', _err)
})
autoUpdater.on('download-progress', (progress) => {
updateStatus('downloading', progress)
})
autoUpdater.on('update-downloaded', (_info) => {
updateStatus('update-downloaded', _info)
mainWindow.webContents.send('updater:readyToInstall')
readyToInstall = true
})
autoUpdater.on('checking-for-update', () => {
updateStatus('check-for-update')
})
autoUpdater.on('update-available', (_info) => {
updateStatus('update-available', _info)
})
autoUpdater.on('update-not-available', (_info) => {
updateStatus('update-not-available', _info)
})
autoUpdater.on('error', (_err) => {
updateStatus('update-error', _err)
})
autoUpdater.on('download-progress', (progress) => {
updateStatus('downloading', progress)
})
autoUpdater.on('update-downloaded', (_info) => {
updateStatus('update-downloaded', _info)
mainWindow.webContents.send('updater:readyToInstall')
readyToInstall = true
})
ipcMain.handle('updater:check', async (_event) => {
return await autoUpdater.checkForUpdates()
})
ipcMain.handle('updater:check', async (_event) => {
return await autoUpdater.checkForUpdates()
})
ipcMain.handle('updater:download', async (_event) => {
return await autoUpdater.downloadUpdate()
})
ipcMain.handle('updater:download', async (_event) => {
return await autoUpdater.downloadUpdate()
})
ipcMain.handle('updater:quitAndInstall', (_event) => {
if (!readyToInstall) return
autoUpdater.quitAndInstall()
})
ipcMain.handle('updater:quitAndInstall', (_event) => {
if (!readyToInstall) return
autoUpdater.quitAndInstall()
})
autoUpdater.checkForUpdates()
setInterval(() => {
autoUpdater.checkForUpdates()
}, 1000 * 60 * 60 * 2)
console.log('[-] MODULE::updater Initialized')
setInterval(
() => {
autoUpdater.checkForUpdates()
},
1000 * 60 * 60 * 2
)
console.log('[-] MODULE::updater Initialized')
}

View File

@ -1,16 +1,10 @@
import {contextBridge, ipcRenderer} from 'electron'
import { contextBridge, ipcRenderer } from 'electron'
contextBridge.exposeInMainWorld('myAPI', {
selectFolder: () => ipcRenderer.invoke('dialog:openDirectory'),
getFolder: () => ipcRenderer.invoke('dialog:defaultDirectory'),
openWindow: (opt: {
title: string,
url: string,
width: number,
height: number,
backgroundColor: string
}) => ipcRenderer.invoke('window:openNewWindow', opt),
getUpdateStatus: () => ipcRenderer.invoke('updater:getUpdateStatus'),
startUpdateDownload: () => ipcRenderer.invoke('updater:download'),
startUpdateInstall: () => ipcRenderer.invoke('updater:quitAndInstall'),
selectFolder: () => ipcRenderer.invoke('dialog:openDirectory'),
getFolder: () => ipcRenderer.invoke('dialog:defaultDirectory'),
openWindow: (opt: { title: string; url: string; width: number; height: number; backgroundColor: string }) => ipcRenderer.invoke('window:openNewWindow', opt),
getUpdateStatus: () => ipcRenderer.invoke('updater:getUpdateStatus'),
startUpdateDownload: () => ipcRenderer.invoke('updater:download'),
startUpdateInstall: () => ipcRenderer.invoke('updater:quitAndInstall')
})

View File

@ -1,23 +1,23 @@
import { App, BrowserWindow } from 'electron'
export default (app: App, win: BrowserWindow) => {
const gotTheLock = app.requestSingleInstanceLock()
const gotTheLock = app.requestSingleInstanceLock()
if (!gotTheLock) {
app.quit()
return true
}
app.on('second-instance', (_, _argv) => {
if (win) {
win.show()
if (win.isMinimized()) win.restore()
win.focus()
if (!gotTheLock) {
app.quit()
return true
}
})
app.on('open-url', function (event, url) {
event.preventDefault()
win.webContents.send('deeplink', url)
})
app.on('second-instance', (_, _argv) => {
if (win) {
win.show()
if (win.isMinimized()) win.restore()
win.focus()
}
})
app.on('open-url', function (event, url) {
event.preventDefault()
win.webContents.send('deeplink', url)
})
}

View File

@ -1,103 +1,103 @@
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig to read more about this file */
"compilerOptions": {
/* Visit https://aka.ms/tsconfig to read more about this file */
/* Projects */
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Projects */
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */
"target": "ESNext" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
/* Language and Environment */
"target": "ESNext" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
/* Modules */
"module": "commonjs" /* Specify what module code is generated. */,
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
// "resolveJsonModule": true, /* Enable importing .json files. */
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
/* Modules */
"module": "commonjs" /* Specify what module code is generated. */,
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
// "resolveJsonModule": true, /* Enable importing .json files. */
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
/* JavaScript Support */
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
/* JavaScript Support */
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
/* Emit */
"declaration": false, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
"outDir": "../.output/src" /* Specify an output folder for all emitted files. */,
// "removeComments": true, /* Disable emitting comments. */
// "noEmit": true, /* Disable emitting files from a compilation. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
// "newLine": "crlf", /* Set the newline character for emitting files. */
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
/* Emit */
"declaration": false /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
"outDir": "../.output/src" /* Specify an output folder for all emitted files. */,
// "removeComments": true, /* Disable emitting comments. */
// "noEmit": true, /* Disable emitting files from a compilation. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
// "newLine": "crlf", /* Set the newline character for emitting files. */
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
/* Interop Constraints */
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
/* Interop Constraints */
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
/* Type Checking */
"strict": true /* Enable all strict type-checking options. */,
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
/* Type Checking */
"strict": true /* Enable all strict type-checking options. */,
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}

View File

@ -1,9 +1,4 @@
{
// https://nuxt.com/docs/guide/concepts/typescript
"extends": "./.nuxt/tsconfig.json",
"compilerOptions": {
"types": [
"@nuxtjs/i18n",
]
}
}