Skip to content

Commit e22a27a

Browse files
committed
fix src='' not being supported
1 parent e4b02bc commit e22a27a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/migaku_connection/srs_util.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
from ..languages import Languages
2020
from ..util import tmp_path
2121

22-
IMG_RE = re.compile(r"<img (.*?)src=\"(.*?)\"(.*?)>", re.IGNORECASE)
22+
# supports both src="" and src=''
23+
IMG_RE = re.compile(r"<img (.*?)src=(?:\"|')(.*?)(?:\"|')(.*?)>", re.IGNORECASE)
2324
SOUND_RE = re.compile(r"\[sound:(.*?)\]")
2425

2526

@@ -458,7 +459,6 @@ async def handle_card(
458459
# no usable mapping found
459460
if not dst_id:
460461
print(f"skipped {card.id}: no mapping for {src_id}")
461-
print(mappings)
462462
return None
463463

464464
# get the correct card type
@@ -513,6 +513,7 @@ async def handle_card(
513513
gather_media.add((src, False))
514514
if hashes:
515515
data[i] = "|".join(hashes)
516+
516517
elif field["type"].startswith("AUDIO"):
517518
hashes = []
518519
srcs = SOUND_RE.findall(data[i]) + recovered_audio_src
@@ -531,6 +532,7 @@ async def handle_card(
531532
gather_media.add((src, True))
532533
if hashes:
533534
data[i] = "|".join(hashes)
535+
534536
elif field["type"] == "SYNTAX":
535537
if data[i].strip() and not "[" in data[i]:
536538
if gather_syntax is None:
@@ -552,6 +554,7 @@ async def handle_card(
552554
if (not gather_syntax is None) or (not gather_media is None):
553555
return None
554556

557+
555558
card_data = {
556559
"deckId": 0, # set by core
557560
"typeId": dst_id,

0 commit comments

Comments
 (0)