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 class="text-xs uppercase">{{ p.format }}</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 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
|
||||
@ -165,6 +166,7 @@ const playlist = ref<
|
||||
media: CrunchyEpisode | ADNEpisode
|
||||
dub: Array<{ locale: string; name: string }>
|
||||
sub: Array<{ locale: string; name: string }>
|
||||
hardsub: { name: string | undefined; locale: string, format: string }
|
||||
dir: string
|
||||
installDir: string
|
||||
partsleft: number
|
||||
@ -192,6 +194,7 @@ const getPlaylist = async () => {
|
||||
media: CrunchyEpisode | ADNEpisode
|
||||
dub: Array<{ locale: string; name: string }>
|
||||
sub: Array<{ locale: string; name: string }>
|
||||
hardsub: { name: string | undefined; locale: string, format: string }
|
||||
dir: string
|
||||
installDir: string
|
||||
partsleft: number
|
||||
|
@ -5,7 +5,7 @@ import { ADNEpisode } from '../types/adn'
|
||||
|
||||
const sequelize = new Sequelize({
|
||||
dialect: 'sqlite',
|
||||
storage: app.getPath('documents') + '/Crunchyroll Downloader/databases/v2/data.db'
|
||||
storage: app.getPath('documents') + '/Crunchyroll Downloader/databases/v3/data.db'
|
||||
})
|
||||
|
||||
interface AccountAttributes {
|
||||
@ -44,9 +44,9 @@ interface PlaylistAttributes {
|
||||
| 'completed'
|
||||
| 'failed'
|
||||
media: CrunchyEpisode | ADNEpisode
|
||||
dub: Array<string>
|
||||
sub: Array<string>
|
||||
hardsub: boolean
|
||||
dub: { name: string | undefined; locale: string }[]
|
||||
sub: { name: string | undefined; locale: string }[]
|
||||
hardsub: { name: string | undefined; locale: string, format: string }
|
||||
quality: 1080 | 720 | 480 | 360 | 240
|
||||
qualityaudio: 1 | 2 | 3 | undefined
|
||||
dir: string
|
||||
@ -58,12 +58,12 @@ interface PlaylistAttributes {
|
||||
|
||||
interface PlaylistCreateAttributes {
|
||||
media: CrunchyEpisode | ADNEpisode
|
||||
dub: Array<string>
|
||||
sub: Array<string>
|
||||
dub: { name: string | undefined; locale: string }[]
|
||||
sub: { name: string | undefined; locale: string }[]
|
||||
hardsub: { name: string | undefined; locale: string, format: string } | undefined
|
||||
dir: string
|
||||
quality: 1080 | 720 | 480 | 360 | 240
|
||||
qualityaudio: 1 | 2 | 3 | undefined
|
||||
hardsub: boolean
|
||||
status:
|
||||
| 'waiting'
|
||||
| 'preparing'
|
||||
@ -134,6 +134,10 @@ const Playlist: ModelDefined<PlaylistAttributes, PlaylistCreateAttributes> = seq
|
||||
allowNull: false,
|
||||
type: DataTypes.JSON
|
||||
},
|
||||
hardsub: {
|
||||
allowNull: true,
|
||||
type: DataTypes.JSON
|
||||
},
|
||||
dir: {
|
||||
allowNull: false,
|
||||
type: DataTypes.STRING
|
||||
@ -142,10 +146,6 @@ const Playlist: ModelDefined<PlaylistAttributes, PlaylistCreateAttributes> = seq
|
||||
allowNull: true,
|
||||
type: DataTypes.STRING
|
||||
},
|
||||
hardsub: {
|
||||
allowNull: false,
|
||||
type: DataTypes.BOOLEAN
|
||||
},
|
||||
failedreason: {
|
||||
allowNull: true,
|
||||
type: DataTypes.STRING
|
||||
|
@ -96,10 +96,10 @@ export async function addPlaylistController(
|
||||
request: FastifyRequest<{
|
||||
Body: {
|
||||
episodes: CrunchyEpisodes
|
||||
dubs: Array<string>
|
||||
subs: Array<string>
|
||||
dubs: { name: string | undefined; locale: string }[]
|
||||
subs: { name: string | undefined; locale: string }[]
|
||||
hardsub: { name: string | undefined; locale: string, format: string } | undefined
|
||||
dir: string
|
||||
hardsub: boolean
|
||||
quality: 1080 | 720 | 480 | 360 | 240
|
||||
qualityaudio: 1 | 2 | 3 | undefined
|
||||
service: 'CR' | 'ADN'
|
||||
@ -111,7 +111,7 @@ export async function addPlaylistController(
|
||||
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.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()
|
||||
|
@ -209,10 +209,10 @@ export async function updatePlaylistByID(
|
||||
// Add Episode to Playlist
|
||||
export async function addEpisodeToPlaylist(
|
||||
e: CrunchyEpisode,
|
||||
s: Array<string>,
|
||||
d: Array<string>,
|
||||
s: { name: string | undefined; locale: string }[],
|
||||
d: { name: string | undefined; locale: string }[],
|
||||
hardsub: { name: string | undefined; locale: string, format: string } | undefined,
|
||||
dir: string,
|
||||
hardsub: boolean,
|
||||
status:
|
||||
| 'waiting'
|
||||
| 'preparing'
|
||||
@ -295,8 +295,8 @@ async function checkPlaylists() {
|
||||
if (e.dataValues.service === 'CR') {
|
||||
downloadCrunchyrollPlaylist(
|
||||
(e.dataValues.media as CrunchyEpisode).id,
|
||||
(e as any).dataValues.dub.map((s: { locale: any }) => s.locale),
|
||||
(e as any).dataValues.sub.map((s: { locale: any }) => s.locale),
|
||||
e.dataValues.dub.map((s: { locale: any }) => s.locale),
|
||||
e.dataValues.sub.map((s: { locale: any }) => s.locale),
|
||||
e.dataValues.hardsub,
|
||||
(e.dataValues.media as CrunchyEpisode).id,
|
||||
e.dataValues.id,
|
||||
@ -471,7 +471,7 @@ export async function downloadCrunchyrollPlaylist(
|
||||
e: string,
|
||||
dubs: Array<string>,
|
||||
subs: Array<string>,
|
||||
hardsub: boolean,
|
||||
hardsub: { name: string | undefined; locale: string; format: string; },
|
||||
episodeID: string,
|
||||
downloadID: number,
|
||||
name: string,
|
||||
@ -926,7 +926,7 @@ export async function downloadCrunchyrollPlaylist(
|
||||
return
|
||||
}
|
||||
|
||||
const play = await crunchyGetPlaylist(code, geo)
|
||||
var play = await crunchyGetPlaylist(code, geo)
|
||||
|
||||
if (!play) {
|
||||
await updatePlaylistByID(downloadID, 'failed')
|
||||
@ -945,24 +945,61 @@ export async function downloadCrunchyrollPlaylist(
|
||||
|
||||
var downloadGEO
|
||||
|
||||
if (hardsub) {
|
||||
const hardsubURL = play.data.hardSubs.find((h) => h.hlang === subs[0])?.url
|
||||
if (hardsub && hardsub.locale) {
|
||||
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) {
|
||||
downloadURL = hardsubURL
|
||||
downloadGEO = hardsubGEO
|
||||
console.log('Hardsub Playlist found')
|
||||
} else {
|
||||
downloadURL = play.data.url
|
||||
downloadGEO = play.data.geo
|
||||
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 {
|
||||
downloadURL = play.data.url
|
||||
downloadGEO = play.data.geo
|
||||
console.log('Hardsub disabled, skipping')
|
||||
}
|
||||
|
||||
var mdp = await crunchyGetPlaylistMPD(downloadURL, downloadGEO)
|
||||
|
Reference in New Issue
Block a user