Fixes #75
Drops any tracks that start after the track length (as per YouTube). We can add a flag for making this optional in case it is neededpull/104/head
parent
91242ce61f
commit
5ba24e95db
2
index.js
2
index.js
|
@ -49,7 +49,6 @@ if (argv.version) {
|
|||
let url = argv._[0];
|
||||
|
||||
ytdl.getInfo(url).then((info) => {
|
||||
console.log(info);
|
||||
let audioFile = argv["audio-file"]
|
||||
? argv["audio-file"]
|
||||
: `${info.videoDetails.title}.m4a`;
|
||||
|
@ -75,6 +74,7 @@ if (argv.version) {
|
|||
artist,
|
||||
forceTimestamps,
|
||||
forceDurations,
|
||||
length: Number(info.videoDetails.lengthSeconds)
|
||||
});
|
||||
generate({ tracks, artist, audioFile, album }, output_file);
|
||||
console.log(`"${output_file}" saved`);
|
||||
|
|
|
@ -153,6 +153,12 @@ var fixDurations = function (list) {
|
|||
}
|
||||
};
|
||||
|
||||
var dropInvalid = function(e) {
|
||||
// All tracks should start before the closing time
|
||||
if (_options.length) return (e.start.calc < _options.length);
|
||||
return true;
|
||||
}
|
||||
|
||||
export function parse(
|
||||
text,
|
||||
options = { artist: "Unknown", forceTimestamps: false, forceDurations: false }
|
||||
|
@ -184,5 +190,5 @@ export function parse(
|
|||
}
|
||||
}
|
||||
|
||||
return result.map(parseTitle).map(parseArtist).map(addTrack).map(addEnd);
|
||||
return result.map(parseTitle).map(parseArtist).map(addTrack).map(addEnd).filter(dropInvalid);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue