/**
 * @file Music handler for YouTube videos. Does not support livestreams.
 * @author Ovyerus
 */

const ytdl = require('youtube-dl');
const got = require('got');

// List of all itag qualities can be found here: https://en.wikipedia.org/w/index.php?title=YouTube&oldid=800910021#Quality_and_formats.
const ITAG = '140'; // Preferred itag quality to get. Default: 140.
const ITAG_FALLBACK = '22'; // In the event that the previous itag could not be found, try finding this one. Should probably be a lower value.

class YouTubeHandler {
    constructor() {}

    async getInfo(url) {
        if (typeof url !== 'string') throw new TypeError('url is not a string.');

        let info = await new Promise((res, rej) => ytdl.getInfo(url, (err, i) => err ? rej(err) : res(i)));
        let res = {
            url,
            title: info.title,
            uploader: info.author.name,
            thumbnail: info.thumbnail_url.replace('default.jpg', 'hqdefault.jpg'),
            length: Number(info.length_seconds),
            type: 'YouTubeVideo'
        };

        return res;
    }

    async getStream(url) {
        if (typeof url !== 'string') throw new TypeError('url is not a string.');
            
        let info = await new Promise((res, rej) => ytdl.getInfo(url, (err, i) => err ? rej(err) : res(i)));
        let format = info.formats.find(f => f.itag === ITAG) || info.formats.find(f => f.itag === ITAG_FALLBACK);
        format = format ? format.url : info.url; // Fallback to default URL if the wanted itags could not be found;

        return got.stream(format);
    }
}

module.exports = YouTubeHandler;

@@ -868,19 +868,16 @@
 nfo.
-author.name
+uploader
 ,%0A  
@@ -915,100 +915,53 @@
 nail
-_url.replace('default.jpg', 'hqdefault.jpg'),%0A            length: Number(info.length_seconds
+,%0A            length: splitTime(info.duration
 ),%0A 
@@ -1144,21 +1144,9 @@
 ');%0A
-            
 %0A
+
     
@@ -1287,36 +1287,41 @@
 ats.find(f =%3E f.
-itag
+format_id
  === ITAG) %7C%7C in
@@ -1343,20 +1343,25 @@
 (f =%3E f.
-itag
+format_id
  === ITA
@@ -1525,16 +1525,16 @@
 ormat);%0A
-
     %7D%0A%7D%0A
@@ -1534,16 +1534,145 @@
    %7D%0A%7D%0A%0A
+function splitTime(time) %7B%0A    return time.split(':').reverse().map(v =%3E Number(v)).reduce((m, v, i) =%3E m + (v * (60 ** i)));%0A%7D%0A%0A
 module.e

Fix youtube-dl port issues