refactor(render): этап 5a — таблица медиа-типов (байт-в-байт) (#32)
Три параллельные ручно-синхронизируемые «лестницы» выбора media-объекта (_get_file_unique_id dict-map, _save_media_file_ids if/elif, _generate_html_media elif-каскад) сведены в одну точку правды: MEDIA_SOURCES (селектор → (media_obj, render_kind), 12 записей) + RenderCtx + RENDERERS (7 рендереров подняты дословно из старых веток). Все три консьюмера теперь ходят через таблицу; uid единообразно через getattr(file_unique_id). Байт-в-байт: fragment-oracle (media_fragment_replay + media_fragments.json, 24 кейса) без изменений, feed-golden без изменений. Единственная унификация — _save_media_file_ids теперь ключуется на message.media (как две другие лестницы), что заодно чинит латентную рассинхронизацию (в корпусе не встречается → оракул 0). test_stage5_media_table.py (48 тестов). Полный сюит 413 passed, PYTHONHASHSEED 1/42. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,218 @@
|
||||
{
|
||||
"animation": {
|
||||
"collected": [
|
||||
[
|
||||
"testchan",
|
||||
3,
|
||||
"ani_uid"
|
||||
]
|
||||
],
|
||||
"html": "<div class=\"message-media\">\n<video controls src=\"http://test.example.com/media/testchan/3/ani_uid/ef4319c9\" style=\"max-width:100%; width:auto;height:auto; max-height:400px;\"></video>\n</div>"
|
||||
},
|
||||
"audio_default_mime": {
|
||||
"collected": [
|
||||
[
|
||||
"testchan",
|
||||
5,
|
||||
"au_uid"
|
||||
]
|
||||
],
|
||||
"html": "<div class=\"message-media\">\n<audio controls style=\"width:100%; max-width:400px;\"><source src=\"http://test.example.com/media/testchan/5/au_uid/be14c993\" type=\"audio/mpeg\"></audio>\n<br>\n</div>"
|
||||
},
|
||||
"audio_explicit_mime": {
|
||||
"collected": [
|
||||
[
|
||||
"testchan",
|
||||
6,
|
||||
"au2_uid"
|
||||
]
|
||||
],
|
||||
"html": "<div class=\"message-media\">\n<audio controls style=\"width:100%; max-width:400px;\"><source src=\"http://test.example.com/media/testchan/6/au2_uid/015e2737\" type=\"audio/flac\"></audio>\n<br>\n</div>"
|
||||
},
|
||||
"channel_username_none": {
|
||||
"collected": [],
|
||||
"html": "<div class=\"message-media\">\n</div>"
|
||||
},
|
||||
"document_normal": {
|
||||
"collected": [
|
||||
[
|
||||
"testchan",
|
||||
13,
|
||||
"doc_uid"
|
||||
]
|
||||
],
|
||||
"html": "<div class=\"message-media\">\n<img src=\"http://test.example.com/media/testchan/13/doc_uid/4c9075c7\" style=\"max-width:100%; width:auto; height:auto;max-height:400px; object-fit:contain;\">\n</div>"
|
||||
},
|
||||
"document_pdf_private": {
|
||||
"collected": [
|
||||
[
|
||||
"-1009876543210",
|
||||
12,
|
||||
"pdf2_uid"
|
||||
]
|
||||
],
|
||||
"html": "<div class=\"message-media\">\n<div class=\"document-pdf\" style=\"padding: 10px;\">\n<a href=\"https://t.me/c/9876543210/12\" target=\"_blank\">[PDF-файл]</a></div>\n</div>"
|
||||
},
|
||||
"document_pdf_public": {
|
||||
"collected": [
|
||||
[
|
||||
"pubchan",
|
||||
11,
|
||||
"pdf_uid"
|
||||
]
|
||||
],
|
||||
"html": "<div class=\"message-media\">\n<div class=\"document-pdf\" style=\"padding: 10px;\">\n<a href=\"https://t.me/pubchan/11\" target=\"_blank\">[PDF-файл]</a></div>\n</div>"
|
||||
},
|
||||
"file_unique_id_none": {
|
||||
"collected": [],
|
||||
"html": "<div class=\"message-media\">"
|
||||
},
|
||||
"live_photo": {
|
||||
"collected": [
|
||||
[
|
||||
"testchan",
|
||||
14,
|
||||
"lp_uid"
|
||||
]
|
||||
],
|
||||
"html": "<div class=\"message-media\">\n<video controls autoplay loop muted src=\"http://test.example.com/media/testchan/14/lp_uid/7cbfcf53\"style=\"max-width:100%; width:auto; height:auto; max-height:400px;object-fit:contain;\"></video>\n</div>"
|
||||
},
|
||||
"paid_media": {
|
||||
"collected": [],
|
||||
"html": "<div class=\"message-media\">\n<div class=\"paid-media\">⭐ Paid media (50 stars, 2 item(s)) — available in Telegram</div>\n</div>"
|
||||
},
|
||||
"photo": {
|
||||
"collected": [
|
||||
[
|
||||
"testchan",
|
||||
1,
|
||||
"ph_uid"
|
||||
]
|
||||
],
|
||||
"html": "<div class=\"message-media\">\n<img src=\"http://test.example.com/media/testchan/1/ph_uid/08e6b2ef\" style=\"max-width:100%; width:auto; height:auto;max-height:400px; object-fit:contain;\">\n</div>"
|
||||
},
|
||||
"poll_media_img": {
|
||||
"collected": [
|
||||
[
|
||||
"testchan",
|
||||
17,
|
||||
"pl_uid"
|
||||
]
|
||||
],
|
||||
"html": "<div class=\"message-media\">\n<img src=\"http://test.example.com/media/testchan/17/pl_uid/492d238c\" style=\"max-width:100%; width:auto; height:auto;max-height:400px; object-fit:contain;\">\n</div>"
|
||||
},
|
||||
"poll_media_video": {
|
||||
"collected": [
|
||||
[
|
||||
"testchan",
|
||||
18,
|
||||
"plv_uid"
|
||||
]
|
||||
],
|
||||
"html": "<div class=\"message-media\">\n<video controls src=\"http://test.example.com/media/testchan/18/plv_uid/abb609a3\" style=\"max-width:100%; width:auto;height:auto; max-height:400px;\"></video>\n</div>"
|
||||
},
|
||||
"sticker_img": {
|
||||
"collected": [
|
||||
[
|
||||
"testchan",
|
||||
9,
|
||||
"st_uid"
|
||||
]
|
||||
],
|
||||
"html": "<div class=\"message-media\">\n<img src=\"http://test.example.com/media/testchan/9/st_uid/03dc35d2\" alt=\"Sticker 😀\" style=\"max-width:100%;width:auto; height:auto; max-height:200px; object-fit:contain;\">\n</div>"
|
||||
},
|
||||
"sticker_video": {
|
||||
"collected": [
|
||||
[
|
||||
"testchan",
|
||||
10,
|
||||
"stv_uid"
|
||||
]
|
||||
],
|
||||
"html": "<div class=\"message-media\">\n<video controls autoplay loop muted src=\"http://test.example.com/media/testchan/10/stv_uid/cedd7494\"style=\"max-width:100%; width:auto; height:auto; max-height:200px;object-fit:contain;\"></video>\n</div>"
|
||||
},
|
||||
"story_photo": {
|
||||
"collected": [
|
||||
[
|
||||
"testchan",
|
||||
16,
|
||||
"sp_uid"
|
||||
]
|
||||
],
|
||||
"html": "<div class=\"message-media\">\n<img src=\"http://test.example.com/media/testchan/16/sp_uid/d8a5d9c9\" style=\"max-width:100%; width:auto; height:auto;max-height:400px; object-fit:contain;\">\n</div>"
|
||||
},
|
||||
"story_video": {
|
||||
"collected": [
|
||||
[
|
||||
"testchan",
|
||||
15,
|
||||
"sv_uid"
|
||||
]
|
||||
],
|
||||
"html": "<div class=\"message-media\">\n<video controls src=\"http://test.example.com/media/testchan/15/sv_uid/1aba6362\" style=\"max-width:100%; width:auto;height:auto; max-height:400px;\"></video>\n</div>"
|
||||
},
|
||||
"video": {
|
||||
"collected": [
|
||||
[
|
||||
"testchan",
|
||||
2,
|
||||
"vid_uid"
|
||||
]
|
||||
],
|
||||
"html": "<div class=\"message-media\">\n<video controls src=\"http://test.example.com/media/testchan/2/vid_uid/e0c6ba2e\" style=\"max-width:100%; width:auto;height:auto; max-height:400px;\"></video>\n</div>"
|
||||
},
|
||||
"video_note": {
|
||||
"collected": [
|
||||
[
|
||||
"testchan",
|
||||
4,
|
||||
"vn_uid"
|
||||
]
|
||||
],
|
||||
"html": "<div class=\"message-media\">\n<video controls src=\"http://test.example.com/media/testchan/4/vn_uid/a5ee9944\" style=\"max-width:100%; width:auto;height:auto; max-height:400px;\"></video>\n</div>"
|
||||
},
|
||||
"voice_default_mime": {
|
||||
"collected": [
|
||||
[
|
||||
"testchan",
|
||||
7,
|
||||
"vo_uid"
|
||||
]
|
||||
],
|
||||
"html": "<div class=\"message-media\">\n<audio controls style=\"width:100%; max-width:400px;\"><source src=\"http://test.example.com/media/testchan/7/vo_uid/f16627e0\" type=\"audio/ogg\"></audio>\n<br>\n</div>"
|
||||
},
|
||||
"voice_explicit_mime": {
|
||||
"collected": [
|
||||
[
|
||||
"testchan",
|
||||
8,
|
||||
"vo2_uid"
|
||||
]
|
||||
],
|
||||
"html": "<div class=\"message-media\">\n<audio controls style=\"width:100%; max-width:400px;\"><source src=\"http://test.example.com/media/testchan/8/vo2_uid/30fed86a\" type=\"audio/wav\"></audio>\n<br>\n</div>"
|
||||
},
|
||||
"webpage_photo_long_text": {
|
||||
"collected": [
|
||||
[
|
||||
"testchan",
|
||||
22,
|
||||
"wpl_uid"
|
||||
]
|
||||
],
|
||||
"html": "<div class=\"message-media\">\n</div>"
|
||||
},
|
||||
"webpage_with_photo": {
|
||||
"collected": [
|
||||
[
|
||||
"testchan",
|
||||
20,
|
||||
"wp_uid"
|
||||
]
|
||||
],
|
||||
"html": "<div class=\"message-media\">\n</div>\n<div class=\"webpage-preview\">\n<div class=\"webpage-preview\" style=\"border-left: 3px solid #ccc; padding-left: 10px; margin: 10px 0;\">\n<div class=\"webpage-title\" style=\"font-weight:bold; margin:5px 0;\">\n<a href=\"https://example.com\" target=\"_blank\">Example</a></div>\n<div class=\"webpage-url\" style=\"color:#666; font-size:0.9em;margin-bottom:5px;\">https://example.com</div>\n<div class=\"webpage-photo\" style=\"margin-top:10px;\">\n<a href=\"https://example.com\" target=\"_blank\">\n<img src=\"http://test.example.com/media/testchan/20/wp_uid/a3dc7111\" style=\"max-width:100%; width:auto;height:auto; max-height:200px; object-fit:contain;\"></a></div>\n</div>\n</div>"
|
||||
},
|
||||
"webpage_without_photo": {
|
||||
"collected": [],
|
||||
"html": "<div class=\"message-media\">\n<div class=\"webpage-preview\">\n<div class=\"webpage-preview\" style=\"border-left: 3px solid #ccc; padding-left: 10px; margin: 10px 0;\">\n<div class=\"webpage-title\" style=\"font-weight:bold; margin:5px 0;\">\n<a href=\"https://example.com\" target=\"_blank\">Example</a></div>\n<div class=\"webpage-url\" style=\"color:#666; font-size:0.9em;margin-bottom:5px;\">https://example.com</div>\n</div>\n</div>"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user