def development_status():
            global dev_status
            global customclassifiers_bool
            lifeeasy.clear()
            print('Choose a development status from the following')
            print('')
            print('Alpha')
            print('Beta')
            print('Stable')
            print('')
            print(
                'Or press [enter] to add a custom one when adding classifiers...'
            )
            print('')
            print('')
            dev_status_try = input('> ')

            if dev_status_try.lower() == 'alpha':
                dev_status = 'Development Status :: 3 - Alpha'
            elif dev_status_try.lower() == 'beta':
                dev_status = 'Development Status :: 4 - Beta'
            elif dev_status_try.lower() == 'stable':
                dev_status = 'Development Status :: 5 - Production/Stable'
            elif dev_status_try == '':
                customclassifiers_bool = True
            else:
                print("Sorry but I couldn't recognize the status.")
                lifeeasy.sleep(1)
                print('Please try again...')
                lifeeasy.sleep(1)
                development_status()
            def console_output():
                '''
                Internal Function used to display statistics during processing the images.\n
                Might be disabled and thus main function analyze_episode could be optimized for better performance but I prefer seeing what's going on. 
                '''
                total_fps = 0
                total_frames = 'N/A'
                total_frames_frame = 0
                total_frames_frames = 0
                for element in fps_dict:
                    total_fps += fps_dict[element]
                single_thread_stats = ''
                for element in frames_stats_dict:
                    total_frames_frame += frames_stats_dict[element]['frame']
                    total_frames_frames += frames_stats_dict[element]['total_frames']
                    try:
                        try:
                            thread_percentage = int(frames_stats_dict[element]['frame']) * 100 / int(frames_stats_dict[element]['total_frames'])
                            thread_percentage = round(thread_percentage, 1)
                        except:
                            thread_percentage = 'n/a'
                        try:
                            frames_per_second = str(fps_dict[element])
                        except:
                            frames_per_second = 'n/a'
                        single_thread_stats = single_thread_stats + 'Episode ' + str(element) + ': Frame ' + str(frames_stats_dict[element]['frame']) + '/' + str(int(frames_stats_dict[element]['total_frames'])) + ' (' + str(thread_percentage) + '%) ・ Analyze Speed: ' + frames_per_second + 'FPS ・ Status: ' + frames_stats_dict[element]['status'] + '\n'
                    except:
                        try:
                            thread_percentage = int(frames_stats_dict[element]['frame']) * 100 / int(frames_stats_dict[element]['total_frames'])
                            thread_percentage = round(thread_percentage, 1)
                        except:
                            thread_percentage = 'n/a'
                        single_thread_stats = single_thread_stats + 'Episode ' + str(element) + ': Frame ' + str(frames_stats_dict[element]['frame']) + '/' + str(int(frames_stats_dict[element]['total_frames'])) + ' (' + str(thread_percentage) + '%) ・ Analyze Speed: 0FPS ・ Status: Starting\n'

                try:
                    total_frames_percentage = total_frames_frame * 100 / total_frames_frames
                    total_frames_percentage = round(total_frames_percentage, 2)
                except:
                    total_frames_percentage = 'n/a'
                total_frames = str(total_frames_frame) + '/' + str(int(total_frames_frames))

                lifeeasy.sleep(0.1)
                lifeeasy.clear()
                try:
                    remaining_frames = total_frames_frames - total_frames_frame
                    remaining_time = remaining_frames / int(total_fps)
                    eta = str(timedelta(seconds=remaining_time))
                except:
                    eta = 'N/A'
                print(f'Anime: {anime}\nFrame: {total_frames} ({str(total_frames_percentage)}%)\nAnalyze Speed: {str(total_fps)}FPS\nRemaining Time (ETA): {eta[:-7]}\n\nActive Threads\nーーーーーーーーーーーー\n{single_thread_stats}\nErina Project\n©Anime no Sekai - 2020')
                if stop_command_output == False:
                    thread = threading.Thread(target=console_output)
                    thread.daemon = True
                    thread.start()
def first_confirmation():
    print('Make sure to have your package uploaded to GitHub')
    lifeeasy.sleep(1)
    print('Make sure to make a release of this package on GitHub')
    lifeeasy.sleep(1)
    print('')
    print('')
    user_choice = input('Press [enter] to coninue or enter [quit] to abort...')
    if user_choice.lower() == "quit":
        return 1
    else:
        return 0
def start():
    global cleaning_dir
    global destination_dir
    global destination_dir_name
    global unique_number
    global number_of_items

    lifeeasy.clear()
    if __file__ == '__main__':
        print("What's the folder you want to clean today?")
        cleaning_dir = input('> ')
    else:
        cleaning_dir = lifeeasy.working_dir()
    if cleaning_dir.lower() == 'cancel' or cleaning_dir.lower(
    ) == 'stop' or cleaning_dir.lower() == 'quit' or cleaning_dir.lower(
    ) == 'exit':
        goodbye(nothing=True)
    elif filecenter.isdir(cleaning_dir):
        if cleaning_dir[-1] != '/' or cleaning_dir[-1] != '\\':
            if filecenter.os_name() == 'nt':
                cleaning_dir = cleaning_dir + '\\'
            else:
                cleaning_dir = cleaning_dir + '/'

        for _ in filecenter.files_in_dir(cleaning_dir):
            number_of_items += 1

        destination_dir_name = 'Cleaned'
        while filecenter.exists(cleaning_dir + destination_dir_name):
            destination_dir_name = destination_dir_name + ' ' + str(
                unique_number)
            unique_number += 1
        destination_dir = cleaning_dir + destination_dir_name
        filecenter.make_dir(destination_dir)
        decide_mode()
    else:
        lifeeasy.display_action('It seems like you mistyped the path',
                                delay=0.1)
        print('Please retry entering the path to your folder')
        lifeeasy.sleep(2)
        start()
 def ask_for_github_release():
     global download_url
     print(
         'What is the URL of your GitHub release? (it ends with .tar.gz)'
     )
     download_url_try = input('> ')
     print('')
     if lifeeasy.request_statuscode(method='get',
                                    url=download_url_try) == 200:
         download_url = download_url_try
     else:
         print(
             "It seems that you mistyped the URL or that the repository is private..."
         )
         lifeeasy.sleep(2)
         print(
             "Please put your GitHub repository visibility in public and retry..."
         )
         print('')
         lifeeasy.sleep(2)
         ask_for_github_release()
def decide_mode():
    lifeeasy.clear()
    print('Available options')
    print('')
    print('nosort   >   nothing will be sorted in your cleaned up folder')
    print(
        'type     >   each file will be sorted and put in a folder according to its type'
    )
    print('')
    print('')
    print('')
    print('How do you want to sort your cleaned folder?')
    decision = input('> ')
    if decision.lower() == 'cancel' or decision.lower(
    ) == 'stop' or decision.lower() == 'quit' or decision.lower() == 'exit':
        goodbye(nothing=True)
    elif decision.lower() == 'nosort' or decision.lower(
    ) == 'osort' or decision.lower() == 'nsort' or decision.lower(
    ) == 'noort' or decision.lower() == 'nosrt' or decision.lower(
    ) == 'nosot' or decision.lower() == 'nosor':
        lifeeasy.display_title('Cleaning your folder')
        lifeeasy.display_body(['Chosen mode: No Sorting'])
        lifeeasy.display(wait=0.5)
        nosort()
    elif decision.lower() == 'type' or decision.lower(
    ) == 'ype' or decision.lower() == 'tpe' or decision.lower(
    ) == 'tye' or decision.lower() == 'typ':
        lifeeasy.display_title('Cleaning your folder')
        lifeeasy.display_body(['Chosen mode: Type Sorting'])
        lifeeasy.display(wait=0.5)
        sort_by_type()
    else:
        print('Sorry I did not understand.')
        lifeeasy.sleep(2)
        lifeeasy.clear()
        decide_mode()
def create_information():
    lifeeasy.change_working_dir(filecenter.get_correct_path(destination_dir))
    print(destination_dir)
    lifeeasy.sleep(3)
    information_file = open('cleaning_information.txt', 'w+')
    information_file.write('Here are the information about this folder.\n')
    information_file.write('\n')
    information_file.write('Cleaned the: {date} {time}\n'.format(
        date=lifeeasy.today(), time=lifeeasy.current_time()))
    information_file.write('\n')
    information_file.write('\n')
    information_file.write('\n')
    information_file.write('Cleaned folder: {}\n'.format(cleaning_dir))
    information_file.write('Result folder: {}\n'.format(destination_dir))
    information_file.write('\n')
    information_file.write(
        'Number of items in given folder: {}\n'.format(number_of_items))
    information_file.write(
        'Number of moved items: {}\n'.format(number_of_moved_items))
    information_file.write('\n')
    information_file.write('\n')
    information_file.write('Generated by Folder Cleaner\n')
    information_file.write('©Anime no Sekai - 2020\n')
    information_file.close()
from subprocess import check_output  # Using this import just to install the dependencies if not.

# I will only use my library lifeeasy and will not import anything else after it is installed.

# IMPORTS
try:
    import lifeeasy
except:
    print('It is the first time launching the program')
    print('Installing the dependencies...')
    command_output = check_output(["pip", "install", "lifeeasy"],
                                  universal_newlines=True)
    import lifeeasy
    print('Successfully installed the dependencies!')
    lifeeasy.sleep(2)

print('System Information')
print("System: " + lifeeasy.system())
print("Node name: " + lifeeasy.node())
print("Release: " + lifeeasy.release())
print("Version: " + lifeeasy.version())
print("Machine: " + lifeeasy.machine())
print("Boot Time: " + lifeeasy.boot_time())
print('')
input('Press [enter] to continue...')
lifeeasy.clear()

