1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-24 04:05:39 +01:00

svtplay: all episodes for öppet arkiv.

This commit is contained in:
Johan Andersson 2014-04-03 21:02:51 +02:00
parent 9303550de1
commit cba3bed554

View File

@ -119,12 +119,38 @@ class Svtplay(Service, OpenGraphThumbMixin):
def find_all_episodes(self, options):
match = re.search(r'<link rel="alternate" type="application/rss\+xml" [^>]*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'<link rel="alternate" type="application/rss\+xml" [^>]*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"))