]> git.phdru.name Git - bookmarks_db.git/blobdiff - parse_html/bkmk_ph_html5.py
Add a few TODO items
[bookmarks_db.git] / parse_html / bkmk_ph_html5.py
index 0e86477e0bc4e749620e5dd5860c7fcb67042302..53109be72fd761f874a92723f0eb4d606c47b11f 100644 (file)
@@ -4,7 +4,7 @@ This file is a part of Bookmarks database and Internet robot.
 """
 
 __author__ = "Oleg Broytman <phd@phdru.name>"
-__copyright__ = "Copyright (C) 2010-2012 PhiloSoft Design"
+__copyright__ = "Copyright (C) 2010-2013 PhiloSoft Design"
 __license__ = "GNU GPL"
 
 __all__ = ['parse_html']
@@ -52,11 +52,8 @@ def parse_html(filename, charset=None, log=None):
                 else:
                     title = ''
 
-        if title is None:
-            return None
-
         for node in head.childNodes:
-            if node.name == 'meta' and \
+            if (node.name == 'meta') and \
                     ('http-equiv' in node.attributes) and \
                     (node.attributes['http-equiv'] == 'content-type'):
                 meta_content = node.attributes['content']
@@ -68,11 +65,14 @@ def parse_html(filename, charset=None, log=None):
                         meta_charset = False
                     else:
                         break
+            elif (node.name == 'meta') and ('charset' in node.attributes):
+                meta_charset = node.attributes['charset'].lower()
+                break
 
         if not charset:
             charset = parser.tokenizer.stream.charEncoding[0]
 
-        if charset or meta_charset:
+        if title and (charset or meta_charset):
             title = title.encode(charset or meta_charset)
 
         for node in head.childNodes:
@@ -98,7 +98,6 @@ def parse_html(filename, charset=None, log=None):
                 else:
                     title = ''
 
-        if title is None:
-            return None
-
+    if (title is None) and (refresh is None) and (icon is None):
+        return None
     return HTMLParser(charset, meta_charset, title, refresh, icon)