# Buggy code
def do_GET(self):
    """Process each GET request and return a value (image or file path)"""
    # Parse URL
    url_output = REGEX_THUMBNAIL_URL.match(self.path)
    if url_output and len(url_output.groups()) == 4:
        # Path is expected to have 3 matched components (third is optional though)
        #   /thumbnails/FILE-ID/FRAME-NUMBER/   or
        #   /thumbnails/FILE-ID/FRAME-NUMBER/path/  or
        #   /thumbnails/FILE-ID/FRAME-NUMBER/no-cache/  or
        #   /thumbnails/FILE-ID/FRAME-NUMBER/path/no-cache/
        self.send_response_only(200)
    else:
        self.send_error(404)
        return

    # Get URL parts
    file_id = url_output.group("file_id")
    file_frame = int(url_output.group("file_frame"))
    only_path = url_output.group("only_path")
    no_cache = url_output.group("no_cache")

    try:
        # Look up file data
        file = File.get(id=file_id)

        # Ensure file location is an absolute path
        file_path = file.absolute_path()
    except AttributeError:
        # Couldn't match file ID
        self.send_error(404)
        return

    # Send headers
    if not only_path:
        self.send_header("Content-type", "image/png")
    else:
        self.send_header("Content-type", "text/html; charset=utf-8")
    self.end_headers()

    # Locate thumbnail
    thumb_path = os.path.join(info.THUMBNAIL_PATH, file_id, "%s.png" % file_frame)
    if not os.path.exists(thumb_path) and file_frame == 1:
        # Try ID with no frame # (for backwards compatibility)
        thumb_path = os.path.join(info.THUMBNAIL_PATH, "%s.png" % file_id)
    if not os.path.exists(thumb_path) and file_frame != 1:
        # Try with ID and frame # in filename (for backwards compatibility)
        thumb_path = os.path.join(
            info.THUMBNAIL_PATH, "%s-%s.png" % (file_id, file_frame)
        )

    if not os.path.exists(thumb_path) or no_cache:
        # Generate thumbnail (since we can't find it)

        # Determine if video overlay should be applied to thumbnail
        overlay_path = ""
        if file.data["media_type"] == "video":
            overlay_path = os.path.join(info.IMAGES_PATH, "overlay.png")

        # Create thumbnail image
        GenerateThumbnail(
            file_path,
            thumb_path,
            file_frame,
            98,
            64,
            os.path.join(info.IMAGES_PATH, "mask.png"),
            overlay_path,
        )

    # Send message back to client
    if os.path.exists(thumb_path):
        if not only_path:
            self.wfile.write(open(thumb_path, "rb").read())
        else:
            self.wfile.write(bytes(thumb_path, "utf-8"))

    # Pause processing of request (since we don't currently use thread pooling, this allows
    # the threads to be processed without choking the CPU as much
    # TODO: Make HTTPServer work with a limited thread pool and remove this sleep() hack.
    time.sleep(0.01)


# Traceback (TypeError)
Loaded modules from: /home/chiller/Desktop/git-extern/openshot-qt/src
app:INFO ------------------------------------------------
app:INFO             Wed Aug 26 17:21:17 2020
app:INFO               Starting new session
app:INFO ------------------------------------------------
app:INFO          OpenShot (version 2.5.1-dev2)
app:INFO ------------------------------------------------
app:INFO openshot-qt version: 2.5.1-dev2
app:INFO libopenshot version: 0.2.5-dev2
app:INFO platform: Linux-4.19.0-10-amd64-x86_64-with-debian-10.5
app:INFO processor:
app:INFO machine: x86_64
app:INFO python version: 3.7.3
app:INFO qt5 version: 5.11.3
app:INFO pyqt5 version: 5.11.3
language:INFO Qt Detected Languages: ['en-US']
language:INFO LANG Environment Variable: en_US.UTF-8
language:INFO LOCALE Environment Variable:
language:INFO OpenShot Preference Language: Default
project_data:INFO Setting default profile to HD 720p 30 fps
app:INFO Setting font to /home/chiller/Desktop/git-extern/openshot-qt/src/images/fonts/Ubuntu-R.ttf
logger_libopenshot:INFO Connecting to libopenshot with debug port: 5556
app:INFO Setting custom dark theme
exceptions:ERROR Unhandled Exception
Traceback (most recent call last):
File "src/launch.py", line 143, in <module>
main()
File "src/launch.py", line 136, in main
app = OpenShotApp(argv)
File "/home/chiller/Desktop/git-extern/openshot-qt/src/classes/app.py", line 242, in __init__
from windows.main_window import MainWindow
File "/home/chiller/Desktop/git-extern/openshot-qt/src/windows/main_window.py", line 45, in <module>
from windows.views.timeline_webview import TimelineWebView
File "/home/chiller/Desktop/git-extern/openshot-qt/src/windows/views/timeline_webview.py", line 154, in <module>
class TimelineWebView(TimelineMixin, updates.UpdateInterface):
TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

# Fixed code
def do_GET(self):
    """Process each GET request and return a value (image or file path)"""
    mask_path = os.path.join(info.IMAGES_PATH, "mask.png")

    # Parse URL
    url_output = REGEX_THUMBNAIL_URL.match(self.path)
    if url_output and len(url_output.groups()) == 4:
        # Path is expected to have 3 matched components (third is optional though)
        #   /thumbnails/FILE-ID/FRAME-NUMBER/   or
        #   /thumbnails/FILE-ID/FRAME-NUMBER/path/  or
        #   /thumbnails/FILE-ID/FRAME-NUMBER/no-cache/  or
        #   /thumbnails/FILE-ID/FRAME-NUMBER/path/no-cache/
        self.send_response_only(200)
    else:
        self.send_error(404)
        return

    # Get URL parts
    file_id = url_output.group("file_id")
    file_frame = int(url_output.group("file_frame"))
    only_path = url_output.group("only_path")
    no_cache = url_output.group("no_cache")

    log.debug("Processing thumbnail request for %s frame %d", file_id, file_frame)

    try:
        # Look up file data
        file = File.get(id=file_id)

        # Ensure file location is an absolute path
        file_path = file.absolute_path()
    except AttributeError:
        # Couldn't match file ID
        log.debug("No ID match, returning 404")
        self.send_error(404)
        return

    # Send headers
    if not only_path:
        self.send_header("Content-type", "image/png")
    else:
        self.send_header("Content-type", "text/html; charset=utf-8")
    self.end_headers()

    # Locate thumbnail
    thumb_path = os.path.join(info.THUMBNAIL_PATH, file_id, "%s.png" % file_frame)
    if not os.path.exists(thumb_path) and file_frame == 1:
        # Try ID with no frame # (for backwards compatibility)
        thumb_path = os.path.join(info.THUMBNAIL_PATH, "%s.png" % file_id)
    if not os.path.exists(thumb_path) and file_frame != 1:
        # Try with ID and frame # in filename (for backwards compatibility)
        thumb_path = os.path.join(
            info.THUMBNAIL_PATH, "%s-%s.png" % (file_id, file_frame)
        )

    if not os.path.exists(thumb_path) or no_cache:
        # Generate thumbnail (since we can't find it)

        # Determine if video overlay should be applied to thumbnail
        overlay_path = ""
        if file.data["media_type"] == "video":
            overlay_path = os.path.join(info.IMAGES_PATH, "overlay.png")

        # Create thumbnail image
        GenerateThumbnail(
            file_path, thumb_path, file_frame, 98, 64, mask_path, overlay_path
        )

    # Send message back to client
    if os.path.exists(thumb_path):
        if not only_path:
            self.wfile.write(open(thumb_path, "rb").read())
        else:
            self.wfile.write(bytes(thumb_path, "utf-8"))

    # Pause processing of request (since we don't currently use thread pooling, this allows
    # the threads to be processed without choking the CPU as much
    # TODO: Make HTTPServer work with a limited thread pool and remove this sleep() hack.
    time.sleep(0.01)