🎨 Clean up code

This commit is contained in:
Androz2091 2020-11-08 14:23:34 +01:00
parent 7657ffedef
commit 5e3075dad1

View file

@ -31,22 +31,18 @@ class Track {
* The video duration (formatted).
* @type {string}
*/
this.duration =
videoData.durationFormatted ||
`${Math.floor(parseInt(videoData.videoDetails.lengthSeconds) / 60)}:${
parseInt(videoData.videoDetails.lengthSeconds) % 60
}`
this.duration = videoData.durationFormatted ||
`${Math.floor(parseInt(videoData.videoDetails.lengthSeconds) / 60)}:${parseInt(videoData.videoDetails.lengthSeconds) % 60}`
/**
* The video description
* @type {string}
*/
this.description = videoData.description;
this.description = videoData.description
/**
* The video thumbnail
* @type {string}
*/
this.thumbnail =
typeof videoData.thumbnail === "object"
this.thumbnail = typeof videoData.thumbnail === 'object'
? videoData.thumbnail.url
: videoData.thumbnail
/**
@ -86,17 +82,11 @@ class Track {
* @type {number}
*/
get durationMS () {
const args = this.duration.split(":")
if (args.length === 3) {
return (
parseInt(args[0]) * 60 * 60 * 1000 +
parseInt(args[1]) * 60 * 1000 +
parseInt(args[2]) * 1000
);
} else if (args.length === 2) {
return parseInt(args[0]) * 60 * 1000 + parseInt(args[1]) * 1000
} else {
return parseInt(args[0]) * 1000
const args = this.duration.split(':')
switch (args.length) {
case 3: return parseInt(args[0]) * 60 * 60 * 1000 + parseInt(args[1]) * 60 * 1000 + parseInt(args[2]) * 1000
case 2: return parseInt(args[0]) * 60 * 1000 + parseInt(args[1]) * 1000
default: return parseInt(args[0]) * 1000
}
}
}