mirror of
https://gitlab.com/RemixDev/deemix-js.git
synced 2025-01-16 03:06:39 +00:00
Implemented execute command after download
This commit is contained in:
parent
5ec2e82fcb
commit
50b4785b59
|
@ -2,7 +2,7 @@ const { Track } = require('./types/Track.js')
|
||||||
const { StaticPicture } = require('./types/Picture.js')
|
const { StaticPicture } = require('./types/Picture.js')
|
||||||
const { streamTrack, generateStreamURL, DownloadCanceled } = require('./decryption.js')
|
const { streamTrack, generateStreamURL, DownloadCanceled } = require('./decryption.js')
|
||||||
const { tagID3, tagID3v1, tagFLAC } = require('./tagger.js')
|
const { tagID3, tagID3v1, tagFLAC } = require('./tagger.js')
|
||||||
const { USER_AGENT_HEADER, pipeline } = require('./utils/index.js')
|
const { USER_AGENT_HEADER, pipeline, shellEscape } = require('./utils/index.js')
|
||||||
const { DEFAULTS, OverwriteOption } = require('./settings.js')
|
const { DEFAULTS, OverwriteOption } = require('./settings.js')
|
||||||
const { generatePath, generateAlbumName, generateArtistName, generateDownloadObjectName } = require('./utils/pathtemplates.js')
|
const { generatePath, generateAlbumName, generateArtistName, generateDownloadObjectName } = require('./utils/pathtemplates.js')
|
||||||
const { TrackFormats } = require('deezer-js')
|
const { TrackFormats } = require('deezer-js')
|
||||||
|
@ -10,6 +10,7 @@ const got = require('got')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const { tmpdir } = require('os')
|
const { tmpdir } = require('os')
|
||||||
const { queue, each, eachOf } = require('async')
|
const { queue, each, eachOf } = require('async')
|
||||||
|
const { exec } = require("child_process")
|
||||||
|
|
||||||
const extensions = {
|
const extensions = {
|
||||||
[TrackFormats.FLAC]: '.flac',
|
[TrackFormats.FLAC]: '.flac',
|
||||||
|
@ -520,6 +521,8 @@ class Downloader {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute command after download
|
// Execute command after download
|
||||||
|
if (this.settings.executeCommand !== "")
|
||||||
|
exec(this.settings.executeCommand.replaceAll("%folder%", shellEscape(this.extrasPath)).replaceAll("%filename%", shellEscape(track.filename)))
|
||||||
}
|
}
|
||||||
|
|
||||||
async afterDownloadCollection(tracks){
|
async afterDownloadCollection(tracks){
|
||||||
|
@ -575,6 +578,8 @@ class Downloader {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute command after download
|
// Execute command after download
|
||||||
|
if (this.settings.executeCommand !== "")
|
||||||
|
exec(this.settings.executeCommand.replaceAll("%folder%", shellEscape(this.extrasPath)).replaceAll("%filename%", ''))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,12 @@ function uniqueArray(arr){
|
||||||
return arr
|
return arr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function shellEscape(s){
|
||||||
|
if (typeof s !== 'string') return ''
|
||||||
|
if (!(/[^\w@%+=:,./-]/g.test(s))) return s
|
||||||
|
return "'" + s.replaceAll("'", "'\"'\"'") + "'"
|
||||||
|
}
|
||||||
|
|
||||||
function removeDuplicateArtists(artist, artists){
|
function removeDuplicateArtists(artist, artists){
|
||||||
artists = uniqueArray(artists)
|
artists = uniqueArray(artists)
|
||||||
Object.keys(artist).forEach((role) => {
|
Object.keys(artist).forEach((role) => {
|
||||||
|
@ -88,5 +94,6 @@ module.exports = {
|
||||||
removeDuplicateArtists,
|
removeDuplicateArtists,
|
||||||
pipeline,
|
pipeline,
|
||||||
canWrite,
|
canWrite,
|
||||||
changeCase
|
changeCase,
|
||||||
|
shellEscape
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue