feat: support document/archive extensions in MEDIA: tag extraction#8255
Open
huangke19 wants to merge 1 commit intoNousResearch:mainfrom
Open
feat: support document/archive extensions in MEDIA: tag extraction#8255huangke19 wants to merge 1 commit intoNousResearch:mainfrom
huangke19 wants to merge 1 commit intoNousResearch:mainfrom
Conversation
Add epub, pdf, zip, rar, 7z, docx, xlsx, pptx, txt, csv, apk, ipa to the MEDIA: path regex in extract_media(). These file types were already routed to send_document() in the delivery loop (base.py:1705), but the extraction regex only matched media extensions (audio/video/image), causing document paths to fall through to the generic \S+ branch which could fail silently in some cases. This explicit list ensures reliable matching and delivery for all common document formats.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
extract_media()regex ingateway/platforms/base.pyonly matched audio/video/image extensions (png|jpe?g|gif|webp|mp4|...|m4a). Document formats like.epub,.pdf,.zipetc. were not explicitly matched, causingMEDIA:/path/to/file.epubto fall through to the generic\S+branch which can fail silently depending on the path format.The send routing (line 1705) already has an
elsebranch that callssend_document()for non-audio/video/image files — so the infrastructure was there, just the extraction regex was too narrow.Fix
Add common document and archive extensions to the extraction regex:
epub|pdf|zip|rar|7z|docx?|xlsx?|pptx?|txt|csv|apk|ipaTesting
Verified the updated regex compiles and correctly matches:
MEDIA:/path/to/book.epub✓MEDIA:/tmp/report.pdf✓