]> git.bitcoin.ninja Git - youtube-dl/commitdiff
some HTMLParser bugfixes
authorFilippo Valsorda <filippo.valsorda@gmail.com>
Fri, 13 Apr 2012 20:09:24 +0000 (22:09 +0200)
committerFilippo Valsorda <filippo.valsorda@gmail.com>
Fri, 13 Apr 2012 20:09:24 +0000 (22:09 +0200)
youtube-dl
youtube-dl.exe
youtube_dl/InfoExtractors.py
youtube_dl/utils.py

index c4b5c07ca3c52ac0a49409335655634f98979f45..e4d7beb2d646956663885df16cc73c8bd641de5e 100755 (executable)
Binary files a/youtube-dl and b/youtube-dl differ
index cb965428327cb0f5bd686629d9dd32326a3efe00..287b78af52b7dafff7355e890f5d019d1e2d688d 100755 (executable)
Binary files a/youtube-dl.exe and b/youtube-dl.exe differ
index d77154dcb4902422f9297c6b0d0fbf90168f5975..ae98e12642974435058f973d9e546db0c1cbcfba 100644 (file)
@@ -359,8 +359,8 @@ class YoutubeIE(InfoExtractor):
                                        pass
 
                # description
-               video_description = get_element_by_id("eow-description", video_webpage)
-               if video_description: video_description = clean_html(video_description.decode('utf8'))
+               video_description = get_element_by_id("eow-description", video_webpage.decode('utf8'))
+               if video_description: video_description = clean_html(video_description)
                else: video_description = ''
                        
                # closed captions
@@ -1055,8 +1055,8 @@ class VimeoIE(InfoExtractor):
                video_thumbnail = config["video"]["thumbnail"]
 
                # Extract video description
-               video_description = get_element_by_id("description", webpage)
-               if video_description: video_description = clean_html(video_description.decode('utf8'))
+               video_description = get_element_by_id("description", webpage.decode('utf8'))
+               if video_description: video_description = clean_html(video_description)
                else: video_description = ''
 
                # Extract upload date
index a19656000d738530cfaa6d13450442385332a202..0f903c64a0d8c71517378143ecad1caf07cb5893 100644 (file)
@@ -73,7 +73,7 @@ def htmlentity_transform(matchobj):
        # Unknown entity in name, return its literal representation
        return (u'&%s;' % entity)
 
-
+HTMLParser.locatestarttagend = re.compile(r"""<[a-zA-Z][-.a-zA-Z0-9:_]*(?:\s+(?:(?<=['"\s])[^\s/>][^\s/=>]*(?:\s*=+\s*(?:'[^']*'|"[^"]*"|(?!['"])[^>\s]*))?\s*)*)?\s*""", re.VERBOSE) # backport bugfix
 class IDParser(HTMLParser.HTMLParser):
        """Modified HTMLParser that isolates a tag with the specified id"""
        def __init__(self, id):
@@ -83,8 +83,17 @@ class IDParser(HTMLParser.HTMLParser):
                self.depth = {}
                self.html = None
                self.watch_startpos = False
+               self.error_count = 0
                HTMLParser.HTMLParser.__init__(self)
 
+       def error(self, message):
+               print self.getpos()
+               if self.error_count > 10 or self.started:
+                       raise HTMLParser.HTMLParseError(message, self.getpos())
+               self.rawdata = '\n'.join(self.html.split('\n')[self.getpos()[0]:]) # skip one line
+               self.error_count += 1
+               self.goahead(1)
+
        def loads(self, html):
                self.html = html
                self.feed(html)