Skip to content

Commit

Permalink
[InfoExtractor] Support groups in _search_regex(), etc
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkf committed Jul 18, 2023
1 parent 6e04c30 commit ffcea47
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions youtube_dl/extractor/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,8 @@ def _search_regex(self, pattern, string, name, default=NO_DEFAULT, fatal=True, f
if group is None:
# return the first matching group
return next(g for g in mobj.groups() if g is not None)
elif isinstance(group, (list, tuple)):
return tuple(mobj.group(g) for g in group)
else:
return mobj.group(group)
elif default is not NO_DEFAULT:
Expand All @@ -1020,10 +1022,9 @@ def _html_search_regex(self, pattern, string, name, default=NO_DEFAULT, fatal=Tr
Like _search_regex, but strips HTML tags and unescapes entities.
"""
res = self._search_regex(pattern, string, name, default, fatal, flags, group)
if res:
return clean_html(res).strip()
else:
return res
if isinstance(res, tuple):
return tuple(map(clean_html, res))
return clean_html(res)

def _get_netrc_login_info(self, netrc_machine=None):
username = None
Expand Down

0 comments on commit ffcea47

Please sign in to comment.