mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-02 17:22:31 +01:00
[motherless:group] Relax entry extraction and add a fallback scenario
This commit is contained in:
parent
a133eb7764
commit
0a5b1295b7
@ -148,14 +148,27 @@ def suitable(cls, url):
|
|||||||
else super(MotherlessGroupIE, cls).suitable(url))
|
else super(MotherlessGroupIE, cls).suitable(url))
|
||||||
|
|
||||||
def _extract_entries(self, webpage, base):
|
def _extract_entries(self, webpage, base):
|
||||||
return [
|
entries = []
|
||||||
self.url_result(
|
for mobj in re.finditer(
|
||||||
compat_urlparse.urljoin(base, video_path),
|
r'href="(?P<href>/[^"]+)"[^>]*>(?:\s*<img[^>]+alt="[^-]+-\s(?P<title>[^"]+)")?',
|
||||||
MotherlessIE.ie_key(), video_title=title)
|
webpage):
|
||||||
for video_path, title in orderedSet(re.findall(
|
video_url = compat_urlparse.urljoin(base, mobj.group('href'))
|
||||||
r'href="(/[^"]+)"[^>]+>\s+<img[^>]+alt="[^-]+-\s([^"]+)"',
|
if not MotherlessIE.suitable(video_url):
|
||||||
webpage))
|
continue
|
||||||
]
|
video_id = MotherlessIE._match_id(video_url)
|
||||||
|
title = mobj.group('title')
|
||||||
|
entries.append(self.url_result(
|
||||||
|
video_url, ie=MotherlessIE.ie_key(), video_id=video_id,
|
||||||
|
video_title=title))
|
||||||
|
# Alternative fallback
|
||||||
|
if not entries:
|
||||||
|
entries = [
|
||||||
|
self.url_result(
|
||||||
|
compat_urlparse.urljoin(base, '/' + video_id),
|
||||||
|
ie=MotherlessIE.ie_key(), video_id=video_id)
|
||||||
|
for video_id in orderedSet(re.findall(
|
||||||
|
r'data-codename=["\']([A-Z0-9]+)', webpage))]
|
||||||
|
return entries
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
group_id = self._match_id(url)
|
group_id = self._match_id(url)
|
||||||
|
Loading…
Reference in New Issue
Block a user