print("Processor (CPU): " + lifeeasy.processor())
print("Number of physical cores: " + str(lifeeasy.number_of_physical_cores()))
print("Number of cores: " + str(lifeeasy.number_of_cores()))
print("CPU Max Freq.: " + str(lifeeasy.cpu_max_frequency()))
def add_animes_to_database(auto_analyze=True):
    global anime
    global fps_dict
    global frames_stats_dict
    global queue

    for file in filecenter.files_in_dir(erina_add_animes_path):
        if file == '.DS_Store':
            continue
        if file == '.gitkeep':
            continue
        if filecenter.type_from_extension(filecenter.extension_from_base(file)) == 'Folder':
            anime = file

            if anime == '':
                print('No anime folder found.')
                quit()

            if '-a' in sys.argv or '--auto' in sys.argv or auto_analyze == True:
                anilist_filename = erinacache.anilist_search_caching(anime)
                anilist_id = anilist_filename.replace('.erina', '')
                season = '1'
            else:
                print('What is the AniList ID for ' + anime + '?')
                anilist_id = input('> ')
                print('Which season is it?')
                season = input('> ')



            def analyze_episode(episode):
                """
                Internal Function that is ran by multiple thread to analyze each frame of an anime episode and create a file with its hash.
                Erina Project
                © Anime no Sekai - 2020
                """

                global fps_dict
                global frames_stats_dict
                global queue

                queue += 1
                episode_number = erina_aniep.episode_from_filename(episode, anime)
                
                frames_stats_dict[episode_number] = {'frame': 0, 'total_frames': 0, 'status': 'Starting'}

                video = cv2.VideoCapture(erina_add_animes_path + anime + '/' + episode)

                frame_count = video.get(cv2.CAP_PROP_FRAME_COUNT)
                framerate = video.get(cv2.CAP_PROP_FPS)
                duration = frame_count/framerate

                success, image = video.read()
                
                count = 0
                fps = 0
                start_loop_fps = 0
                end_loop_fps = 0
                start_loop_time = process_time()
                from_dict = {}
                first_frame_dict = {}

                new_database_path = erina_database_path + anime + '/' + episode_number
                if filecenter.isdir(new_database_path) == False:
                    filecenter.make_dir(new_database_path)
                
                skip = False
                while success:
                    if skip == False:
                        hashing_image = Image.fromarray(image)
                        image_hash = imagehash.average_hash(hashing_image)

                        second = count/framerate

                        try:
                            from_second = from_dict[str(image_hash)]
                            at_second = (float(from_second) + second) / 2
                        except:
                            from_dict[str(image_hash)] = second
                            from_second = second
                            at_second = second

                        try:
                            first_frame = first_frame_dict[str(image_hash)]
                        except:
                            first_frame_dict[str(image_hash)] = count
                            first_frame = count
                                
                        database_content = []
                        database_content.append('AniList ID: ' + anilist_id)
                        database_content.append('Anime: ' + anime)
                        database_content.append('Season: ' + season)
                        database_content.append('Episode: ' + episode_number)
                        database_content.append('First Frame: ' + str(first_frame))
                        database_content.append('Last Frame: ' + str(count))
                        database_content.append('From: ' + str(from_second))
                        database_content.append('To: ' + str(second))
                        database_content.append('At: ' + str(at_second))
                        database_content.append('Hash: ' + str(image_hash))
                        database_content.append('Hashing Algorithm: Average Hash (aHash)')
                        database_content.append('Filename: ' + episode)
                        database_content.append('Episode Framerate: ' + str(framerate))
                        database_content.append('Episode Duration: ' + str(duration))
                        database_content.append('Episode Frame Count: ' + str(frame_count))
                        database_content.append('')
                        database_content.append('Analyze Date: ' + str(datetime.timestamp(datetime.today())))
                        
                        lifeeasy.write_file(str(image_hash) + '.erina', database_content, new_database_path)

                    frames_stats_dict[episode_number] = {'frame': count, 'total_frames': frame_count, 'status': 'Active'}
                    
                    count += 1

                    end_loop_fps += 1
                    end_loop_time = process_time()
                    if end_loop_time - start_loop_time > 1:
                        fps = int(end_loop_fps - start_loop_fps)
                        fps_dict[episode_number] = fps
                        start_loop_time = process_time()
                        start_loop_fps = end_loop_fps

                    if skip == True:
                        skip = False
                        success, image = video.read()
                    else:
                        skip = True
                        success = video.grab()
                queue -= 1
                frames_stats_dict[episode_number] = {'frame': count, 'total_frames': frame_count, 'status': 'Done'}
                fps_dict.pop(episode_number, None)


            start_time = process_time()
            for episode in filecenter.files_in_dir(erina_add_animes_path + anime):
                if filecenter.type_from_extension(filecenter.extension_from_base(episode)) != 'Video':
                    continue
                else:
                    print('Opening new thread...')
                    thread = threading.Thread(target=analyze_episode, args=(episode,))
                    thread.daemon = True
                    thread.start()

            stop_command_output = False

            def console_output():
                '''
                Internal Function used to display statistics during processing the images.\n
                Might be disabled and thus main function analyze_episode could be optimized for better performance but I prefer seeing what's going on. 
                '''
                total_fps = 0
                total_frames = 'N/A'
                total_frames_frame = 0
                total_frames_frames = 0
                for element in fps_dict:
                    total_fps += fps_dict[element]
                single_thread_stats = ''
                for element in frames_stats_dict:
                    total_frames_frame += frames_stats_dict[element]['frame']
                    total_frames_frames += frames_stats_dict[element]['total_frames']
                    try:
                        try:
                            thread_percentage = int(frames_stats_dict[element]['frame']) * 100 / int(frames_stats_dict[element]['total_frames'])
                            thread_percentage = round(thread_percentage, 1)
                        except:
                            thread_percentage = 'n/a'
                        try:
                            frames_per_second = str(fps_dict[element])
                        except:
                            frames_per_second = 'n/a'
                        single_thread_stats = single_thread_stats + 'Episode ' + str(element) + ': Frame ' + str(frames_stats_dict[element]['frame']) + '/' + str(int(frames_stats_dict[element]['total_frames'])) + ' (' + str(thread_percentage) + '%) ・ Analyze Speed: ' + frames_per_second + 'FPS ・ Status: ' + frames_stats_dict[element]['status'] + '\n'
                    except:
                        try:
                            thread_percentage = int(frames_stats_dict[element]['frame']) * 100 / int(frames_stats_dict[element]['total_frames'])
                            thread_percentage = round(thread_percentage, 1)
                        except:
                            thread_percentage = 'n/a'
                        single_thread_stats = single_thread_stats + 'Episode ' + str(element) + ': Frame ' + str(frames_stats_dict[element]['frame']) + '/' + str(int(frames_stats_dict[element]['total_frames'])) + ' (' + str(thread_percentage) + '%) ・ Analyze Speed: 0FPS ・ Status: Starting\n'

                try:
                    total_frames_percentage = total_frames_frame * 100 / total_frames_frames
                    total_frames_percentage = round(total_frames_percentage, 2)
                except:
                    total_frames_percentage = 'n/a'
                total_frames = str(total_frames_frame) + '/' + str(int(total_frames_frames))

                lifeeasy.sleep(0.1)
                lifeeasy.clear()
                try:
                    remaining_frames = total_frames_frames - total_frames_frame
                    remaining_time = remaining_frames / int(total_fps)
                    eta = str(timedelta(seconds=remaining_time))
                except:
                    eta = 'N/A'
                print(f'Anime: {anime}\nFrame: {total_frames} ({str(total_frames_percentage)}%)\nAnalyze Speed: {str(total_fps)}FPS\nRemaining Time (ETA): {eta[:-7]}\n\nActive Threads\nーーーーーーーーーーーー\n{single_thread_stats}\nErina Project\n©Anime no Sekai - 2020')
                if stop_command_output == False:
                    thread = threading.Thread(target=console_output)
                    thread.daemon = True
                    thread.start()

            console_output()

            lifeeasy.sleep(3)

            while queue != 0:
                lifeeasy.sleep(1)

            stop_command_output = True

            lifeeasy.sleep(3)

            print('')
            end_time = process_time()
            print('Total time: ' + str(end_time - start_time) + ' seconds')

            if '-a' not in sys.argv and '--auto' not in sys.argv and auto_analyze == False:
                print('')
                print(f'Caching AniList API with the ID {str(anilist_id)}...')
                erinacache.anilist_caching(int(anilist_id))
            print(f'{anime} has been added to the database')
