fix: Catch correct exceptions to extract original image link
This commit is contained in:
parent
ac024989a6
commit
601b42acdc
1 changed files with 2 additions and 1 deletions
|
|
@ -18,12 +18,13 @@ class Original: # BadJoke: Sting
|
|||
m = re.match(r'<img src="(?P<img>.+?)"', s)
|
||||
try:
|
||||
img = m.group("img")
|
||||
except (IndexError, NameError):
|
||||
except (IndexError, AttributeError):
|
||||
return ("", s)
|
||||
|
||||
if img:
|
||||
rest = re.sub(r"<img src=.+?>", "", s)
|
||||
return (img, rest)
|
||||
return ("", s)
|
||||
|
||||
def __post_init__(self):
|
||||
self.id = hashlib.sha256(self.link.encode()).hexdigest()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue