1
0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2025-02-06 18:20:02 +00:00

Use (?i) for case-insensitivity in URLs

This commit is contained in:
John Hawkinson 2016-10-08 19:21:33 -04:00
parent e468f91968
commit 71fbddb78a

View File

@ -47,28 +47,8 @@ from .generic import GenericIE
class IQM2IE(InfoExtractor):
# xxx is really right that InfoExtractor.suitable() calls re.compile()
# on _VALID_URL in a case-sensitive fashion? It's obviously reasonable
# for the path portion of a URL to be case-sensitive, but the hostname
# ought not to be. And it seems like strict adherence might mess up a
# bunch of extractors in funny-cased URLs? Redefine suitable() to search
# case-insensitively. Note this also changes the re.match() call at the
# start of _real_extract()
#
# In this case, we commonly see both iqm2.com and IQM2.com.
@classmethod
def suitable(cls, url):
"""Receives a URL and returns True if suitable for this IE."""
# This does not use has/getattr intentionally - we want to know whether
# we have cached the regexp for *this* class, whereas getattr would also
# match the superclass
if '_VALID_URL_RE' not in cls.__dict__:
cls._VALID_URL_RE = re.compile(cls._VALID_URL, flags=re.IGNORECASE)
return cls._VALID_URL_RE.match(url) is not None
_VALID_URL = r'https?://(?:\w+\.)?iqm2\.com/Citizens/\w+.aspx\?.*MeetingID=(?P<id>[0-9]+)'
# We commonly see both iqm2.com and IQM2.com.
_VALID_URL = r'(?i)https?://(?:\w+\.)?iqm2\.com/Citizens/\w+.aspx\?.*MeetingID=(?P<id>[0-9]+)'
_TESTS = [ {
'url': 'http://cambridgema.iqm2.com/Citizens/SplitView.aspx?Mode=Video&MeetingID=1679#',
'md5': '478ea30eee1966f7be0d8dd623122148',
@ -83,7 +63,7 @@ class IQM2IE(InfoExtractor):
}]
def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url, flags=re.IGNORECASE)
mobj = re.match(self._VALID_URL, url)
video_id = mobj.group('id')
webpage = self._download_webpage(url, video_id)