def setup(customurl=False, force_upgrade=False):
    global package_name
    global upgrade
    global custom_setup

    upgrade = force_upgrade

    setup = []

    # AUTHOR
    author = input('Who is the author? ')
    print('')

    def naming_package():
        global package_name
        global upgrade
        # NAME
        package_name = input("What's the name of your package? ")
        print('')

        lifeeasy.display_action('Verification', delay=0.1)
        name_verification = lifeeasy.request(
            'https://pypi.org/project/' + package_name + '/', 'get')
        if name_verification.status_code == 404:
            print('The name is available!')
        elif name_verification.status_code == 200:
            request = lifeeasy.request(
                'https://pypi.org/pypi/' + package_name + '/json', 'get')
            request_json = json.loads(request.text)
            if request_json['info']['author'] == author:
                print('upload mode: upgrade')
                print('Do you want to change some metadatas or keep them?')
                user_choice = input(
                    'press [enter] to continue with current metadatas or type [continue] to continue modifying the metadatas... '
                )
                if user_choice.lower() == 'continue' or user_choice.lower(
                ) == 'ontinue' or user_choice.lower(
                ) == 'cntinue' or user_choice.lower(
                ) == 'coninue' or user_choice.lower(
                ) == 'contnue' or user_choice.lower(
                ) == 'contiue' or user_choice.lower(
                ) == 'contine' or user_choice.lower() == 'continu':
                    upgrade = False
                else:
                    upgrade = True
            else:
                print('This name is already taken!')
                print('Please try giving another name to the package...')
                print('')
                naming_package()
        else:
            print('An error occured with the name verification...')
            return 1

    if upgrade == False:
        if naming_package() == 1:
            return 1
    else:
        # NAME
        package_name = input("What's the name of your package? ")
        print('')

    # VERSION
    version = input("What's the version of " + package_name + '? ')
    print('')

    if upgrade == False:
        # DESCRIPTION
        print('Write a little summary/description of ' + package_name)
        desc = input('> ')
        print('')

        # EMAIL
        email = input('What is his ' + author + "'s email? ")
        print('')

        # LICENSE
        print('Warning: the license name is case-sensitive!')
        package_license = input('What is the license for ' + package_name +
                                ' ? ')
        package_license_classifier = 'License :: OSI Approved :: ' + package_license + ' License'
        print('')

        request = lifeeasy.request(
            'https://github.com/' + author + '/' + package_name, 'get')
        if request.status_code == 404:
            # GITHUB REPO
            print("What is the GitHub repository for this package?")
            url = input('> ')
            print('')
        else:
            url = 'https://github.com/' + author + '/' + package_name

        # ARCHIVE
        if url[-1] == '/':
            download_url_try = url + 'archive/' + version + '.tar.gz'
        else:
            download_url_try = url + '/archive/' + version + '.tar.gz'
        request = lifeeasy.request(method='get', url=download_url_try)
        if request.status_code == 200:
            download_url = download_url_try
        else:
            if url[-1] == '/':
                download_url_try = url + 'archive/v' + version + '.tar.gz'
            else:
                download_url_try = url + '/archive/v' + version + '.tar.gz'
            request = lifeeasy.request(method='get', url=download_url_try)
            if request.status_code == 200:
                download_url = download_url_try
            else:
                github_release = input(
                    "What is the name of the GitHub release? ")
                print('')
                if url[-1] == '/':
                    download_url_try = url + 'archive/' + github_release + '.tar.gz'
                else:
                    download_url_try = url + '/archive/' + github_release + '.tar.gz'
                request = lifeeasy.request(method='get', url=download_url_try)
                if request.status_code == 200:
                    download_url = download_url_try
                else:

                    def ask_for_github_release():
                        global download_url
                        print(
                            'What is the URL of your GitHub release? (it ends with .tar.gz)'
                        )
                        download_url_try = input('> ')
                        print('')
                        request = lifeeasy.request(method='get',
                                                   url=download_url_try)
                        if request.status_code == 200:
                            download_url = download_url_try
                        else:
                            print(
                                "It seems that you mistyped the URL or that the repository is private..."
                            )
                            lifeeasy.sleep(2)
                            print(
                                "Please put your GitHub repository visibility in public and retry..."
                            )
                            print('')
                            lifeeasy.sleep(2)
                            ask_for_github_release()

                    ask_for_github_release()

        # CUSTOM URL
        if customurl == True:
            print('What is the URL of the website for this package?')
            url = input('> ')
            print('')

        # KEYWORDS
        print('Enter a comma-separated list of keywords for your package')
        keywords = input('> ')
        keywords = keywords.split(',')
        print('')

        # DEPENDENCIES
        print('Enter a comma-separated list of dependencies for your package')
        dependencies = input('> ')
        dependencies = dependencies.replace(' ', '')
        dependencies = dependencies.split(',')
        print('')

        # PYTHON VERSIONS
        print(
            'Enter a comma-separated list of supported Python version numbers for this package'
        )
        print('(i.e 3,3.4,3.5,3.6,3.7,3.8)')
        python_versions = input('> ')
        print('')
        python_versions = python_versions.replace(' ', '')
        python_versions = python_versions.split(',')

        versions_classifiers = []
        for python_version in python_versions:
            versions_classifiers.append('Programming Language :: Python :: ' +
                                        python_version)

        dev_status = 'Development Status :: 4 - Beta'

        def development_status():
            global dev_status
            global customclassifiers_bool
            lifeeasy.clear()
            print('Choose a development status from the following')
            print('')
            print('Alpha')
            print('Beta')
            print('Stable')
            print('')
            print(
                'Or press [enter] to add a custom one when adding classifiers...'
            )
            print('')
            print('')
            dev_status_try = input('> ')

            if dev_status_try.lower() == 'alpha':
                dev_status = 'Development Status :: 3 - Alpha'
            elif dev_status_try.lower() == 'beta':
                dev_status = 'Development Status :: 4 - Beta'
            elif dev_status_try.lower() == 'stable':
                dev_status = 'Development Status :: 5 - Production/Stable'
            elif dev_status_try == '':
                customclassifiers_bool = True
            else:
                print("Sorry but I couldn't recognize the status.")
                lifeeasy.sleep(1)
                print('Please try again...')
                lifeeasy.sleep(1)
                development_status()

        development_status()

        # CUSTOM CLASSIFIERS
        custom_classifiers = []
        if customclassifiers_bool == True:
            lifeeasy.clear()
            print("What are the custom classifiers that you want to add?")
            print('')
            print("You need to enter your classifiers one-by-one")
            print("You need to write the full classifier")
            print(
                "When you are done press [enter] again without entering anything."
            )
            print('')
            print('')
            user_choice = input('> ')
            if user_choice != '':
                custom_classifiers.append(user_choice)
            while user_choice != '':
                lifeeasy.clear()
                print("What are the custom classifiers that you want to add?")
                print('')
                print("You need to enter your classifiers one-by-one")
                print("You need to write the full classifier")
                print(
                    "When you are done press [enter] again without entering anything."
                )
                print('')
                print('')
                user_choice = input('> ')
                if user_choice != '':
                    custom_classifiers.append(user_choice)

    else:
        package_infos = lifeeasy.request(
            'https://pypi.org/pypi/' + package_name + '/json', 'get')
        package_infos = json.loads(package_infos.text)
        package_license = package_infos['info']['license']
        desc = package_infos['info']['summary']
        author = package_infos['info']['author']
        email = package_infos['info']['author_email']
        url = package_infos['info']['home_page']

        def ask_for_github_release():
            global download_url
            print(
                'What is the URL of your GitHub release? (it ends with .tar.gz)'
            )
            download_url_try = input('> ')
            print('')
            if lifeeasy.request_statuscode(method='get',
                                           url=download_url_try) == 200:
                download_url = download_url_try
            else:
                print(
                    "It seems that you mistyped the URL or that the repository is private..."
                )
                lifeeasy.sleep(2)
                print(
                    "Please put your GitHub repository visibility in public and retry..."
                )
                print('')
                lifeeasy.sleep(2)
                ask_for_github_release()

        ask_for_github_release()
        download_url = package_infos['info']['download_url']
        keywords_string = package_infos['info']['keywords']
        keywords = keywords_string.split(',')
        dependencies = package_infos['info']['requires_dist']
        classifiers = package_infos['info']['classifiers']

    # CUSTOM SETUP

    if custom_setup == True:
        print('Add your custom setup sections (comma-separated)')
        setup_customized = input('> ')
        if len(setup_customized) == 0:
            custom_setup = False

    lifeeasy.clear()
    print('Building your setup file')
    lifeeasy.sleep(random.uniform(0.126, 0.31))

    print('adding imports')
    lifeeasy.sleep(random.uniform(0.126, 0.31))
    setup.append('from setuptools import setup')

    # README

    if filecenter.exists(lifeeasy.working_dir() + '/README.md'):
        print('adding the package readme')
        lifeeasy.sleep(random.uniform(0.126, 0.31))
        setup.append('from os import path')
        setup.append(
            "with open(path.join(path.abspath(path.dirname(__file__)), 'README.md'), encoding='utf-8') as f:"
        )
        setup.append("    readme_description = f.read()")

        long_description_type = 'text/markdown'

    elif filecenter.exists(lifeeasy.working_dir() + '/readme.md'):
        print('adding the package readme')
        lifeeasy.sleep(random.uniform(0.126, 0.31))
        setup.append('from os import path')
        setup.append('')
        setup.append(
            "with open(path.join(path.abspath(path.dirname(__file__)), 'readme.md'), encoding='utf-8') as f:"
        )
        setup.append("    readme_description = f.read()")
        setup.append('')
        setup.append('')

        long_description_type = 'text/markdown'

    else:
        long_description_type = ''

    # Need to add more readme type

    print('creating the setup class')
    lifeeasy.sleep(random.uniform(0.126, 0.31))
    setup.append('setup(')

    print('adding the package name')
    lifeeasy.sleep(random.uniform(0.126, 0.31))
    setup.append('name = "' + package_name + '",')

    print('adding the packages name')
    lifeeasy.sleep(random.uniform(0.126, 0.31))
    setup.append('packages = ["' + package_name + '"],')

    print('adding the package version')
    lifeeasy.sleep(random.uniform(0.126, 0.31))
    setup.append('version = "' + version + '",')

    print('adding the package license')
    lifeeasy.sleep(random.uniform(0.126, 0.31))
    setup.append('license = "' + package_license + '",')

    print('adding the package description')
    lifeeasy.sleep(random.uniform(0.126, 0.31))
    setup.append('description = "' + desc + '",')

    print('adding the package author')
    lifeeasy.sleep(random.uniform(0.126, 0.31))
    setup.append('author = "' + author + '",')

    print('adding the package email')
    lifeeasy.sleep(random.uniform(0.126, 0.31))
    setup.append('author_email = "' + email + '",')

    print('adding the package url')
    lifeeasy.sleep(random.uniform(0.126, 0.31))
    setup.append('url = "' + url + '",')

    print('adding the package download url')
    lifeeasy.sleep(random.uniform(0.126, 0.31))
    setup.append('download_url = "' + download_url + '",')

    print('adding the package keywords')
    lifeeasy.sleep(random.uniform(0.126, 0.31))
    setup.append('keywords = ' + str(keywords) + ',')

    print('adding the package dependencies')
    lifeeasy.sleep(random.uniform(0.126, 0.31))
    setup.append('install_requires = ' + str(dependencies) + ',')

    print('creating the package classifiers')
    lifeeasy.sleep(random.uniform(0.126, 0.31))
    if upgrade == False:
        classifiers = []
        classifiers.append(dev_status)
        classifiers.append(package_license_classifier)
        classifiers.extend(versions_classifiers)
        classifiers.extend(custom_classifiers)

    print('adding the package classifiers')
    lifeeasy.sleep(random.uniform(0.126, 0.31))
    setup.append('classifiers = ' + str(classifiers) + ',')

    print('adding the package readme')
    lifeeasy.sleep(random.uniform(0.126, 0.31))
    setup.append('long_description = readme_description,')

    print('adding the package readme type')
    lifeeasy.sleep(random.uniform(0.126, 0.31))
    setup.append('long_description_content_type = "' + long_description_type +
                 '",')

    setup.append('include_package_data=True,')

    if custom_setup == True:
        print('adding your custom setup sections')
        lifeeasy.sleep(random.uniform(0.126, 0.31))
        setup.append(setup_customized)

    print('finishing...')
    lifeeasy.sleep(random.uniform(0.126, 0.31))
    setup.append(')')

    print('creating the file...')
    lifeeasy.write_file('setup.py', setup)
    lifeeasy.sleep(random.uniform(1.5, 2.3))
    return 0