# Path: build/plugin/src/resources/libraries/youtube_dl/compat.py
# def compat_realpath(path):
#     while os.path.islink(path):
#         path = os.path.abspath(os.readlink(path))
#     return path
# 
# Path: build/plugin/src/resources/libraries/youtube_dl/utils.py
# def encode_compat_str(string, encoding=preferredencoding(), errors='strict'):
#     return string if isinstance(string, compat_str) else compat_str(string, encoding, errors)
# 
# Path: build/plugin/src/resources/libraries/youtube_dl/version.py



import io
import json
import traceback
import hashlib
import os
import subprocess
import sys
from zipimport import zipimporter
from .compat import compat_realpath
from .utils import encode_compat_str
from .version import __version__
    from hashlib import sha256
        if verbose:
            to_screen(encode_compat_str(traceback.format_exc()))
        to_screen('ERROR: can\'t obtain versions info. Please try again later.')
        to_screen('Visit https://github.com/blackjack4494/yt-dlc/releases/latest')
        return
    if 'signature' not in versions_info:
        to_screen('ERROR: the versions file is not signed or corrupted. Aborting.')
        return
    signature = versions_info['signature']
    del versions_info['signature']
    if not rsa_verify(json.dumps(versions_info, sort_keys=True).encode('utf-8'), signature, UPDATES_RSA_KEY):
        to_screen('ERROR: the versions file signature is invalid. Aborting.')
        return

    version_id = versions_info['latest']

    def version_tuple(version_str):
        return tuple(map(int, version_str.split('.')))
    if version_tuple(__version__) >= version_tuple(version_id):
        to_screen('youtube-dlc is up to date (%s)' % __version__)
        return

    to_screen('Updating to version ' + version_id + ' ...')
    version = versions_info['versions'][version_id]

    print_notes(to_screen, versions_info['versions'])

    # sys.executable is set to the full pathname of the exe-file for py2exe
    # though symlinks are not followed so that we need to do this manually
    # with help of realpath

# Path: build/plugin/src/resources/libraries/youtube_dl/compat.py
# def compat_realpath(path):
#     while os.path.islink(path):
#         path = os.path.abspath(os.readlink(path))
#     return path
# 
# Path: build/plugin/src/resources/libraries/youtube_dl/utils.py
# def encode_compat_str(string, encoding=preferredencoding(), errors='strict'):
#     return string if isinstance(string, compat_str) else compat_str(string, encoding, errors)
# 
# Path: build/plugin/src/resources/libraries/youtube_dl/version.py



# Path: build/plugin/src/resources/libraries/youtube_dl/update.py
import io
import json
import traceback
import hashlib
import os
import subprocess
import sys
from zipimport import zipimporter
from .compat import compat_realpath
from .utils import encode_compat_str
from .version import __version__
    from hashlib import sha256

        if verbose:
            to_screen(encode_compat_str(traceback.format_exc()))
        to_screen('ERROR: can\'t obtain versions info. Please try again later.')
        to_screen('Visit https://github.com/blackjack4494/yt-dlc/releases/latest')
        return
    if 'signature' not in versions_info:
        to_screen('ERROR: the versions file is not signed or corrupted. Aborting.')
        return
    signature = versions_info['signature']
    del versions_info['signature']
    if not rsa_verify(json.dumps(versions_info, sort_keys=True).encode('utf-8'), signature, UPDATES_RSA_KEY):
        to_screen('ERROR: the versions file signature is invalid. Aborting.')
        return

    version_id = versions_info['latest']

    def version_tuple(version_str):
        return tuple(map(int, version_str.split('.')))
    if version_tuple(__version__) >= version_tuple(version_id):
        to_screen('youtube-dlc is up to date (%s)' % __version__)
        return

    to_screen('Updating to version ' + version_id + ' ...')
    version = versions_info['versions'][version_id]

    print_notes(to_screen, versions_info['versions'])

    # sys.executable is set to the full pathname of the exe-file for py2exe
    # though symlinks are not followed so that we need to do this manually
    # with help of realpath

    filename = compat_realpath(sys.executable if hasattr(sys, 'frozen') else sys.argv[0])