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
|
|
|
|
|
2014-05-01 22:01:09 +02:00
|
|
|
from svtplay_dl.utils import get_http_data
|
2014-05-01 19:51:21 +02:00
|
|
|
from svtplay_dl.service.svtplay import Svtplay
|
|
|
|
from svtplay_dl.log import log
|
|
|
|
|
|
|
|
class OppetArkiv(Svtplay):
|
|
|
|
supported_domains = ['oppetarkiv.se']
|
|
|
|
|
|
|
|
def find_all_episodes(self, options):
|
|
|
|
page = 1
|
2014-12-08 23:07:02 +01:00
|
|
|
error, data = self.get_urldata()
|
|
|
|
match = re.search(r'"http://www.oppetarkiv.se/etikett/titel/([^"/]+)', data)
|
2014-05-01 19:51:21 +02:00
|
|
|
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")
|
2014-10-06 23:21:43 +02:00
|
|
|
return
|
2014-05-01 19:51:21 +02:00
|
|
|
program = match.group(1)
|
|
|
|
more = True
|
|
|
|
episodes = []
|
2014-12-21 13:10:26 +01:00
|
|
|
|
|
|
|
n = 0
|
|
|
|
if options.all_last > 0:
|
|
|
|
sort = "tid_fallande"
|
|
|
|
else:
|
|
|
|
sort = "tid_stigande"
|
|
|
|
|
2014-05-01 19:51:21 +02:00
|
|
|
while more:
|
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)
|
2014-12-08 23:07:02 +01:00
|
|
|
error, data = get_http_data(url)
|
2014-05-01 19:51:21 +02:00
|
|
|
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):
|
2014-12-21 13:10:26 +01:00
|
|
|
if n == options.all_last:
|
|
|
|
break
|
2014-05-01 19:51:21 +02:00
|
|
|
episodes.append(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
|