2013-03-02 21:26:28 +01:00
|
|
|
# ex:ts=4:sw=4:sts=4:et
|
|
|
|
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
2013-03-01 23:39:42 +01:00
|
|
|
from __future__ import absolute_import
|
2013-03-23 16:11:36 +01:00
|
|
|
import re
|
2014-01-01 14:57:17 +01:00
|
|
|
from urlparse import urlparse
|
2013-03-23 16:11:36 +01:00
|
|
|
|
|
|
|
class Service(object):
|
2014-01-01 14:57:17 +01:00
|
|
|
supported_domains = []
|
|
|
|
|
2014-01-01 15:03:15 +01:00
|
|
|
def handles(self, url):
|
2014-01-01 14:57:17 +01:00
|
|
|
urlp = urlparse(url)
|
|
|
|
|
|
|
|
if urlp.netloc in self.supported_domains:
|
|
|
|
return True
|
|
|
|
|
|
|
|
# For every listed domain, try with www. subdomain as well.
|
|
|
|
if urlp.netloc in ['www.'+x for x in self.supported_domains]:
|
|
|
|
return True
|
|
|
|
|
|
|
|
return False
|
2013-03-01 23:39:42 +01:00
|
|
|
|
2013-03-23 15:56:25 +01:00
|
|
|
from svtplay_dl.service.aftonbladet import Aftonbladet
|
|
|
|
from svtplay_dl.service.dr import Dr
|
|
|
|
from svtplay_dl.service.expressen import Expressen
|
|
|
|
from svtplay_dl.service.hbo import Hbo
|
|
|
|
from svtplay_dl.service.justin import Justin
|
|
|
|
from svtplay_dl.service.kanal5 import Kanal5
|
2013-04-21 21:51:45 +02:00
|
|
|
from svtplay_dl.service.mtvservices import Mtvservices
|
2013-03-23 15:56:25 +01:00
|
|
|
from svtplay_dl.service.nrk import Nrk
|
|
|
|
from svtplay_dl.service.qbrick import Qbrick
|
|
|
|
from svtplay_dl.service.ruv import Ruv
|
|
|
|
from svtplay_dl.service.radioplay import Radioplay
|
|
|
|
from svtplay_dl.service.sr import Sr
|
|
|
|
from svtplay_dl.service.svtplay import Svtplay
|
|
|
|
from svtplay_dl.service.tv4play import Tv4play
|
|
|
|
from svtplay_dl.service.urplay import Urplay
|
|
|
|
from svtplay_dl.service.viaplay import Viaplay
|
|
|
|
from svtplay_dl.service.vimeo import Vimeo
|
2013-03-23 16:11:36 +01:00
|
|
|
from svtplay_dl.utils import get_http_data
|
2013-03-23 15:56:25 +01:00
|
|
|
|
2013-03-23 15:58:15 +01:00
|
|
|
sites = [
|
|
|
|
Aftonbladet(),
|
|
|
|
Dr(),
|
|
|
|
Expressen(),
|
|
|
|
Hbo(),
|
|
|
|
Justin(),
|
|
|
|
Kanal5(),
|
2013-04-21 21:51:45 +02:00
|
|
|
Mtvservices(),
|
2013-03-23 15:58:15 +01:00
|
|
|
Nrk(),
|
|
|
|
Qbrick(),
|
|
|
|
Ruv(),
|
|
|
|
Radioplay(),
|
|
|
|
Sr(),
|
|
|
|
Svtplay(),
|
|
|
|
Tv4play(),
|
|
|
|
Urplay(),
|
|
|
|
Viaplay(),
|
|
|
|
Vimeo()]
|
|
|
|
|
2013-02-28 21:44:28 +01:00
|
|
|
|
2013-03-10 13:28:31 +01:00
|
|
|
class Generic(object):
|
|
|
|
''' Videos embed in sites '''
|
2013-03-23 16:11:36 +01:00
|
|
|
def get(self, url):
|
2013-03-10 13:28:31 +01:00
|
|
|
data = get_http_data(url)
|
2013-11-14 22:43:39 +01:00
|
|
|
match = re.search(r"src=\"(http://www.svt.se/wd.*)\" height", data)
|
2013-03-10 13:28:31 +01:00
|
|
|
stream = None
|
|
|
|
if match:
|
|
|
|
url = match.group(1)
|
|
|
|
for i in sites:
|
2014-01-01 15:03:15 +01:00
|
|
|
if i.handles(url):
|
2013-03-10 13:28:31 +01:00
|
|
|
return url, i
|
|
|
|
|
2013-05-05 12:57:42 +02:00
|
|
|
match = re.search(r"src=\"(http://player.vimeo.com/video/[0-9]+)\" ", data)
|
2013-03-10 13:28:31 +01:00
|
|
|
if match:
|
|
|
|
for i in sites:
|
2014-01-01 15:03:15 +01:00
|
|
|
if i.handles(match.group(1)):
|
2013-03-10 13:28:31 +01:00
|
|
|
return match.group(1), i
|
2013-05-05 12:57:42 +02:00
|
|
|
match = re.search(r"tv4video.swf\?vid=(\d+)", data)
|
2013-03-24 14:55:14 +01:00
|
|
|
if match:
|
|
|
|
url = "http://www.tv4play.se/?video_id=%s" % match.group(1)
|
|
|
|
for i in sites:
|
2014-01-01 15:03:15 +01:00
|
|
|
if i.handles(url):
|
2013-03-24 14:55:14 +01:00
|
|
|
return url, i
|
2013-03-10 13:28:31 +01:00
|
|
|
return url, stream
|
|
|
|
|
2013-02-28 21:44:28 +01:00
|
|
|
def service_handler(url):
|
|
|
|
handler = None
|
|
|
|
|
|
|
|
for i in sites:
|
2014-01-01 15:03:15 +01:00
|
|
|
if i.handles(url):
|
2013-02-28 21:44:28 +01:00
|
|
|
handler = i
|
|
|
|
break
|
|
|
|
|
2014-01-01 14:57:17 +01:00
|
|
|
return handler
|