# Buggy code
def menu_download_from_online_image_bookmark(opisvalid, args):
    __log__.info("User's Image Bookmark mode.")
    start_page = 1
    end_page = 0
    hide = "n"
    tag = ""
    sorting = "desc"

    if opisvalid and len(args) > 0:
        hide = args[0].lower()
        if hide not in ("y", "n", "o"):
            print("Invalid args: ", args)
            return
        (start_page, end_page) = get_start_and_end_number_from_args(args, offset=1)
        if len(args) > 3:
            tag = args[3]
        if len(args) > 4:
            sorting = args[4].lower()
            if sorting not in ("asc", "desc", "date", "date_d"):
                print("Invalid sorting order: ", sorting)
                return
    else:
        hide = input("Include Private bookmarks [y/n/o]: ").rstrip("\r") or "n"
        hide = hide.lower()
        if hide not in ("y", "n", "o"):
            print("Invalid args: ", hide)
            return
        tag = input("Tag (default=All Images): ").rstrip("\r") or ""
        (start_page, end_page) = get_start_and_end_number()
        sorting = input("Sort Order [asc/desc/date/date_d]: ").rstrip("\r") or "desc"
        sorting = sorting.lower()
        if sorting not in ("asc", "desc", "date", "date_d"):
            print("Invalid sorting order: ", sorting)
            return

    process_image_bookmark(hide, start_page, end_page, tag, sorting)


# Traceback (ZeroDivisionError)
Input: 5
Include Private bookmarks [y/n/o]:
Start Page (default=1):
End Page (default=0, 0 for no limit):
Importing Bookmarks...
Exporting page 1
Source URL: https://www.pixiv.net/bookmark.php?type=user&amp;p=1
Using default DB Path: /mnt/c/PixivUtil2/db.sqlite
No more data
Result:  0 items.
Error at process_bookmark(): (<class 'ZeroDivisionError'>, ZeroDivisionError('float division by zero'), <traceback object at 0x7fa7885a55a0>)
Traceback (most recent call last):
File "PixivUtil2.py", line 2407, in main
np_is_valid, op_is_valid, selection = main_loop(ewd, op_is_valid, selection, np_is_valid, args)
File "PixivUtil2.py", line 2127, in main_loop
menu_download_from_online_user_bookmark(op_is_valid, args)
File "PixivUtil2.py", line 1722, in menu_download_from_online_user_bookmark
process_bookmark(hide, start_page, end_page)
File "PixivUtil2.py", line 1235, in process_bookmark
print("%d/%d\t%f %%" % (i, len(total_list), 100.0 * i / float(len(total_list))))
ZeroDivisionError: float division by zero
press enter to exit.

# Fixed code
def menu_download_from_online_image_bookmark(opisvalid, args):
    __log__.info("User's Image Bookmark mode.")
    start_page = 1
    end_page = 0
    hide = "n"
    tag = ""
    sorting = "desc"

    if opisvalid and len(args) > 0:
        hide = args[0].lower()
        if hide not in ("y", "n", "o"):
            print("Invalid args: ", args)
            return
        (start_page, end_page) = get_start_and_end_number_from_args(args, offset=1)
        if len(args) > 3:
            tag = args[3]
        if len(args) > 4:
            sorting = args[4].lower()
            if sorting not in ("asc", "desc", "date", "date_d"):
                print("Invalid sorting order: ", sorting)
                return
    else:
        hide = input("Include Private bookmarks [y/n/o]: ").rstrip("\r") or "n"
        hide = hide.lower()
        if hide not in ("y", "n", "o"):
            print("Invalid args: ", hide)
            return
        tag = input("Tag (default=All Images): ").rstrip("\r") or ""
        (start_page, end_page) = get_start_and_end_number()
        # sorting = input("Sort Order [asc/desc/date/date_d]: ").rstrip("\r") or 'desc'
        # sorting = sorting.lower()
        # if sorting not in ('asc', 'desc', 'date', 'date_d'):
        #     print("Invalid sorting order: ", sorting)
        #     return

    process_image_bookmark(hide, start_page, end_page, tag, sorting)