2021-05-30 15:31:27 +00:00
|
|
|
|
#!/usr/bin/env node
|
2021-09-12 17:44:11 +00:00
|
|
|
|
import ytdl from 'ytdl-core';
|
|
|
|
|
import getArtistTitle from 'get-artist-title';
|
|
|
|
|
import { generate } from './src/cue.js';
|
|
|
|
|
import minimist from 'minimist';
|
|
|
|
|
import exit from 'process';
|
|
|
|
|
import updateNotifier from 'update-notifier';
|
|
|
|
|
import pkg from './src/package.js';
|
|
|
|
|
import { processFile, processYoutube } from './src/process.js';
|
2021-07-29 06:14:23 +00:00
|
|
|
|
|
|
|
|
|
updateNotifier({ pkg }).notify();
|
2021-05-30 15:31:27 +00:00
|
|
|
|
|
2021-06-09 18:51:23 +00:00
|
|
|
|
let argv = minimist(process.argv.slice(2), {
|
2021-09-12 17:44:11 +00:00
|
|
|
|
string: ['audio-file', 'cue-title', 'cue-performer'],
|
2021-06-09 18:51:23 +00:00
|
|
|
|
});
|
|
|
|
|
|
2021-07-29 06:14:23 +00:00
|
|
|
|
if (argv.version) {
|
|
|
|
|
console.log(pkg.version);
|
|
|
|
|
} else if (argv._.length < 1 || argv.help) {
|
2021-06-09 18:51:23 +00:00
|
|
|
|
console.log(`Usage
|
2021-09-12 17:44:11 +00:00
|
|
|
|
$ youtube-cue [--audio-file audio.m4a] --cue-title "Album Name" --cue-performer "Album Artist" <youtube_url|input_file> [output_file]
|
|
|
|
|
|
|
|
|
|
youtube_url: Pass a Youtube URL from where description is fetched and parsed
|
|
|
|
|
input_file: Pass a plaintext file which contains the description text containing a timesheet.
|
2021-05-30 15:31:27 +00:00
|
|
|
|
|
|
|
|
|
Options
|
|
|
|
|
--help, Show help
|
2021-09-12 17:44:11 +00:00
|
|
|
|
--audio-file, Input Audio File (optional) that is written to the CUE sheet.
|
2021-06-28 09:34:09 +00:00
|
|
|
|
|
2021-09-12 17:44:11 +00:00
|
|
|
|
If a youtube URL is passed, then
|
|
|
|
|
The default audio file is set to %VIDEOTITLE.m4a
|
|
|
|
|
The default output file is set to %VIDEOTITLE.cue
|
|
|
|
|
Since video title is not available while parsing text files,
|
|
|
|
|
The default audio file is set to audio.m4a
|
|
|
|
|
The default output file is set to output.cue
|
2021-05-30 15:31:27 +00:00
|
|
|
|
|
2021-09-12 17:44:11 +00:00
|
|
|
|
Generally the parser detects whether numbers (such as 00:12) are positional timestamps or track durations.
|
2021-07-28 11:52:36 +00:00
|
|
|
|
To enforce a desired interpretation you can use these flags:
|
|
|
|
|
|
|
|
|
|
--timestamps Parse as positional timestamps (relative to the start of the playlist)
|
2021-09-12 17:44:11 +00:00
|
|
|
|
--durations Parse numbers as track durations instead.
|
2021-07-21 08:14:47 +00:00
|
|
|
|
|
|
|
|
|
The above 2 are only needed to force behaviour in very specific edge cases, they should
|
|
|
|
|
not be required for most files.
|
2021-07-21 08:00:42 +00:00
|
|
|
|
|
2021-09-12 17:44:11 +00:00
|
|
|
|
--cue-title "Title that goes into the CUE file for the complete CUE sheet"
|
|
|
|
|
--cue-performer "Performer for the entire collection. Commonly the album artist."
|
|
|
|
|
|
|
|
|
|
cue-title and cue-performer are recommended especially if you are reading the data from a text file.
|
|
|
|
|
|
2021-07-29 06:14:23 +00:00
|
|
|
|
--version Print version
|
|
|
|
|
|
2021-05-30 15:31:27 +00:00
|
|
|
|
Examples
|
2021-06-28 09:34:09 +00:00
|
|
|
|
$ youtube-cue --audio-file audio.m4a "https://www.youtube.com/watch?v=THzUassmQwE"
|
|
|
|
|
"T A Y L O R S W I F T – Folklore [Full album].cue" saved
|
2021-06-28 08:50:10 +00:00
|
|
|
|
$ youtube-cue "https://youtu.be/THzUassmQwE" folklore.cue
|
2021-09-12 17:44:11 +00:00
|
|
|
|
folklore.cue saved
|
|
|
|
|
$ youtube-cue --audio-file audio.m4a --cue-performer "Magic Riders" description.txt
|
|
|
|
|
"output.cue" saved`);
|
2021-06-09 18:51:23 +00:00
|
|
|
|
} else {
|
2021-09-12 17:44:11 +00:00
|
|
|
|
let urlOrFile = argv._[0];
|
|
|
|
|
|
|
|
|
|
if (fs.existsSync(urlOrFile)) {
|
|
|
|
|
let r = processFile(urlOrFile, argv);
|
|
|
|
|
} else {
|
|
|
|
|
let r = processYoutube(urlOrFile, argv);
|
|
|
|
|
}
|
|
|
|
|
generate({ r.tracks, r.artist, r.audioFile, r.album }, r.outputFile);
|
|
|
|
|
console.log(`"${outputFile}" saved`);
|
2021-05-30 15:31:27 +00:00
|
|
|
|
}
|