_user_match_score. Internal helper function. This docstring was added automatically to improve maintainability. Args: q: Parameter. u: Parameter. Returns: Varies.
(q: str, u: str)
| 13633 | cur.execute( |
| 13634 | "INSERT INTO dm_files(dm_id, filename, mime, stored_path, size, created_at) VALUES(?,?,?,?,?,?)", |
| 13635 | (dm_id, "gif.gif", "image/gif", "PENDING", 0, now_z()) |
| 13636 | ) |
| 13637 | fid = cur.lastrowid |
| 13638 | stored_path = os.path.join(DM_FILES_DIR, f"dm_file_{fid}.bin") |
| 13639 | |
| 13640 | max_bytes = CHAT_MAX_BYTES # 33 MB |
| 13641 | size = 0 |
| 13642 | mime = "image/gif" |
| 13643 | filename = "gif.gif" |
| 13644 | |
| 13645 | req = urllib.request.Request( |
| 13646 | gif_url, |
| 13647 | headers={ |
| 13648 | "User-Agent": "ButSystem/1.0 (+https://example.invalid)", |
| 13649 | "Accept": "image/gif,image/*,video/*,*/*;q=0.8", |
| 13650 | }, |
| 13651 | method="GET", |
| 13652 | ) |
| 13653 | with _safe_urlopen(req, timeout=12) as resp: |
| 13654 | ctype = (resp.headers.get("Content-Type") or "").split(";")[0].strip().lower() |
| 13655 | if ctype: |
| 13656 | mime = ctype |
| 13657 | if not (mime == "image/gif" or mime.startswith("video/")): |
| 13658 | path = (u.path or "").lower() |