]> git.llucax.com Git - software/subdivxget.git/blobdiff - subdivxget
Ignore br tags for tag depth calculations
[software/subdivxget.git] / subdivxget
index bd6fc6ec6b6a427685b85c41b9c8ee92c309a792..d7c32d1f61047a2a8ea3c7703bb87a74bf0f3b4a 100755 (executable)
@@ -64,10 +64,11 @@ class SubDivXHTMLParser(HTMLParser.HTMLParser):
                                self.attr = 'desc'
                elif tag == 'a':
                        if attrs.get('class') == 'titulo_menu_izq':
                                self.attr = 'desc'
                elif tag == 'a':
                        if attrs.get('class') == 'titulo_menu_izq':
-                               self.attr = 'title'
+                               self.attr = 'titulo'
                        elif attrs.get('href', '').startswith(self.down_uri):
                                self.cur['url'] = attrs['href']
                        elif attrs.get('href', '').startswith(self.down_uri):
                                self.cur['url'] = attrs['href']
-               if self.parsing:
+               # br are usually not closed, so ignore them in depth calculation
+               if self.parsing and tag != 'br':
                        self.depth += 1
 
        def handle_endtag(self, tag):
                        self.depth += 1
 
        def handle_endtag(self, tag):
@@ -75,7 +76,9 @@ class SubDivXHTMLParser(HTMLParser.HTMLParser):
                        if tag == 'script' or tag == 'style':
                                self.in_script_style = False
                                return
                        if tag == 'script' or tag == 'style':
                                self.in_script_style = False
                                return
-                       self.depth -= 1
+                       # see comment in handle_starttag()
+                       if tag != 'br':
+                               self.depth -= 1
                if self.depth == 0:
                        self.parsing = False
 
                if self.depth == 0:
                        self.parsing = False
 
@@ -127,7 +130,7 @@ def get_subs(query_str):
 
        for sub in subdivx_get_subs(query_str):
                print '''\
 
        for sub in subdivx_get_subs(query_str):
                print '''\
-       - %(title)s (%(autor)s - %(fecha)s - %(downloads)s - %(comentarios)s)
+       - %(titulo)s (%(autor)s - %(fecha)s - %(downloads)s - %(comentarios)s)
          %(desc)s
                DOWNLOADING ...
        ''' % sub
          %(desc)s
                DOWNLOADING ...
        ''' % sub