final better hardsub select
This commit is contained in:
parent
639c919ff0
commit
32fb607f8a
@ -130,7 +130,8 @@
|
|||||||
<div v-if="p.qualityaudio" class="text-xs">{{ audioQualities[p.qualityaudio-1] ?? '44.10 kHz' }}</div>
|
<div v-if="p.qualityaudio" class="text-xs">{{ audioQualities[p.qualityaudio-1] ?? '44.10 kHz' }}</div>
|
||||||
<div class="text-xs uppercase">{{ p.format }}</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">Dubs: {{ p.dub.map((t) => t.name).join(', ') }}</div>
|
||||||
<div class="text-xs mr-20">Subs: {{ p.sub.length !== 0 ? p.sub.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="text-xs mr-20">Hardsub: {{ p.hardsub ? `${p.hardsub.name} (${p.hardsub.format})` : '-' }}</div>
|
||||||
<div class="absolute flex flex-col ml-auto gap-0.5 right-0 bottom-0">
|
<div class="absolute flex flex-col ml-auto gap-0.5 right-0 bottom-0">
|
||||||
<div v-if="(p.totaldownloaded && p.status === 'downloading') || (p.totaldownloaded && p.status === 'downloading video')" class="text-xs ml-auto"
|
<div v-if="(p.totaldownloaded && p.status === 'downloading') || (p.totaldownloaded && p.status === 'downloading video')" class="text-xs ml-auto"
|
||||||
>{{ (p.totaldownloaded / Math.pow(1024, 2)).toFixed(2) }} MB</div
|
>{{ (p.totaldownloaded / Math.pow(1024, 2)).toFixed(2) }} MB</div
|
||||||
@ -165,6 +166,7 @@ const playlist = ref<
|
|||||||
media: CrunchyEpisode | ADNEpisode
|
media: CrunchyEpisode | ADNEpisode
|
||||||
dub: Array<{ locale: string; name: string }>
|
dub: Array<{ locale: string; name: string }>
|
||||||
sub: Array<{ locale: string; name: string }>
|
sub: Array<{ locale: string; name: string }>
|
||||||
|
hardsub: { name: string | undefined; locale: string, format: string }
|
||||||
dir: string
|
dir: string
|
||||||
installDir: string
|
installDir: string
|
||||||
partsleft: number
|
partsleft: number
|
||||||
@ -192,6 +194,7 @@ const getPlaylist = async () => {
|
|||||||
media: CrunchyEpisode | ADNEpisode
|
media: CrunchyEpisode | ADNEpisode
|
||||||
dub: Array<{ locale: string; name: string }>
|
dub: Array<{ locale: string; name: string }>
|
||||||
sub: Array<{ locale: string; name: string }>
|
sub: Array<{ locale: string; name: string }>
|
||||||
|
hardsub: { name: string | undefined; locale: string, format: string }
|
||||||
dir: string
|
dir: string
|
||||||
installDir: string
|
installDir: string
|
||||||
partsleft: number
|
partsleft: number
|
||||||
|
@ -5,7 +5,7 @@ import { ADNEpisode } from '../types/adn'
|
|||||||
|
|
||||||
const sequelize = new Sequelize({
|
const sequelize = new Sequelize({
|
||||||
dialect: 'sqlite',
|
dialect: 'sqlite',
|
||||||
storage: app.getPath('documents') + '/Crunchyroll Downloader/databases/v2/data.db'
|
storage: app.getPath('documents') + '/Crunchyroll Downloader/databases/v3/data.db'
|
||||||
})
|
})
|
||||||
|
|
||||||
interface AccountAttributes {
|
interface AccountAttributes {
|
||||||
@ -44,9 +44,9 @@ interface PlaylistAttributes {
|
|||||||
| 'completed'
|
| 'completed'
|
||||||
| 'failed'
|
| 'failed'
|
||||||
media: CrunchyEpisode | ADNEpisode
|
media: CrunchyEpisode | ADNEpisode
|
||||||
dub: Array<string>
|
dub: { name: string | undefined; locale: string }[]
|
||||||
sub: Array<string>
|
sub: { name: string | undefined; locale: string }[]
|
||||||
hardsub: boolean
|
hardsub: { name: string | undefined; locale: string, format: string }
|
||||||
quality: 1080 | 720 | 480 | 360 | 240
|
quality: 1080 | 720 | 480 | 360 | 240
|
||||||
qualityaudio: 1 | 2 | 3 | undefined
|
qualityaudio: 1 | 2 | 3 | undefined
|
||||||
dir: string
|
dir: string
|
||||||
@ -58,12 +58,12 @@ interface PlaylistAttributes {
|
|||||||
|
|
||||||
interface PlaylistCreateAttributes {
|
interface PlaylistCreateAttributes {
|
||||||
media: CrunchyEpisode | ADNEpisode
|
media: CrunchyEpisode | ADNEpisode
|
||||||
dub: Array<string>
|
dub: { name: string | undefined; locale: string }[]
|
||||||
sub: Array<string>
|
sub: { name: string | undefined; locale: string }[]
|
||||||
|
hardsub: { name: string | undefined; locale: string, format: string } | undefined
|
||||||
dir: string
|
dir: string
|
||||||
quality: 1080 | 720 | 480 | 360 | 240
|
quality: 1080 | 720 | 480 | 360 | 240
|
||||||
qualityaudio: 1 | 2 | 3 | undefined
|
qualityaudio: 1 | 2 | 3 | undefined
|
||||||
hardsub: boolean
|
|
||||||
status:
|
status:
|
||||||
| 'waiting'
|
| 'waiting'
|
||||||
| 'preparing'
|
| 'preparing'
|
||||||
@ -134,6 +134,10 @@ const Playlist: ModelDefined<PlaylistAttributes, PlaylistCreateAttributes> = seq
|
|||||||
allowNull: false,
|
allowNull: false,
|
||||||
type: DataTypes.JSON
|
type: DataTypes.JSON
|
||||||
},
|
},
|
||||||
|
hardsub: {
|
||||||
|
allowNull: true,
|
||||||
|
type: DataTypes.JSON
|
||||||
|
},
|
||||||
dir: {
|
dir: {
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
type: DataTypes.STRING
|
type: DataTypes.STRING
|
||||||
@ -142,10 +146,6 @@ const Playlist: ModelDefined<PlaylistAttributes, PlaylistCreateAttributes> = seq
|
|||||||
allowNull: true,
|
allowNull: true,
|
||||||
type: DataTypes.STRING
|
type: DataTypes.STRING
|
||||||
},
|
},
|
||||||
hardsub: {
|
|
||||||
allowNull: false,
|
|
||||||
type: DataTypes.BOOLEAN
|
|
||||||
},
|
|
||||||
failedreason: {
|
failedreason: {
|
||||||
allowNull: true,
|
allowNull: true,
|
||||||
type: DataTypes.STRING
|
type: DataTypes.STRING
|
||||||
|
@ -96,10 +96,10 @@ export async function addPlaylistController(
|
|||||||
request: FastifyRequest<{
|
request: FastifyRequest<{
|
||||||
Body: {
|
Body: {
|
||||||
episodes: CrunchyEpisodes
|
episodes: CrunchyEpisodes
|
||||||
dubs: Array<string>
|
dubs: { name: string | undefined; locale: string }[]
|
||||||
subs: Array<string>
|
subs: { name: string | undefined; locale: string }[]
|
||||||
|
hardsub: { name: string | undefined; locale: string, format: string } | undefined
|
||||||
dir: string
|
dir: string
|
||||||
hardsub: boolean
|
|
||||||
quality: 1080 | 720 | 480 | 360 | 240
|
quality: 1080 | 720 | 480 | 360 | 240
|
||||||
qualityaudio: 1 | 2 | 3 | undefined
|
qualityaudio: 1 | 2 | 3 | undefined
|
||||||
service: 'CR' | 'ADN'
|
service: 'CR' | 'ADN'
|
||||||
@ -111,7 +111,7 @@ export async function addPlaylistController(
|
|||||||
const body = request.body
|
const body = request.body
|
||||||
|
|
||||||
for (const e of body.episodes) {
|
for (const e of body.episodes) {
|
||||||
await addEpisodeToPlaylist(e, body.subs, body.dubs, body.dir, body.hardsub, 'waiting', body.quality, body.qualityaudio, body.service, body.format)
|
await addEpisodeToPlaylist(e, body.subs, body.dubs, body.hardsub, body.dir, 'waiting', body.quality, body.qualityaudio, body.service, body.format)
|
||||||
}
|
}
|
||||||
|
|
||||||
return reply.code(201).send()
|
return reply.code(201).send()
|
||||||
|
@ -209,10 +209,10 @@ export async function updatePlaylistByID(
|
|||||||
// Add Episode to Playlist
|
// Add Episode to Playlist
|
||||||
export async function addEpisodeToPlaylist(
|
export async function addEpisodeToPlaylist(
|
||||||
e: CrunchyEpisode,
|
e: CrunchyEpisode,
|
||||||
s: Array<string>,
|
s: { name: string | undefined; locale: string }[],
|
||||||
d: Array<string>,
|
d: { name: string | undefined; locale: string }[],
|
||||||
|
hardsub: { name: string | undefined; locale: string, format: string } | undefined,
|
||||||
dir: string,
|
dir: string,
|
||||||
hardsub: boolean,
|
|
||||||
status:
|
status:
|
||||||
| 'waiting'
|
| 'waiting'
|
||||||
| 'preparing'
|
| 'preparing'
|
||||||
@ -295,8 +295,8 @@ async function checkPlaylists() {
|
|||||||
if (e.dataValues.service === 'CR') {
|
if (e.dataValues.service === 'CR') {
|
||||||
downloadCrunchyrollPlaylist(
|
downloadCrunchyrollPlaylist(
|
||||||
(e.dataValues.media as CrunchyEpisode).id,
|
(e.dataValues.media as CrunchyEpisode).id,
|
||||||
(e as any).dataValues.dub.map((s: { locale: any }) => s.locale),
|
e.dataValues.dub.map((s: { locale: any }) => s.locale),
|
||||||
(e as any).dataValues.sub.map((s: { locale: any }) => s.locale),
|
e.dataValues.sub.map((s: { locale: any }) => s.locale),
|
||||||
e.dataValues.hardsub,
|
e.dataValues.hardsub,
|
||||||
(e.dataValues.media as CrunchyEpisode).id,
|
(e.dataValues.media as CrunchyEpisode).id,
|
||||||
e.dataValues.id,
|
e.dataValues.id,
|
||||||
@ -471,7 +471,7 @@ export async function downloadCrunchyrollPlaylist(
|
|||||||
e: string,
|
e: string,
|
||||||
dubs: Array<string>,
|
dubs: Array<string>,
|
||||||
subs: Array<string>,
|
subs: Array<string>,
|
||||||
hardsub: boolean,
|
hardsub: { name: string | undefined; locale: string; format: string; },
|
||||||
episodeID: string,
|
episodeID: string,
|
||||||
downloadID: number,
|
downloadID: number,
|
||||||
name: string,
|
name: string,
|
||||||
@ -926,7 +926,7 @@ export async function downloadCrunchyrollPlaylist(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const play = await crunchyGetPlaylist(code, geo)
|
var play = await crunchyGetPlaylist(code, geo)
|
||||||
|
|
||||||
if (!play) {
|
if (!play) {
|
||||||
await updatePlaylistByID(downloadID, 'failed')
|
await updatePlaylistByID(downloadID, 'failed')
|
||||||
@ -945,24 +945,61 @@ export async function downloadCrunchyrollPlaylist(
|
|||||||
|
|
||||||
var downloadGEO
|
var downloadGEO
|
||||||
|
|
||||||
if (hardsub) {
|
if (hardsub && hardsub.locale) {
|
||||||
const hardsubURL = play.data.hardSubs.find((h) => h.hlang === subs[0])?.url
|
var hardsubURL: string | undefined;
|
||||||
|
|
||||||
const hardsubGEO = play.data.hardSubs.find((h) => h.hlang === subs[0])?.geo
|
var hardsubGEO: string | undefined;;
|
||||||
|
|
||||||
|
if (hardsub.format === 'dub') {
|
||||||
|
const found = play.data.versions.find((h) => h.audio_locale === hardsub.locale)
|
||||||
|
if (!found) {
|
||||||
|
hardsubURL = undefined
|
||||||
|
} else {
|
||||||
|
const newplay = await crunchyGetPlaylist(found.guid, found.geo)
|
||||||
|
if (!newplay) {
|
||||||
|
hardsubURL = undefined
|
||||||
|
hardsubGEO = undefined
|
||||||
|
} else {
|
||||||
|
hardsubURL = newplay.data.hardSubs.find((h) => h.hlang === hardsub.locale)?.url
|
||||||
|
hardsubGEO = newplay.data.hardSubs.find((h) => h.hlang === subs[0])?.geo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hardsub.format === 'sub') {
|
||||||
|
const found = play.data.versions.find((h) => h.audio_locale === 'ja-JP')
|
||||||
|
if (!found) {
|
||||||
|
hardsubURL = undefined
|
||||||
|
} else {
|
||||||
|
const newplay = await crunchyGetPlaylist(found.guid, found.geo)
|
||||||
|
if (!newplay) {
|
||||||
|
hardsubURL = undefined
|
||||||
|
hardsubGEO = undefined
|
||||||
|
} else {
|
||||||
|
hardsubURL = newplay.data.hardSubs.find((h) => h.hlang === hardsub.locale)?.url
|
||||||
|
hardsubGEO = newplay.data.hardSubs.find((h) => h.hlang === subs[0])?.geo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (hardsubURL) {
|
if (hardsubURL) {
|
||||||
downloadURL = hardsubURL
|
downloadURL = hardsubURL
|
||||||
downloadGEO = hardsubGEO
|
downloadGEO = hardsubGEO
|
||||||
console.log('Hardsub Playlist found')
|
|
||||||
} else {
|
} else {
|
||||||
downloadURL = play.data.url
|
downloadURL = play.data.url
|
||||||
downloadGEO = play.data.geo
|
downloadGEO = play.data.geo
|
||||||
console.log('Hardsub Playlist not found')
|
console.log('Hardsub Playlist not found')
|
||||||
|
messageBox('warning', ['Cancel'], 2, 'Hardsub Playlist not found', 'Hardsub Playlist not found', `${hardsub.locale} Hardsub Playlist not found, downloading japanese playlist instead.`)
|
||||||
|
server.logger.log({
|
||||||
|
level: 'error',
|
||||||
|
message: `${hardsub.locale} Hardsub Playlist not found, downloading japanese playlist instead.`,
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
section: 'crunchyrollDownloadProcessVideo'
|
||||||
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
downloadURL = play.data.url
|
downloadURL = play.data.url
|
||||||
downloadGEO = play.data.geo
|
downloadGEO = play.data.geo
|
||||||
console.log('Hardsub disabled, skipping')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var mdp = await crunchyGetPlaylistMPD(downloadURL, downloadGEO)
|
var mdp = await crunchyGetPlaylistMPD(downloadURL, downloadGEO)
|
||||||
|
Reference in New Issue
Block a user