# Path: build/plugin/src/resources/libraries/youtube_dl/compat.py
#     class compat_cookiejar_Cookie(compat_cookiejar.Cookie):
#         class compat_HTMLParseError(Exception):
#     class compat_urllib_request_DataHandler(compat_urllib_request.BaseHandler):
# class _TreeBuilder(etree.TreeBuilder):
#     class compat_Struct(struct.Struct):
#         class compat_Struct(struct.Struct):
#         def __init__(self, version, name, value, *args, **kwargs):
#     def compat_urllib_parse_unquote_to_bytes(string):
#     def compat_urllib_parse_unquote(string, encoding='utf-8', errors='replace'):
#     def compat_urllib_parse_unquote_plus(string, encoding='utf-8', errors='replace'):
#     def compat_urllib_parse_urlencode(query, doseq=0, encoding='utf-8'):
#         def encode_elem(e):
#         def encode_dict(d):
#         def encode_list(l):
#         def data_open(self, req):
#     def doctype(self, name, pubid, system):
#     def compat_etree_fromstring(text):
#         def _etree_iter(root):
#     def _XML(text, parser=None):
#     def _element_factory(*args, **kwargs):
#     def compat_etree_fromstring(text):
#     def compat_etree_register_namespace(prefix, uri):
#     def compat_xpath(xpath):
#     def _parse_qsl(qs, keep_blank_values=False, strict_parsing=False,
#                    encoding='utf-8', errors='replace'):
#     def compat_parse_qs(qs, keep_blank_values=False, strict_parsing=False,
#                         encoding='utf-8', errors='replace'):
#     def compat_shlex_quote(s):
#         def compat_shlex_quote(s):
#     def compat_shlex_split(s, comments=False, posix=True):
# def compat_ord(c):
#     def compat_setenv(key, value, env=os.environ):
#     def compat_getenv(key, default=None):
#     def compat_setenv(key, value, env=os.environ):
#         def encode(v):
#         def compat_expanduser(path):
#         def compat_expanduser(path):
#     def compat_realpath(path):
#     def compat_print(s):
#     def compat_print(s):
#     def compat_getpass(prompt, *args, **kwargs):
#     def _testfunc(x):
#     def compat_kwargs(kwargs):
#     def compat_socket_create_connection(address, timeout, source_address=None):
# def workaround_optparse_bug9161():
#         def _compat_add_option(self, *args, **kwargs):
#     def compat_get_terminal_size(fallback=(80, 24)):
#     def compat_itertools_count(start=0, step=1):
#     def compat_struct_pack(spec, *args):
#     def compat_struct_unpack(spec, *args):
#         def __init__(self, fmt):
#             def unpack(self, string):
#     def compat_b64decode(s, *args, **kwargs):
#     def compat_ctypes_WINFUNCTYPE(*args, **kwargs):
#         def resf(tpl, *args, **kwargs):
#     def compat_ctypes_WINFUNCTYPE(*args, **kwargs):


import base64
import binascii
import calendar
import codecs
import collections
import contextlib
import ctypes
import datetime
import email.utils
import email.header
import errno
import functools
import gzip
import io
import itertools
import json
import locale
import math
import operator
import os
import platform
import random
import re
import socket
import ssl
import subprocess
import sys
import tempfile
import time
import traceback
import xml.etree.ElementTree
import zlib
                import msvcrt
    import ctypes
    import ctypes.wintypes
    import ctypes.wintypes
    import msvcrt
        import fcntl
        import xattr
from .compat import (
    compat_HTMLParseError,
    compat_HTMLParser,
    compat_basestring,
    compat_chr,
    compat_cookiejar,
    compat_ctypes_WINFUNCTYPE,
    compat_etree_fromstring,
    compat_expanduser,
    compat_html_entities,
    compat_html_entities_html5,
    compat_http_client,
    compat_integer_types,
    compat_kwargs,
    compat_os_name,
    compat_parse_qs,
    compat_shlex_quote,
    compat_str,
    compat_struct_pack,
    compat_struct_unpack,
    compat_urllib_error,
    compat_urllib_parse,
    compat_urllib_parse_urlencode,
    compat_urllib_parse_urlparse,
    compat_urllib_parse_unquote_plus,
    compat_urllib_request,
    compat_urlparse,
    compat_xpath,
)
from .socks import (
    ProxyType,
    sockssocket,
)
    from zipimport import zipimporter
    return get_elements_by_attribute(
        'class', r'[^\'"]*\b%s\b[^\'"]*' % re.escape(class_name),
        html, escape_value=False)


def get_elements_by_attribute(attribute, value, html, escape_value=True):
    """Return the content of the tag with the specified attribute in the passed HTML document"""

    value = re.escape(value) if escape_value else value

    retlist = []
    for m in re.finditer(r'''(?xs)
        <([a-zA-Z0-9:._-]+)
         (?:\s+[a-zA-Z0-9:._-]+(?:=[a-zA-Z0-9:._-]*|="[^"]*"|='[^']*'|))*?
         \s+%s=['"]?%s['"]?
         (?:\s+[a-zA-Z0-9:._-]+(?:=[a-zA-Z0-9:._-]*|="[^"]*"|='[^']*'|))*?
        \s*>
        (?P<content>.*?)
        </\1>
    ''' % (re.escape(attribute), value), html):
        res = m.group('content')

        if res.startswith('"') or res.startswith("'"):
            res = res[1:-1]

        retlist.append(unescapeHTML(res))

    return retlist



