diff --git a/lib/svtplay_dl/service/svtplay.py b/lib/svtplay_dl/service/svtplay.py index 1a04c46..239c997 100644 --- a/lib/svtplay_dl/service/svtplay.py +++ b/lib/svtplay_dl/service/svtplay.py @@ -119,12 +119,38 @@ class Svtplay(Service, OpenGraphThumbMixin): def find_all_episodes(self, options): - match = re.search(r']*href="([^"]+)"', - self.get_urldata()) - if match is None: - log.error("Couldn't retrieve episode list") - sys.exit(2) + parse = urlparse(self.url) + if parse.netloc == "www.oppetarkiv.se": + page = 1 + match = re.search(r'"http://www.oppetarkiv.se/etikett/titel/([^"/]+)', self.get_urldata()) + if match is None: + match = re.search(r'"http://www.oppetarkiv.se/etikett/titel/([^"/]+)', self.url) + if match is None: + log.error("Couldn't find title") + sys.exit(2) + program = match.group(1) + more = True + episodes = [] + while more: + url = "http://www.oppetarkiv.se/etikett/titel/%s/?sida=%s&sort=tid_stigande&embed=true" % (program, page) + data = get_http_data(url) + visa = re.search(r'svtXColorDarkLightGrey', data) + if not visa: + more = False + regex = re.compile(r'(http://www.oppetarkiv.se/video/[^"]+)') + for match in regex.finditer(data): + episodes.append(match.group(1)) + page += 1 - xml = ET.XML(get_http_data(match.group(1))) + return episodes - return sorted(x.text for x in xml.findall(".//item/link")) + else: + match = re.search(r']*href="([^"]+)"', + self.get_urldata()) + if match is None: + log.error("Couldn't retrieve episode list") + sys.exit(2) + + xml = ET.XML(get_http_data(match.group(1))) + + return sorted(x.text for x in xml.findall(".//item/link"))