-
1080p
+
{{ p.quality }}p
Dubs: {{ p.dub.map((t) => t.name).join(', ') }}
Subs: {{ p.sub.length !== 0 ? p.sub.map((t) => t.name).join(', ') : '-' }}
{{ p.partsdownloaded }}/{{ p.partsleft }}
@@ -51,6 +51,7 @@ const playlist = ref<
partsleft: number
partsdownloaded: number
downloadspeed: number
+ quality: number
}>
>()
@@ -66,6 +67,7 @@ const getPlaylist = async () => {
partsleft: number
partsdownloaded: number
downloadspeed: number
+ quality: number
}>
>('http://localhost:8080/api/crunchyroll/playlist')
@@ -83,7 +85,7 @@ const getPlaylist = async () => {
const deletePlaylist = async () => {
const { data, error } = await useFetch('http://localhost:8080/api/crunchyroll/playlist', {
- method: "delete"
+ method: 'delete'
})
if (error.value) {
diff --git a/src/api/db/database.ts b/src/api/db/database.ts
index 22313d0..75ce28a 100644
--- a/src/api/db/database.ts
+++ b/src/api/db/database.ts
@@ -33,6 +33,7 @@ interface PlaylistAttributes {
dub: Array
sub: Array
hardsub: boolean,
+ quality: 1080 | 720 | 480 | 360 | 240,
dir: string,
failedreason: string
}
@@ -42,6 +43,7 @@ interface PlaylistCreateAttributes {
dub: Array
sub: Array
dir: string,
+ quality: 1080 | 720 | 480 | 360 | 240,
hardsub: boolean,
status: 'waiting' | 'preparing' | 'downloading' | 'merging' | 'completed' | 'failed'
}
@@ -110,6 +112,10 @@ const Playlist: ModelDefined = seq
allowNull: true,
type: DataTypes.STRING
},
+ quality: {
+ allowNull: true,
+ type: DataTypes.BOOLEAN
+ },
createdAt: {
allowNull: false,
type: DataTypes.DATE
diff --git a/src/api/routes/crunchyroll/crunchyroll.controller.ts b/src/api/routes/crunchyroll/crunchyroll.controller.ts
index 337352c..1aef916 100644
--- a/src/api/routes/crunchyroll/crunchyroll.controller.ts
+++ b/src/api/routes/crunchyroll/crunchyroll.controller.ts
@@ -66,44 +66,36 @@ export async function addPlaylistController(
episodes: CrunchyEpisodes
dubs: Array
subs: Array
- dir: string,
+ dir: string
hardsub: boolean
+ quality: 1080 | 720 | 480 | 360 | 240
}
}>,
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")
+ await addEpisodeToPlaylist(e, body.subs, body.dubs, body.dir, body.hardsub, 'waiting', body.quality)
}
return reply.code(201).send()
}
-export async function deleteCompletePlaylistController(
- request: FastifyRequest,
- reply: FastifyReply
-) {
-
+export async function deleteCompletePlaylistController(request: FastifyRequest, reply: FastifyReply) {
await deletePlaylist()
return reply.code(200).send()
}
-export async function getPlaylistController(
- request: FastifyRequest,
- reply: FastifyReply
-) {
-
+export async function getPlaylistController(request: FastifyRequest, reply: FastifyReply) {
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 as any).dataValues = {
...v.dataValues,
partsleft: found.partsToDownload,
partsdownloaded: found.downloadedParts,
@@ -115,4 +107,3 @@ export async function getPlaylistController(
return reply.code(200).send(playlist.reverse())
}
-
diff --git a/src/api/routes/crunchyroll/crunchyroll.service.ts b/src/api/routes/crunchyroll/crunchyroll.service.ts
index 31100d9..67ebfef 100644
--- a/src/api/routes/crunchyroll/crunchyroll.service.ts
+++ b/src/api/routes/crunchyroll/crunchyroll.service.ts
@@ -139,7 +139,8 @@ export async function addEpisodeToPlaylist(
d: Array,
dir: string,
hardsub: boolean,
- status: 'waiting' | 'preparing' | 'downloading' | 'merging' | 'completed' | 'failed'
+ status: 'waiting' | 'preparing' | 'downloading' | 'merging' | 'completed' | 'failed',
+ quality: 1080 | 720 | 480 | 360 | 240
) {
const episode = await Playlist.create({
media: e,
@@ -147,7 +148,8 @@ export async function addEpisodeToPlaylist(
dub: d,
dir: dir,
hardsub: hardsub,
- status
+ status: status,
+ quality: quality
})
return episode.get()
@@ -194,7 +196,8 @@ async function checkPlaylists() {
e.dataValues.id,
e.dataValues.media.series_title,
e.dataValues.media.season_number,
- e.dataValues.media.episode_number
+ e.dataValues.media.episode_number,
+ e.dataValues.quality
)
}
}
@@ -319,7 +322,7 @@ var downloading: Array<{
downloadSpeed: number
}> = []
-export async function downloadPlaylist(e: string, dubs: Array, subs: Array, hardsub: boolean, downloadID: number, name: string, season: number, episode: number) {
+export async function downloadPlaylist(e: string, dubs: Array, subs: Array, hardsub: boolean, downloadID: number, name: string, season: number, episode: number, quality: 1080 | 720 | 480 | 360 | 240) {
downloading.push({
id: downloadID,
downloadedParts: 0,
@@ -534,7 +537,7 @@ export async function downloadPlaylist(e: string, dubs: Array, subs: Arr
if (!mdp) return
- var hq = mdp.playlists.find((i) => i.attributes.RESOLUTION?.width === 1920)
+ var hq = mdp.playlists.find((i) => i.attributes.RESOLUTION?.height === quality)
if (!hq) return