]> git.phdru.name Git - bookmarks_db.git/blobdiff - parse_html/bkmk_ph_beautifulsoup4.py
Fix(parse_html/bkmk_ph_beautifulsoup4): Find "shortcut icon"
[bookmarks_db.git] / parse_html / bkmk_ph_beautifulsoup4.py
index faafca22eb3ee276b70eddf161c4ae8f30a5327f..060f0786d473c17de36ad073c05632c06f30c35d 100644 (file)
@@ -69,9 +69,12 @@ def parse_html(html_text, charset=None, log=None):
         else:
             parts = []
             for part in title:
-                if not isinstance(part, string_type):
-                    part = part.decode()
-                parts.append(part.strip())
+                #if not isinstance(part, string_type):
+                #    part = part.decode()
+                if part.strip:
+                    parts.append(part.strip())
+                else:
+                    parts.append(' ')  # Skip tags, they're usually `<br>`
             title = ''.join(parts)
 
     meta = head.find(_find_contenttype, recursive=False)
@@ -136,6 +139,7 @@ def _find_refresh(Tag):
 
 
 def _find_icon(Tag):
-    return (Tag.name == "link") and \
-       (Tag.get_attribute_list("rel", '')[0].lower()
-        in ('icon', 'shortcut icon'))
+    if Tag.name != "link":
+        return False
+    rel = ' '.join(Tag.get_attribute_list("rel", ''))
+    return rel in ('icon', 'shortcut icon')