Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect content type based on WARC-Resource-Type #306

Merged
merged 2 commits into from
Jun 13, 2024
Merged

Conversation

benoit74
Copy link
Collaborator

Fix #296

Nota: this PR is slightly enhanced compared to what has been proposed in the issue due to some stuff that has been realized during implementation

Changes:

  • use WARC-Resource-Type header when available inside the WARC to decide what kind of content / rewrite we have
    • fallback to mimetype-only decision will most probably continue to exist since the WARC-Resource-Type is not guaranteed to be present inside the WARC, for old WARC but also for WARC created with other tools then Browsertrix crawler
  • add a test case on the test website faking some content-type headers (warc2zim 2.0.0 is just failing on this test set)
  • add corresponding WARC to the test dataset for automated testing, at least ensuring we can convert the WARC
  • add temporary (to be removed once we are confident about the new logic) log when result from warc-resource-type + mimetype method is different from the mimetype-only method

@benoit74 benoit74 self-assigned this Jun 11, 2024
Copy link

codecov bot commented Jun 11, 2024

Codecov Report

Attention: Patch coverage is 76.00000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 84.01%. Comparing base (24aeafa) to head (92a456f).

Files Patch % Lines
src/warc2zim/content_rewriting/generic.py 76.00% 3 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #306      +/-   ##
==========================================
- Coverage   84.17%   84.01%   -0.17%     
==========================================
  Files          14       14              
  Lines        1245     1270      +25     
  Branches      240      249       +9     
==========================================
+ Hits         1048     1067      +19     
- Misses        152      155       +3     
- Partials       45       48       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@benoit74
Copy link
Collaborator Author

Issues around code coverage are not new. They are now properly tracked in #307 and #308.

@benoit74 benoit74 marked this pull request as ready for review June 11, 2024 14:16
@benoit74 benoit74 requested a review from rgaudin June 11, 2024 14:17
Copy link
Member

@rgaudin rgaudin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ; see minor suggestion inline

src/warc2zim/content_rewriting/generic.py Outdated Show resolved Hide resolved
src/warc2zim/content_rewriting/generic.py Show resolved Hide resolved
src/warc2zim/content_rewriting/generic.py Show resolved Hide resolved
@benoit74 benoit74 force-pushed the detect_content_type branch from a0be3c6 to 92a456f Compare June 13, 2024 06:24
@benoit74 benoit74 merged commit 8bae7be into main Jun 13, 2024
5 of 6 checks passed
@benoit74 benoit74 deleted the detect_content_type branch June 13, 2024 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use Warc-Resource-Type header to decide how to rewrite a WARC record
2 participants