2014-05-01 19:51:21 +02:00
|
|
|
# ex:ts=4:sw=4:sts=4:et
|
|
|
|
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
|
|
from __future__ import absolute_import
|
|
|
|
import re
|
|
|
|
from svtplay_dl.service.svtplay import Svtplay
|
|
|
|
from svtplay_dl.log import log
|
|
|
|
|
2015-09-15 20:10:32 +02:00
|
|
|
|
2014-05-01 19:51:21 +02:00
|
|
|
class OppetArkiv(Svtplay):
|
|
|
|
supported_domains = ['oppetarkiv.se']
|
|
|
|
|
2016-01-07 17:18:38 +01:00
|
|
|
def find_all_episodes(self, options):
|
2014-05-01 19:51:21 +02:00
|
|
|
page = 1
|
2015-08-31 17:14:31 +02:00
|
|
|
data = self.get_urldata()
|
2015-06-28 16:45:43 +02:00
|
|
|
match = re.search(r'"/etikett/titel/([^"/]+)', data)
|
2014-05-01 19:51:21 +02:00
|
|
|
if match is None:
|
2015-06-28 16:45:43 +02:00
|
|
|
match = re.search(r'"http://www.oppetarkiv.se/etikett/titel/([^/]+)/', self.url)
|
2014-05-01 19:51:21 +02:00
|
|
|
if match is None:
|
|
|
|
log.error("Couldn't find title")
|
2014-10-06 23:21:43 +02:00
|
|
|
return
|
2014-05-01 19:51:21 +02:00
|
|
|
program = match.group(1)
|
|
|
|
episodes = []
|
2014-12-21 13:10:26 +01:00
|
|
|
|
|
|
|
n = 0
|
2015-12-26 11:46:14 +01:00
|
|
|
if self.options.all_last > 0:
|
2014-12-21 13:10:26 +01:00
|
|
|
sort = "tid_fallande"
|
|
|
|
else:
|
|
|
|
sort = "tid_stigande"
|
|
|
|
|
2015-09-30 00:47:49 +02:00
|
|
|
while True:
|
2014-12-21 13:10:26 +01:00
|
|
|
url = "http://www.oppetarkiv.se/etikett/titel/%s/?sida=%s&sort=%s&embed=true" % (program, page, sort)
|
2015-09-30 00:47:49 +02:00
|
|
|
data = self.http.request("get", url)
|
|
|
|
if data.status_code == 404:
|
|
|
|
break
|
|
|
|
|
|
|
|
data = data.text
|
2015-06-28 16:45:43 +02:00
|
|
|
regex = re.compile(r'href="(/video/[^"]+)"')
|
2014-05-01 19:51:21 +02:00
|
|
|
for match in regex.finditer(data):
|
2015-12-26 11:46:14 +01:00
|
|
|
if n == self.options.all_last:
|
2014-12-21 13:10:26 +01:00
|
|
|
break
|
2015-06-28 16:45:43 +02:00
|
|
|
episodes.append("http://www.oppetarkiv.se%s" % match.group(1))
|
2014-12-21 13:10:26 +01:00
|
|
|
n += 1
|
2014-05-01 19:51:21 +02:00
|
|
|
page += 1
|
|
|
|
|
|
|
|
return episodes
|