feat(twitter_threads): gallery-dl media download + inline media embeds in Markdown

download_media now shells out to gallery-dl (handles X.com auth/403/video->mp4) instead of urllib, returns the downloaded files, + media_files_for_post glob helper + --cookies CLI. render_markdown embeds images with ![](...) and videos with an HTML <video controls> tag (were plain links). extract_corpus uses the package download_media (one download path). Tests rewritten for the gallery-dl API. Corpus: 4 threads, 33 media (32 img embeds + 1 video), 0 missing.
This commit is contained in:
ed
2026-07-05 19:08:43 -04:00
parent 3f5a2b0659
commit 2c680e23e4
6 changed files with 92 additions and 133 deletions
+3 -3
View File
@@ -77,9 +77,9 @@ def test_render_media_links(tmp_path: Path) -> None:
result = render_markdown(thread, media_names, out)
assert result.is_ok
text = out.read_text(encoding="utf-8")
assert "[Media 1](./media/123_img1.jpg)" in text
assert "[Media 2](./media/123_img2.jpg)" in text
assert "[Media 3](./media/123_vid1.mp4)" in text
assert "![Media 1](./media/123_img1.jpg)" in text
assert "![Media 2](./media/123_img2.jpg)" in text
assert '<video controls src="./media/123_vid1.mp4"></video>' in text
def test_render_view_count_null(tmp_path: Path) -> None: