Skip to content

Commit

Permalink
Fix keep-names filename discovery, including accounting for files wit…
Browse files Browse the repository at this point in the history
…h the same names or spoilered images
  • Loading branch information
DanielOaks committed Jun 23, 2014
1 parent c739c6f commit 62ca89a
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions Lib/Threads.py
Expand Up @@ -99,10 +99,24 @@ def run(self):
if _Globals.globals.keep_names:
images = {}

pairs = _re.findall(r"<a href=\"(//i\.4cdn\.org/\w+/\d+\.\w+)\".*?\>(.*?)\</a\>",
content)
pairs = _re.findall(r"<a (?:title=\"([^\"]*?)\" )?href=\"(//i\.4cdn\.org/\w+/\d+\.\w+).*?\>(.*?)\<\/a>", content)

image_names = []

for val1, key, val2 in pairs:
if val1:
value = val1

if val1 in image_names:
value = key.split('/')[-1] # no overlapping image names
elif val2:
value = val2

if val2 == 'Spoiler Image' or val2 in image_names:
value = key.split('/')[-1] # spoiler image or overlapping image name

image_names.append(value)

for key, value in pairs:
images[key] = value
else:
images = set(
Expand Down

0 comments on commit 62ca89a

Please sign in to comment.