implemented custom audio downloader and changed db version
This commit is contained in:
parent
74bfaf2884
commit
a44932a90b
@ -5,7 +5,7 @@ import { ADNEpisode } from '../types/adn'
|
||||
|
||||
const sequelize = new Sequelize({
|
||||
dialect: 'sqlite',
|
||||
storage: app.getPath('documents') + '/Crunchyroll Downloader/databases/v1/data.db'
|
||||
storage: app.getPath('documents') + '/Crunchyroll Downloader/databases/v2/data.db'
|
||||
})
|
||||
|
||||
interface AccountAttributes {
|
||||
@ -48,6 +48,7 @@ interface PlaylistAttributes {
|
||||
sub: Array<string>
|
||||
hardsub: boolean
|
||||
quality: 1080 | 720 | 480 | 360 | 240
|
||||
qualityaudio: 1 | 2 | 3 | undefined
|
||||
dir: string
|
||||
installDir: string
|
||||
failedreason: string
|
||||
@ -61,6 +62,7 @@ interface PlaylistCreateAttributes {
|
||||
sub: Array<string>
|
||||
dir: string
|
||||
quality: 1080 | 720 | 480 | 360 | 240
|
||||
qualityaudio: 1 | 2 | 3 | undefined
|
||||
hardsub: boolean
|
||||
status:
|
||||
| 'waiting'
|
||||
@ -152,6 +154,10 @@ const Playlist: ModelDefined<PlaylistAttributes, PlaylistCreateAttributes> = seq
|
||||
allowNull: true,
|
||||
type: DataTypes.BOOLEAN
|
||||
},
|
||||
qualityaudio: {
|
||||
allowNull: true,
|
||||
type: DataTypes.BOOLEAN
|
||||
},
|
||||
service: {
|
||||
allowNull: true,
|
||||
type: DataTypes.STRING
|
||||
|
@ -101,6 +101,7 @@ export async function addPlaylistController(
|
||||
dir: string
|
||||
hardsub: boolean
|
||||
quality: 1080 | 720 | 480 | 360 | 240
|
||||
qualityaudio: 1 | 2 | 3 | undefined
|
||||
service: 'CR' | 'ADN'
|
||||
format: 'mp4' | 'mkv'
|
||||
}
|
||||
@ -110,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.service, body.format)
|
||||
await addEpisodeToPlaylist(e, body.subs, body.dubs, body.dir, body.hardsub, 'waiting', body.quality, body.qualityaudio, body.service, body.format)
|
||||
}
|
||||
|
||||
return reply.code(201).send()
|
||||
|
@ -228,6 +228,7 @@ export async function addEpisodeToPlaylist(
|
||||
| 'completed'
|
||||
| 'failed',
|
||||
quality: 1080 | 720 | 480 | 360 | 240,
|
||||
qualityaudio: 1 | 2 | 3 | undefined,
|
||||
service: 'CR' | 'ADN',
|
||||
format: 'mp4' | 'mkv'
|
||||
) {
|
||||
@ -239,6 +240,7 @@ export async function addEpisodeToPlaylist(
|
||||
hardsub: hardsub,
|
||||
status: status,
|
||||
quality: quality,
|
||||
qualityaudio: qualityaudio,
|
||||
service: service,
|
||||
format: format
|
||||
})
|
||||
@ -297,6 +299,7 @@ async function checkPlaylists() {
|
||||
(e.dataValues.media as CrunchyEpisode).episode_number,
|
||||
(e.dataValues.media as CrunchyEpisode).episode,
|
||||
e.dataValues.quality,
|
||||
e.dataValues.qualityaudio ? e.dataValues.qualityaudio-1 : 0,
|
||||
e.dataValues.dir,
|
||||
e.dataValues.format,
|
||||
(e.dataValues.media as CrunchyEpisode).geo
|
||||
@ -470,6 +473,7 @@ export async function downloadCrunchyrollPlaylist(
|
||||
episode: number,
|
||||
episode_string: string,
|
||||
quality: 1080 | 720 | 480 | 360 | 240,
|
||||
qualityaudio: number,
|
||||
downloadPath: string,
|
||||
format: 'mp4' | 'mkv',
|
||||
geo: string | undefined
|
||||
@ -744,11 +748,13 @@ export async function downloadCrunchyrollPlaylist(
|
||||
|
||||
if (!playlist) return
|
||||
|
||||
const assetId = playlist.mediaGroups.AUDIO.audio.main.playlists[0].segments[0].resolvedUri.match(/\/assets\/(?:p\/)?([^_,]+)/)
|
||||
const playlistindex = playlist.mediaGroups.AUDIO.audio.main.playlists[qualityaudio] ? qualityaudio : 0
|
||||
|
||||
const assetId = playlist.mediaGroups.AUDIO.audio.main.playlists[playlistindex].segments[0].resolvedUri.match(/\/assets\/(?:p\/)?([^_,]+)/)
|
||||
|
||||
if (!assetId) {
|
||||
console.log(playlist.mediaGroups.AUDIO.audio.main.playlists[0].segments[0])
|
||||
console.log(playlist.mediaGroups.AUDIO.audio.main.playlists[0].segments[0].uri)
|
||||
console.log(playlist.mediaGroups.AUDIO.audio.main.playlists[playlistindex].segments[0])
|
||||
console.log(playlist.mediaGroups.AUDIO.audio.main.playlists[playlistindex].segments[0].uri)
|
||||
console.log('No AssetID found, exiting.')
|
||||
await updatePlaylistByID(downloadID, 'failed')
|
||||
messageBox('error', ['Cancel'], 2, 'No AssetID found', 'No AssetID found', "No AssetID found, can't download MPD.")
|
||||
@ -766,8 +772,8 @@ export async function downloadCrunchyrollPlaylist(
|
||||
|
||||
let p: { filename: string; url: string }[] = []
|
||||
|
||||
if (playlist.mediaGroups.AUDIO.audio.main.playlists[0].contentProtection) {
|
||||
if (!playlist.mediaGroups.AUDIO.audio.main.playlists[0].contentProtection['com.widevine.alpha'].pssh) {
|
||||
if (playlist.mediaGroups.AUDIO.audio.main.playlists[playlistindex].contentProtection) {
|
||||
if (!playlist.mediaGroups.AUDIO.audio.main.playlists[playlistindex].contentProtection['com.widevine.alpha'].pssh) {
|
||||
console.log('No PSSH found, exiting.')
|
||||
messageBox(
|
||||
'error',
|
||||
@ -786,7 +792,7 @@ export async function downloadCrunchyrollPlaylist(
|
||||
})
|
||||
return
|
||||
}
|
||||
pssh = Uint8ArrayToBase64(playlist.mediaGroups.AUDIO.audio.main.playlists[0].contentProtection['com.widevine.alpha'].pssh)
|
||||
pssh = Uint8ArrayToBase64(playlist.mediaGroups.AUDIO.audio.main.playlists[playlistindex].contentProtection['com.widevine.alpha'].pssh)
|
||||
|
||||
keys = await getDRMKeys(pssh, assetId[1], list.account_id)
|
||||
|
||||
@ -804,9 +810,9 @@ export async function downloadCrunchyrollPlaylist(
|
||||
}
|
||||
|
||||
if (
|
||||
(playlist.mediaGroups.AUDIO.audio.main.playlists[0].contentProtection && !drmL3blob && !drmL3key) ||
|
||||
(playlist.mediaGroups.AUDIO.audio.main.playlists[0].contentProtection && !drmL3blob) ||
|
||||
(playlist.mediaGroups.AUDIO.audio.main.playlists[0].contentProtection && !drmL3key)
|
||||
(playlist.mediaGroups.AUDIO.audio.main.playlists[playlistindex].contentProtection && !drmL3blob && !drmL3key) ||
|
||||
(playlist.mediaGroups.AUDIO.audio.main.playlists[playlistindex].contentProtection && !drmL3blob) ||
|
||||
(playlist.mediaGroups.AUDIO.audio.main.playlists[playlistindex].contentProtection && !drmL3key)
|
||||
) {
|
||||
await updatePlaylistByID(downloadID, 'failed')
|
||||
messageBox(
|
||||
@ -828,11 +834,11 @@ export async function downloadCrunchyrollPlaylist(
|
||||
}
|
||||
|
||||
p.push({
|
||||
filename: (playlist.mediaGroups.AUDIO.audio.main.playlists[0].segments[0].map.uri.match(/([^\/]+)\?/) as RegExpMatchArray)[1],
|
||||
url: playlist.mediaGroups.AUDIO.audio.main.playlists[0].segments[0].map.resolvedUri
|
||||
filename: (playlist.mediaGroups.AUDIO.audio.main.playlists[playlistindex].segments[0].map.uri.match(/([^\/]+)\?/) as RegExpMatchArray)[1],
|
||||
url: playlist.mediaGroups.AUDIO.audio.main.playlists[playlistindex].segments[0].map.resolvedUri
|
||||
})
|
||||
|
||||
for (const s of playlist.mediaGroups.AUDIO.audio.main.playlists[0].segments) {
|
||||
for (const s of playlist.mediaGroups.AUDIO.audio.main.playlists[playlistindex].segments) {
|
||||
p.push({
|
||||
filename: (s.uri.match(/([^\/]+)\?/) as RegExpMatchArray)[1],
|
||||
url: s.resolvedUri
|
||||
|
Reference in New Issue
Block a user