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