switch to minimist arg parser
This commit is contained in:
parent
c730a8f823
commit
c06841f57d
33
index.js
33
index.js
|
@ -1,36 +1,31 @@
|
|||
#!/usr/bin/env node
|
||||
import meow from 'meow';
|
||||
import ytdl from 'ytdl-core';
|
||||
import getArtistTitle from 'get-artist-title'
|
||||
import {parse} from './src/parser.js'
|
||||
import {generate} from './src/cue.js'
|
||||
import minimist from 'minimist'
|
||||
|
||||
const cli = meow(`
|
||||
Usage
|
||||
let argv = minimist(process.argv.slice(2), {
|
||||
string: 'audio-file'
|
||||
});
|
||||
|
||||
if (argv._.length <2 || argv.help ){
|
||||
console.log(`Usage
|
||||
$ youtube-cue --audio-file <youtube_url> <output.cue>
|
||||
|
||||
Options
|
||||
--help, Show help
|
||||
--version, Show version
|
||||
--audio-file, Input Audio File
|
||||
|
||||
Examples
|
||||
$ youtube-cue "https://www.youtube.com/watch?v=THzUassmQwE" output.cue
|
||||
output.cue saved
|
||||
`, {
|
||||
importMeta: import.meta,
|
||||
flags: {
|
||||
audioFile: {type: 'string'}
|
||||
},
|
||||
allowUnknownFlags: false
|
||||
});
|
||||
|
||||
if(cli.input.length==2) {
|
||||
let url = cli.input[0]
|
||||
let output_file = cli.input[1]
|
||||
output.cue saved`)
|
||||
} else {
|
||||
let url = argv._[0]
|
||||
let output_file = argv._[1]
|
||||
|
||||
ytdl.getInfo(url).then(info=>{
|
||||
let audioFile = cli.flags.audioFile? cli.flags.audioFile : `${info.videoDetails.title}.m4a`
|
||||
let audioFile = argv['audio-file']? argv['audio-file'] : `${info.videoDetails.title}.m4a`
|
||||
let res = getArtistTitle(info.videoDetails.title,{
|
||||
defaultArtist: "Unknown Artist",
|
||||
defaultTitle: info.videoDetails.title
|
||||
|
@ -38,8 +33,6 @@ if(cli.input.length==2) {
|
|||
let [artist, album] = res
|
||||
artist = (info.videoDetails.media ? info.videoDetails.media.artist : artist)
|
||||
let tracks = parse(info.videoDetails.description, {artist})
|
||||
generate({tracks, artist, audioFile, album}, cli.input[1])
|
||||
generate({tracks, artist, audioFile, album}, output_file)
|
||||
})
|
||||
} else {
|
||||
cli.showHelp()
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -15,7 +15,7 @@
|
|||
"dependencies": {
|
||||
"console-log-level": "^1.4.1",
|
||||
"get-artist-title": "^1.3.1",
|
||||
"meow": "^10.0.0",
|
||||
"minimist": "^1.2.5",
|
||||
"ytdl-core": "^4.8.2"
|
||||
},
|
||||
"repository": {
|
||||
|
|
Loading…
Reference in New Issue