fix: support spaced emoji media attributes
This commit is contained in:
@@ -36,7 +36,11 @@ def _is_usable_local_media_path(value: str) -> bool:
|
||||
def _extract_emoji_preview_url(xml_text: str) -> str:
|
||||
if not xml_text:
|
||||
return ''
|
||||
patterns = (r'cdnurl="([^"]+)"', r'encrypturl="([^"]+)"', r'externurl="([^"]+)"')
|
||||
patterns = (
|
||||
r'cdnurl\s*=\s*"([^"]+)"',
|
||||
r'encrypturl\s*=\s*"([^"]+)"',
|
||||
r'externurl\s*=\s*"([^"]+)"'
|
||||
)
|
||||
for pattern in patterns:
|
||||
match = re.search(pattern, xml_text)
|
||||
if match:
|
||||
|
||||
BIN
static/images/_shared/667ab3a58baabb224db3b19239d02c51.gif
Normal file
BIN
static/images/_shared/667ab3a58baabb224db3b19239d02c51.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.7 MiB |
BIN
static/images/_shared/7098af5cbd9432e808e6920042d2b4aa.gif
Normal file
BIN
static/images/_shared/7098af5cbd9432e808e6920042d2b4aa.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 842 KiB |
BIN
static/images/_shared/cdfc9e8af856987b339e6e549ad3ce14.jpg
Normal file
BIN
static/images/_shared/cdfc9e8af856987b339e6e549ad3ce14.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
BIN
temp/test_emoji_extract.png
Normal file
BIN
temp/test_emoji_extract.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
@@ -60,14 +60,15 @@ class MessageStorage:
|
||||
self._image_loop = asyncio.new_event_loop()
|
||||
|
||||
# 正则(替代 XML 解析)
|
||||
self._aeskey_re = re.compile(r'aeskey="(.*?)"')
|
||||
self._cdn_re = re.compile(r'cdnthumburl="(.*?)"')
|
||||
self._cdn_mid_re = re.compile(r'cdnmidimgurl="(.*?)"')
|
||||
self._cdn_big_re = re.compile(r'cdnbigimgurl="(.*?)"')
|
||||
self._emoji_cdn_re = re.compile(r'cdnurl="(.*?)"')
|
||||
self._emoji_encrypt_re = re.compile(r'encrypturl="(.*?)"')
|
||||
self._emoji_extern_re = re.compile(r'externurl="(.*?)"')
|
||||
self._md5_re = re.compile(r'md5="(.*?)"')
|
||||
attr = r'\s*=\s*["\'](.*?)["\']'
|
||||
self._aeskey_re = re.compile(rf'aeskey{attr}')
|
||||
self._cdn_re = re.compile(rf'cdnthumburl{attr}')
|
||||
self._cdn_mid_re = re.compile(rf'cdnmidimgurl{attr}')
|
||||
self._cdn_big_re = re.compile(rf'cdnbigimgurl{attr}')
|
||||
self._emoji_cdn_re = re.compile(rf'cdnurl{attr}')
|
||||
self._emoji_encrypt_re = re.compile(rf'encrypturl{attr}')
|
||||
self._emoji_extern_re = re.compile(rf'externurl{attr}')
|
||||
self._md5_re = re.compile(rf'md5{attr}')
|
||||
|
||||
# 修改为项目根目录下的 static/images
|
||||
self.image_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "static", "images")
|
||||
|
||||
Reference in New Issue
Block a user