mirror of https://github.com/yt-dlp/yt-dlp.git
Improve OpenGraph property matching
This commit is contained in:
parent
36034aecc2
commit
3c4e6d8337
|
@ -259,16 +259,16 @@ class InfoExtractor(object):
|
||||||
|
|
||||||
# Helper functions for extracting OpenGraph info
|
# Helper functions for extracting OpenGraph info
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _og_regex(property):
|
def _og_regex(prop):
|
||||||
return r'<meta.+?property=[\'"]og:%s[\'"].+?content=(?:"(.+?)"|\'(.+?)\')' % property
|
return r'<meta.+?property=[\'"]og:%s[\'"].+?content=(?:"(.+?)"|\'(.+?)\')' % re.escape(prop)
|
||||||
|
|
||||||
def _og_search_property(self, property, html, name=None, **kargs):
|
def _og_search_property(self, prop, html, name=None, **kargs):
|
||||||
if name is None:
|
if name is None:
|
||||||
name = 'OpenGraph %s' % property
|
name = 'OpenGraph %s' % prop
|
||||||
return self._html_search_regex(self._og_regex(property), html, name, flags=re.DOTALL, **kargs)
|
return self._html_search_regex(self._og_regex(prop), html, name, flags=re.DOTALL, **kargs)
|
||||||
|
|
||||||
def _og_search_thumbnail(self, html, **kargs):
|
def _og_search_thumbnail(self, html, **kargs):
|
||||||
return self._og_search_property('image', html, 'thumbnail url', fatal=False, **kargs)
|
return self._og_search_property('image', html, u'thumbnail url', fatal=False, **kargs)
|
||||||
|
|
||||||
def _og_search_description(self, html, **kargs):
|
def _og_search_description(self, html, **kargs):
|
||||||
return self._og_search_property('description', html, fatal=False, **kargs)
|
return self._og_search_property('description', html, fatal=False, **kargs)
|
||||||
|
|
Loading…
Reference in New Issue