# Buggy code
def get_bookmarks(hide, start_page=1, end_page=0, member_id=None):
    """Get User's bookmarked artists"""
    total_list = list()
    i = start_page
    limit = 24
    offset = 0
    is_json = False

    while True:
        if end_page != 0 and i > end_page:
            print("Limit reached")
            break
        PixivHelper.print_and_log("info", f"Exporting page {i}")
        if member_id:
            is_json = True
            offset = 24 * (i - 1)
            url = f"https://www.pixiv.net/ajax/user/{member_id}/following?offset={offset}&limit={limit}"
        else:
            url = f"https://www.pixiv.net/bookmark.php?type=user&p={i}"
        if hide:
            url = url + "&rest=hide"
        else:
            url = url + "&rest=show"

        PixivHelper.print_and_log("info", f"Source URL: {url}")

        page = __br__.open_with_retry(url)
        page_str = page.read().decode("utf8")
        page.close()

        bookmarks = PixivBookmark.parseBookmark(
            page_str,
            root_directory=__config__.rootDirectory,
            db_path=__config__.dbPath,
            is_json=is_json,
        )

        if len(bookmarks) == 0:
            print("No more data")
            break
        total_list.extend(bookmarks)
        i = i + 1
        print(str(len(bookmarks)), "items")
        wait()
    return total_list


# 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 get_bookmarks(hide, start_page=1, end_page=0, member_id=None):
    """Get User's bookmarked artists"""
    total_list = list()
    i = start_page
    limit = 24
    offset = 0
    is_json = False

    while True:
        if end_page != 0 and i > end_page:
            print("Limit reached")
            break
        PixivHelper.print_and_log("info", f"Exporting page {i}")
        if member_id:
            is_json = True
            offset = limit * (i - 1)
            url = f"https://www.pixiv.net/ajax/user/{member_id}/following?offset={offset}&limit={limit}"
        else:
            url = f"https://www.pixiv.net/bookmark.php?type=user&p={i}"
        if hide:
            url = url + "&rest=hide"
        else:
            url = url + "&rest=show"

        PixivHelper.print_and_log("info", f"Source URL: {url}")

        page = __br__.open_with_retry(url)
        page_str = page.read().decode("utf8")
        page.close()

        bookmarks = PixivBookmark.parseBookmark(
            page_str,
            root_directory=__config__.rootDirectory,
            db_path=__config__.dbPath,
            is_json=is_json,
        )

        if len(bookmarks) == 0:
            print("No more data")
            break
        total_list.extend(bookmarks)
        i = i + 1
        print(str(len(bookmarks)), "items")
        wait()
    return total_list