Skip to content

Commit

Permalink
thumbnail: Name & lookup RE groups
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdnyc committed Nov 20, 2019
1 parent 1742d56 commit 8286345
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/classes/thumbnail.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from http.server import BaseHTTPRequestHandler, HTTPServer
from socketserver import ThreadingMixIn

REGEX_THUMBNAIL_URL = re.compile(r"/thumbnails/(.+?)/(\d+)(/path/)?")
REGEX_THUMBNAIL_URL = re.compile(r"/thumbnails/(?P<file_id>.+?)/(?P<file_frame>\d+)(?P<only_path>/path/)?")


def GenerateThumbnail(file_path, thumb_path, thumbnail_frame, width, height, mask, overlay):
Expand Down Expand Up @@ -107,8 +107,8 @@ def do_GET(self):

""" Process each GET request and return a value (image or file path)"""
# Parse URL
url_output = REGEX_THUMBNAIL_URL.findall(self.path)
if url_output and len(url_output[0]) == 3:
url_output = REGEX_THUMBNAIL_URL.match(self.path)
if url_output and len(url_output.groups()) == 3:
# Path is expected to have 3 matched components (third is optional though)
# /thumbnails/FILE-ID/FRAME-NUMBER/ or
# /thumbnails/FILE-ID/FRAME-NUMBER/path/
Expand All @@ -118,9 +118,9 @@ def do_GET(self):
return

# Get URL parts
file_id = url_output[0][0]
file_frame = int(url_output[0][1])
only_path = url_output[0][2]
file_id = url_output.group('file_id')
file_frame = int(url_output.group('file_frame'))
only_path = url_output.group('only_path')

# Catch undefined calls
if file_id == "undefined":
Expand Down

0 comments on commit 8286345

Please sign in to comment.