added custom naming to download process
This commit is contained in:
parent
20fc3c2ac5
commit
e97bb2a525
@ -85,6 +85,33 @@ onMounted(() => {
|
|||||||
episodeNamingTemplate.value = result
|
episodeNamingTemplate.value = result
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
watch(episodeNamingTemplate, () => {
|
||||||
|
if (!episodeNamingTemplate.value) return
|
||||||
|
setEpisodeTemplate(episodeNamingTemplate.value)
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(seasonNamingTemplate, () => {
|
||||||
|
if (!seasonNamingTemplate.value) return
|
||||||
|
setSeasonTemplate(seasonNamingTemplate.value)
|
||||||
|
})
|
||||||
|
|
||||||
|
const setEpisodeTemplate = (name: string) => {
|
||||||
|
if (process.client) {
|
||||||
|
;(window as any).myAPI.setEpisodeTemplate(name).then((result: string) => {
|
||||||
|
episodeNamingTemplate.value = result
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const setSeasonTemplate = (name: string) => {
|
||||||
|
if (process.client) {
|
||||||
|
;(window as any).myAPI.setSeasonTemplate(name).then((result: string) => {
|
||||||
|
seasonNamingTemplate.value = result
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style></style>
|
<style></style>
|
||||||
|
@ -159,12 +159,24 @@ async function deletePlaylistandTMP() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
deletePlaylistandTMP();
|
deletePlaylistandTMP()
|
||||||
|
|
||||||
// Update Playlist Item
|
// Update Playlist Item
|
||||||
export async function updatePlaylistByID(
|
export async function updatePlaylistByID(
|
||||||
id: number,
|
id: number,
|
||||||
status?: 'waiting' | 'preparing' | 'waiting for playlist' | 'waiting for sub playlist' | 'waiting for dub playlist' | 'downloading' | 'merging video' | 'decrypting video' | 'awaiting all dubs downloaded' | 'merging video & audio' | 'completed' | 'failed',
|
status?:
|
||||||
|
| 'waiting'
|
||||||
|
| 'preparing'
|
||||||
|
| 'waiting for playlist'
|
||||||
|
| 'waiting for sub playlist'
|
||||||
|
| 'waiting for dub playlist'
|
||||||
|
| 'downloading'
|
||||||
|
| 'merging video'
|
||||||
|
| 'decrypting video'
|
||||||
|
| 'awaiting all dubs downloaded'
|
||||||
|
| 'merging video & audio'
|
||||||
|
| 'completed'
|
||||||
|
| 'failed',
|
||||||
quality?: 1080 | 720 | 480 | 360 | 240,
|
quality?: 1080 | 720 | 480 | 360 | 240,
|
||||||
installedDir?: string
|
installedDir?: string
|
||||||
) {
|
) {
|
||||||
@ -199,7 +211,19 @@ export async function addEpisodeToPlaylist(
|
|||||||
d: Array<string>,
|
d: Array<string>,
|
||||||
dir: string,
|
dir: string,
|
||||||
hardsub: boolean,
|
hardsub: boolean,
|
||||||
status: 'waiting' | 'preparing' | 'waiting for playlist' | 'waiting for sub playlist' | 'waiting for dub playlist' | 'downloading' | 'merging video' | 'decrypting video' | 'awaiting all dubs downloaded' | 'merging video & audio' | 'completed' | 'failed',
|
status:
|
||||||
|
| 'waiting'
|
||||||
|
| 'preparing'
|
||||||
|
| 'waiting for playlist'
|
||||||
|
| 'waiting for sub playlist'
|
||||||
|
| 'waiting for dub playlist'
|
||||||
|
| 'downloading'
|
||||||
|
| 'merging video'
|
||||||
|
| 'decrypting video'
|
||||||
|
| 'awaiting all dubs downloaded'
|
||||||
|
| 'merging video & audio'
|
||||||
|
| 'completed'
|
||||||
|
| 'failed',
|
||||||
quality: 1080 | 720 | 480 | 360 | 240,
|
quality: 1080 | 720 | 480 | 360 | 240,
|
||||||
service: 'CR' | 'ADN',
|
service: 'CR' | 'ADN',
|
||||||
format: 'mp4' | 'mkv'
|
format: 'mp4' | 'mkv'
|
||||||
@ -427,24 +451,24 @@ export async function downloadADNPlaylist(
|
|||||||
await deleteFolder(videoFolder)
|
await deleteFolder(videoFolder)
|
||||||
}
|
}
|
||||||
|
|
||||||
var counter = 0;
|
var counter = 0
|
||||||
var maxLimit = 1;
|
var maxLimit = 1
|
||||||
|
|
||||||
async function incrementPlaylistCounter() {
|
async function incrementPlaylistCounter() {
|
||||||
return new Promise<void>((resolve) => {
|
return new Promise<void>((resolve) => {
|
||||||
const interval = setInterval(() => {
|
const interval = setInterval(() => {
|
||||||
if (counter < maxLimit) {
|
if (counter < maxLimit) {
|
||||||
counter++;
|
counter++
|
||||||
clearInterval(interval);
|
clearInterval(interval)
|
||||||
resolve();
|
resolve()
|
||||||
}
|
}
|
||||||
}, 100);
|
}, 100)
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function decrementPlaylistCounter() {
|
function decrementPlaylistCounter() {
|
||||||
if (counter > 0) {
|
if (counter > 0) {
|
||||||
counter--;
|
counter--
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -464,8 +488,7 @@ export async function downloadCrunchyrollPlaylist(
|
|||||||
format: 'mp4' | 'mkv',
|
format: 'mp4' | 'mkv',
|
||||||
geo: string | undefined
|
geo: string | undefined
|
||||||
) {
|
) {
|
||||||
|
const accmaxstream = await checkAccountMaxStreams()
|
||||||
const accmaxstream = await checkAccountMaxStreams();
|
|
||||||
|
|
||||||
if (accmaxstream) {
|
if (accmaxstream) {
|
||||||
maxLimit = accmaxstream
|
maxLimit = accmaxstream
|
||||||
@ -473,7 +496,7 @@ export async function downloadCrunchyrollPlaylist(
|
|||||||
|
|
||||||
await updatePlaylistByID(downloadID, 'waiting for playlist')
|
await updatePlaylistByID(downloadID, 'waiting for playlist')
|
||||||
|
|
||||||
await incrementPlaylistCounter();
|
await incrementPlaylistCounter()
|
||||||
var playlist = await crunchyGetPlaylist(e, geo)
|
var playlist = await crunchyGetPlaylist(e, geo)
|
||||||
|
|
||||||
if (!playlist) {
|
if (!playlist) {
|
||||||
@ -494,8 +517,8 @@ export async function downloadCrunchyrollPlaylist(
|
|||||||
const found = playlist.data.versions.find((v) => v.audio_locale === 'ja-JP')
|
const found = playlist.data.versions.find((v) => v.audio_locale === 'ja-JP')
|
||||||
if (found) {
|
if (found) {
|
||||||
await deleteVideoToken(episodeID, playlist.data.token)
|
await deleteVideoToken(episodeID, playlist.data.token)
|
||||||
decrementPlaylistCounter();
|
decrementPlaylistCounter()
|
||||||
await incrementPlaylistCounter();
|
await incrementPlaylistCounter()
|
||||||
playlist = await crunchyGetPlaylist(found.guid, found.geo)
|
playlist = await crunchyGetPlaylist(found.guid, found.geo)
|
||||||
} else {
|
} else {
|
||||||
console.log('Exact Playlist not found, taking what crunchy gives.')
|
console.log('Exact Playlist not found, taking what crunchy gives.')
|
||||||
@ -524,7 +547,7 @@ export async function downloadCrunchyrollPlaylist(
|
|||||||
}
|
}
|
||||||
|
|
||||||
await deleteVideoToken(episodeID, playlist.data.token)
|
await deleteVideoToken(episodeID, playlist.data.token)
|
||||||
decrementPlaylistCounter();
|
decrementPlaylistCounter()
|
||||||
|
|
||||||
const subFolder = await createFolder()
|
const subFolder = await createFolder()
|
||||||
|
|
||||||
@ -532,7 +555,19 @@ export async function downloadCrunchyrollPlaylist(
|
|||||||
|
|
||||||
const videoFolder = await createFolder()
|
const videoFolder = await createFolder()
|
||||||
|
|
||||||
const seasonFolder = await createFolderName(`${name.replace(/[/\\?%*:|"<>]/g, '')} Season ${season}`, downloadPath)
|
var seasonFolderNaming = (await settings.get('SeasonTemp')) as string
|
||||||
|
|
||||||
|
if (!seasonFolderNaming) {
|
||||||
|
seasonFolderNaming = '{seriesName} Season {seasonNumber}'
|
||||||
|
}
|
||||||
|
|
||||||
|
seasonFolderNaming = seasonFolderNaming
|
||||||
|
.replace('{seriesName}', name.replace(/[/\\?%*:|"<>]/g, ''))
|
||||||
|
.replace('{seasonNumber}', season.toString())
|
||||||
|
.replace('{seasonNumberDD}', season.toString().padStart(2, '0'))
|
||||||
|
.replace('{quality}', quality.toString() + 'p')
|
||||||
|
|
||||||
|
const seasonFolder = await createFolderName(seasonFolderNaming, downloadPath)
|
||||||
|
|
||||||
await updatePlaylistByID(downloadID, undefined, undefined, seasonFolder)
|
await updatePlaylistByID(downloadID, undefined, undefined, seasonFolder)
|
||||||
|
|
||||||
@ -565,7 +600,7 @@ export async function downloadCrunchyrollPlaylist(
|
|||||||
if (playlist.data.audioLocale !== 'ja-JP') {
|
if (playlist.data.audioLocale !== 'ja-JP') {
|
||||||
const foundStream = playlist.data.versions.find((v) => v.audio_locale === 'ja-JP')
|
const foundStream = playlist.data.versions.find((v) => v.audio_locale === 'ja-JP')
|
||||||
if (foundStream) {
|
if (foundStream) {
|
||||||
await incrementPlaylistCounter();
|
await incrementPlaylistCounter()
|
||||||
subPlaylist = await crunchyGetPlaylist(foundStream.guid, foundStream.geo)
|
subPlaylist = await crunchyGetPlaylist(foundStream.guid, foundStream.geo)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -618,11 +653,11 @@ export async function downloadCrunchyrollPlaylist(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (found) {
|
if (found) {
|
||||||
await incrementPlaylistCounter();
|
await incrementPlaylistCounter()
|
||||||
const list = await crunchyGetPlaylist(found.guid, found.geo)
|
const list = await crunchyGetPlaylist(found.guid, found.geo)
|
||||||
if (list) {
|
if (list) {
|
||||||
await deleteVideoToken(episodeID, list.data.token)
|
await deleteVideoToken(episodeID, list.data.token)
|
||||||
decrementPlaylistCounter();
|
decrementPlaylistCounter()
|
||||||
|
|
||||||
const foundSub = list.data.subtitles.find((sub) => sub.language === d)
|
const foundSub = list.data.subtitles.find((sub) => sub.language === d)
|
||||||
if (foundSub) {
|
if (foundSub) {
|
||||||
@ -678,7 +713,7 @@ export async function downloadCrunchyrollPlaylist(
|
|||||||
const audioDownload = async () => {
|
const audioDownload = async () => {
|
||||||
const audios: Array<string> = []
|
const audios: Array<string> = []
|
||||||
for (const v of dubDownloadList) {
|
for (const v of dubDownloadList) {
|
||||||
await incrementPlaylistCounter();
|
await incrementPlaylistCounter()
|
||||||
const list = await crunchyGetPlaylist(v.guid, v.geo)
|
const list = await crunchyGetPlaylist(v.guid, v.geo)
|
||||||
|
|
||||||
if (!list) return
|
if (!list) return
|
||||||
@ -688,7 +723,7 @@ export async function downloadCrunchyrollPlaylist(
|
|||||||
if (!playlist) return
|
if (!playlist) return
|
||||||
|
|
||||||
await deleteVideoToken(episodeID, list.data.token)
|
await deleteVideoToken(episodeID, list.data.token)
|
||||||
decrementPlaylistCounter();
|
decrementPlaylistCounter()
|
||||||
|
|
||||||
const assetId = playlist.mediaGroups.AUDIO.audio.main.playlists[0].segments[0].resolvedUri.match(/\/assets\/(?:p\/)?([^_,]+)/)
|
const assetId = playlist.mediaGroups.AUDIO.audio.main.playlists[0].segments[0].resolvedUri.match(/\/assets\/(?:p\/)?([^_,]+)/)
|
||||||
|
|
||||||
@ -765,7 +800,6 @@ export async function downloadCrunchyrollPlaylist(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const downloadVideo = async () => {
|
const downloadVideo = async () => {
|
||||||
|
|
||||||
downloading.push({
|
downloading.push({
|
||||||
id: downloadID,
|
id: downloadID,
|
||||||
status: 'Waiting for Playlist',
|
status: 'Waiting for Playlist',
|
||||||
@ -803,7 +837,7 @@ export async function downloadCrunchyrollPlaylist(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
await incrementPlaylistCounter();
|
await incrementPlaylistCounter()
|
||||||
const play = await crunchyGetPlaylist(code, geo)
|
const play = await crunchyGetPlaylist(code, geo)
|
||||||
|
|
||||||
if (!play) {
|
if (!play) {
|
||||||
@ -848,7 +882,7 @@ export async function downloadCrunchyrollPlaylist(
|
|||||||
if (!mdp) return
|
if (!mdp) return
|
||||||
|
|
||||||
await deleteVideoToken(episodeID, play.data.token)
|
await deleteVideoToken(episodeID, play.data.token)
|
||||||
decrementPlaylistCounter();
|
decrementPlaylistCounter()
|
||||||
|
|
||||||
var hq = mdp.playlists.find((i) => i.attributes.RESOLUTION?.height === quality)
|
var hq = mdp.playlists.find((i) => i.attributes.RESOLUTION?.height === quality)
|
||||||
|
|
||||||
@ -970,7 +1004,22 @@ export async function downloadCrunchyrollPlaylist(
|
|||||||
if (!audios) return
|
if (!audios) return
|
||||||
|
|
||||||
await updatePlaylistByID(downloadID, 'merging video & audio')
|
await updatePlaylistByID(downloadID, 'merging video & audio')
|
||||||
await mergeVideoFile(file as string, audios, subss, seasonFolder, `${name.replace(/[/\\?%*:|"<>]/g, '')} Season ${season} Episode ${episode}`, format, downloadID)
|
|
||||||
|
var episodeNaming = (await settings.get('EpisodeTemp')) as string
|
||||||
|
|
||||||
|
if (!episodeNaming) {
|
||||||
|
episodeNaming = '{seriesName} Season {seasonNumber} Episode {episodeNumber}'
|
||||||
|
}
|
||||||
|
|
||||||
|
episodeNaming = episodeNaming
|
||||||
|
.replace('{seriesName}', name.replace(/[/\\?%*:|"<>]/g, ''))
|
||||||
|
.replace('{seasonNumber}', season.toString())
|
||||||
|
.replace('{seasonNumberDD}', season.toString().padStart(2, '0'))
|
||||||
|
.replace('{episodeNumber}', episode.toString())
|
||||||
|
.replace('{episodeNumberDD}', episode.toString().padStart(2, '0'))
|
||||||
|
.replace('{quality}', quality.toString() + 'p')
|
||||||
|
|
||||||
|
await mergeVideoFile(file as string, audios, subss, seasonFolder, episodeNaming, format, downloadID)
|
||||||
|
|
||||||
await updatePlaylistByID(downloadID, 'completed')
|
await updatePlaylistByID(downloadID, 'completed')
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user