So long lxml, and thanks for all the fish #329
Merged
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.
There was a lot of confusion over HTML and XML parsing:
_unescapeHTML
did the same thing ashtmlentity_transform
but using the undocumentedHTMLParser.unescape
_unescapeHTML
was used, sometimes the complex to read syntax ofhtmlentity_transform
was used insteadlxml
(non public domain, MIT licensed) only to do what in Javascript is getElementByIdSo here are my changes:
get_element_by_id
that uses a customHTMLParser
to extract the HTML tag with a specific id, so lxml is gone_unescapeHTML
now useshtmlentity_transform
and I applied (and tested) it across the codeclean_html
does the tag-stripping and newline-handling needed to get a pretty text out of a bunch of HTMLHave a look at
./youtube-dl --get-description http://www.youtube.com/watch?v=BQ80NtYmktQ
Before (without lxml):
Before (with lxml):
Now: