Skip to content

Commit 8286345

Browse files
committed
thumbnail: Name & lookup RE groups
1 parent 1742d56 commit 8286345

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/classes/thumbnail.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
from http.server import BaseHTTPRequestHandler, HTTPServer
3737
from socketserver import ThreadingMixIn
3838

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

4141

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

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

120120
# Get URL parts
121-
file_id = url_output[0][0]
122-
file_frame = int(url_output[0][1])
123-
only_path = url_output[0][2]
121+
file_id = url_output.group('file_id')
122+
file_frame = int(url_output.group('file_frame'))
123+
only_path = url_output.group('only_path')
124124

125125
# Catch undefined calls
126126
if file_id == "undefined":

0 commit comments

Comments
 (0)