]> git.phdru.name Git - bookmarks_db.git/blobdiff - Robots/parse_html.py
Do not use bookmarks.html from Firefox3 directory - use ~/.mozilla/ instead.
[bookmarks_db.git] / Robots / parse_html.py
index 47cbb190527d25c3a1bdb74bf0b694a0fe7df909..fd901a8857883a7bc1c5e02d764f76be7f411406 100755 (executable)
@@ -77,7 +77,7 @@ def parse_html(filename, charset=None, log=None):
          if log: log("Parser %s.%s failed, trying next one." % (p.__module__, p.__name__))
 
    converted_title = title = parser.title
-   if not parser.charset:
+   if title and (not parser.charset):
       try:
          unicode(title, "ascii")
       except UnicodeDecodeError:
@@ -86,7 +86,7 @@ def parse_html(filename, charset=None, log=None):
    if parser.charset:
       parser.charset = parser.charset.lower().replace("windows-", "cp")
 
-   if parser.charset and (
+   if title and parser.charset and (
          (parser.charset <> universal_charset) or
          ((not charset) or (charset <> parser.charset))):
       try:
@@ -109,11 +109,12 @@ def parse_html(filename, charset=None, log=None):
    else:
       if log: log("   title          : %s" % title)
 
-   final_title = recode_entities(converted_title, universal_charset)
-   parts = [s.strip() for s in final_title.replace('\r', '').split('\n')]
-   final_title = ' '.join([s for s in parts if s])
-   if log and (final_title <> converted_title): log("   final title    : %s" % final_title)
-   parser.title = final_title
+   if title:
+      final_title = recode_entities(converted_title, universal_charset)
+      parts = [s.strip() for s in final_title.replace('\r', '').split('\n')]
+      final_title = ' '.join([s for s in parts if s])
+      if log and (final_title <> converted_title): log("   final title    : %s" % final_title)
+      parser.title = final_title
    return parser