8000 Allows iframes containing youtube or vimeo videos. People like them · tanqhnguyen/python-readability@f1759c1 · GitHub
[go: up one dir, main page]

Skip to content

Commit f1759c1

Browse files
Miguel Galvesburiy
authored andcommitted
Allows iframes containing youtube or vimeo videos. People like them
1 parent 332ad81 commit f1759c1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

readability/readability.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#'trimRe': re.compile('^\s+|\s+$/'),
3333
#'normalizeRe': re.compile('\s{2,}/'),
3434
#'killBreaksRe': re.compile('(<br\s*\/?>(\s|&nbsp;?)*){1,}/'),
35-
#'videoRe': re.compile('http:\/\/(www\.)?(youtube|vimeo)\.com', re.I),
35+
'videoRe': re.compile('http:\/\/(www\.)?(youtube|vimeo)\.com', re.I),
3636
#skipFootnoteLink: /^\s*(\[?[a-z0-9]{1,2}\]?|^|edit|citation needed)\s*$/i,
3737
}
3838

@@ -428,8 +428,13 @@ def sanitize(self, node, candidates):
428428
if self.class_weight(header) < 0 or self.get_link_density(header) > 0.33:
429429
header.drop_tree()
430430

431-
for elem in self.tags(node, "form", "iframe", "textarea"):
431+
for elem in self.tags(node, "form", "textarea"):
432432
elem.drop_tree()
433+
434+
for elem in self.tags(node, "iframe"):
435+
if not ("src" in elem.attrib and REGEXES["videoRe"].search(elem.attrib["src"])):
436+
elem.drop_tree()
437+
433438
allowed = {}
434439
# Conditionally clean <table>s, <ul>s, and <div>s
435440
for el in self.reverse_tags(node, "table", "ul", "div"):

0 commit comments

Comments
 (0)
0