Returns the filename from URL (including extension), that
        may be:

        https://www.youtube.com/watch?v=ZEtEH-GIAJE ->
        '[Hatsune Miku] After Rain Sweet*Drops [English Sub] -
        YouTube.mp4'

        https://www.youtube.com/watch?v=ZEtEH-GIAJE ->
        'watch_v=ZEtEH-GIAJE.mp4'

        The former case occurs when URL is a web page with <title> tags.
        The last case will occur in pages with malformed HTML or when
        you pass a non-HTML URL as a parameter (for example, a link to
        a direct HTML5 video).

        The extension will be detected according to the stream type,
        for example RTMPStream will always be '.flv'. The only format
        that may returns a wrong extension is HTTPStream, since there
        is no standard container in this case. We assume (for now) that
        every HTTPStream is '.mp4'.

def get_title(self):
        """Returns the filename from URL (including extension), that
        may be:

        https://www.youtube.com/watch?v=ZEtEH-GIAJE ->
        '[Hatsune Miku] After Rain Sweet*Drops [English Sub] -
        YouTube.mp4'

        https://www.youtube.com/watch?v=ZEtEH-GIAJE ->
        'watch_v=ZEtEH-GIAJE.mp4'

        The former case occurs when URL is a web page with <title> tags.
        The last case will occur in pages with malformed HTML or when
        you pass a non-HTML URL as a parameter (for example, a link to
        a direct HTML5 video).

        The extension will be detected according to the stream type,
        for example RTMPStream will always be '.flv'. The only format
        that may returns a wrong extension is HTTPStream, since there
        is no standard container in this case. We assume (for now) that
        every HTTPStream is '.mp4'.
        """

        stream_type = self.stream.__class__.__name__
        try:
            extension = VIDEO_EXTENSIONS[stream_type]
        except KeyError:
            print('No extension found...', file=sys.stderr)
            extension = ''

        r = requests.get(self.original_url)
        regex_result = _RE_PAGE_TITLE.search(r.text)
        
        if regex_result is not None:
          filename = regex_result.group(1)

        # Badly formatted HTML (e.g. no '<title>')
        else:
          # 'http://www.example.com/path1/path2?q=V1' ->
          # 'http', 'www.example.com', '/path1/path2', 'q=V1'
          split_url = urlsplit(self.original_url)
          # '/path1/path2' -> 'path2'
          filename = split_url.path.split('/')[-1]
          # 'path2' -> 'path2_q=V1'
          if split_url.query:
              filename = filename + '_' + split_url.query

        # Substitute invalid chars for '_'
        filename = _RE_INVALID_CHARS.sub('_', filename)

        # Since Windows (Explorer?) has a retarted limit for 255 chars for
        # filename, including the path, we need to limit the filename to a sane
        # size. In this case I am using 80 chars.
        return filename[:80] + extension