# Path: build/plugin/src/resources/libraries/youtube_dl/compat.py
#     class compat_cookiejar_Cookie(compat_cookiejar.Cookie):
#         class compat_HTMLParseError(Exception):
#     class compat_urllib_request_DataHandler(compat_urllib_request.BaseHandler):
# class _TreeBuilder(etree.TreeBuilder):
#     class compat_Struct(struct.Struct):
#         class compat_Struct(struct.Struct):
#         def __init__(self, version, name, value, *args, **kwargs):
#     def compat_urllib_parse_unquote_to_bytes(string):
#     def compat_urllib_parse_unquote(string, encoding='utf-8', errors='replace'):
#     def compat_urllib_parse_unquote_plus(string, encoding='utf-8', errors='replace'):
#     def compat_urllib_parse_urlencode(query, doseq=0, encoding='utf-8'):
#         def encode_elem(e):
#         def encode_dict(d):
#         def encode_list(l):
#         def data_open(self, req):
#     def doctype(self, name, pubid, system):
#     def compat_etree_fromstring(text):
#         def _etree_iter(root):
#     def _XML(text, parser=None):
#     def _element_factory(*args, **kwargs):
#     def compat_etree_fromstring(text):
#     def compat_etree_register_namespace(prefix, uri):
#     def compat_xpath(xpath):
#     def _parse_qsl(qs, keep_blank_values=False, strict_parsing=False,
#                    encoding='utf-8', errors='replace'):
#     def compat_parse_qs(qs, keep_blank_values=False, strict_parsing=False,
#                         encoding='utf-8', errors='replace'):
#     def compat_shlex_quote(s):
#         def compat_shlex_quote(s):
#     def compat_shlex_split(s, comments=False, posix=True):
# def compat_ord(c):
#     def compat_setenv(key, value, env=os.environ):
#     def compat_getenv(key, default=None):
#     def compat_setenv(key, value, env=os.environ):
#         def encode(v):
#         def compat_expanduser(path):
#         def compat_expanduser(path):
#     def compat_realpath(path):
#     def compat_print(s):
#     def compat_print(s):
#     def compat_getpass(prompt, *args, **kwargs):
#     def _testfunc(x):
#     def compat_kwargs(kwargs):
#     def compat_socket_create_connection(address, timeout, source_address=None):
# def workaround_optparse_bug9161():
#         def _compat_add_option(self, *args, **kwargs):
#     def compat_get_terminal_size(fallback=(80, 24)):
#     def compat_itertools_count(start=0, step=1):
#     def compat_struct_pack(spec, *args):
#     def compat_struct_unpack(spec, *args):
#         def __init__(self, fmt):
#             def unpack(self, string):
#     def compat_b64decode(s, *args, **kwargs):
#     def compat_ctypes_WINFUNCTYPE(*args, **kwargs):
#         def resf(tpl, *args, **kwargs):
#     def compat_ctypes_WINFUNCTYPE(*args, **kwargs):


# Path: build/plugin/src/resources/libraries/youtube_dl/utils.py
import base64
import binascii
import calendar
import codecs
import collections
import contextlib
import ctypes
import datetime
import email.utils
import email.header
import errno
import functools
import gzip
import io
import itertools
import json
import locale
import math
import operator
import os
import platform
import random
import re
import socket
import ssl
import subprocess
import sys
import tempfile
import time
import traceback
import xml.etree.ElementTree
import zlib
                import msvcrt
    import ctypes
    import ctypes.wintypes
    import ctypes.wintypes
    import msvcrt
        import fcntl
        import xattr
from .compat import (
    compat_HTMLParseError,
    compat_HTMLParser,
    compat_basestring,
    compat_chr,
    compat_cookiejar,
    compat_ctypes_WINFUNCTYPE,
    compat_etree_fromstring,
    compat_expanduser,
    compat_html_entities,
    compat_html_entities_html5,
    compat_http_client,
    compat_integer_types,
    compat_kwargs,
    compat_os_name,
    compat_parse_qs,
    compat_shlex_quote,
    compat_str,
    compat_struct_pack,
    compat_struct_unpack,
    compat_urllib_error,
    compat_urllib_parse,
    compat_urllib_parse_urlencode,
    compat_urllib_parse_urlparse,
    compat_urllib_parse_unquote_plus,
    compat_urllib_request,
    compat_urlparse,
    compat_xpath,
)
from .socks import (
    ProxyType,
    sockssocket,
)
    from zipimport import zipimporter

    return get_elements_by_attribute(
        'class', r'[^\'"]*\b%s\b[^\'"]*' % re.escape(class_name),
        html, escape_value=False)


def get_elements_by_attribute(attribute, value, html, escape_value=True):
    """Return the content of the tag with the specified attribute in the passed HTML document"""

    value = re.escape(value) if escape_value else value

    retlist = []
    for m in re.finditer(r'''(?xs)
        <([a-zA-Z0-9:._-]+)
         (?:\s+[a-zA-Z0-9:._-]+(?:=[a-zA-Z0-9:._-]*|="[^"]*"|='[^']*'|))*?
         \s+%s=['"]?%s['"]?
         (?:\s+[a-zA-Z0-9:._-]+(?:=[a-zA-Z0-9:._-]*|="[^"]*"|='[^']*'|))*?
        \s*>
        (?P<content>.*?)
        </\1>
    ''' % (re.escape(attribute), value), html):
        res = m.group('content')

        if res.startswith('"') or res.startswith("'"):
            res = res[1:-1]

        retlist.append(unescapeHTML(res))

    return retlist



class HTMLAttributeParser(compat_HTMLParser):