mirror of
https://github.com/spaam/svtplay-dl.git
synced 2024-11-27 21:54:17 +01:00
Move url to object attribute
This commit is contained in:
parent
231eaf00e6
commit
f331a653b6
@ -70,7 +70,7 @@ def get_media(url, options):
|
||||
# output is a directory
|
||||
os.path.join(options.output, filenamify(title_tag))
|
||||
|
||||
stream.get(options, url)
|
||||
stream.get(options)
|
||||
|
||||
def setup_log(silent, verbose=False):
|
||||
fmt = logging.Formatter('%(levelname)s %(message)s')
|
||||
|
@ -8,6 +8,9 @@ class Service(object):
|
||||
supported_domains = []
|
||||
supported_domains_re = []
|
||||
|
||||
def __init__(self, url):
|
||||
self.url = url
|
||||
|
||||
@classmethod
|
||||
def handles(cls, url):
|
||||
urlp = urlparse(url)
|
||||
@ -77,19 +80,19 @@ class Generic(object):
|
||||
url = match.group(1)
|
||||
for i in sites:
|
||||
if i.handles(url):
|
||||
return url, i()
|
||||
return url, i(url)
|
||||
|
||||
match = re.search(r"src=\"(http://player.vimeo.com/video/[0-9]+)\" ", data)
|
||||
if match:
|
||||
for i in sites:
|
||||
if i.handles(match.group(1)):
|
||||
return match.group(1), i()
|
||||
return match.group(1), i(url)
|
||||
match = re.search(r"tv4video.swf\?vid=(\d+)", data)
|
||||
if match:
|
||||
url = "http://www.tv4play.se/?video_id=%s" % match.group(1)
|
||||
for i in sites:
|
||||
if i.handles(url):
|
||||
return url, i()
|
||||
return url, i(url)
|
||||
return url, stream
|
||||
|
||||
def service_handler(url):
|
||||
@ -97,7 +100,7 @@ def service_handler(url):
|
||||
|
||||
for i in sites:
|
||||
if i.handles(url):
|
||||
handler = i()
|
||||
handler = i(url)
|
||||
break
|
||||
|
||||
return handler
|
||||
|
@ -15,9 +15,9 @@ from svtplay_dl.fetcher.http import download_http
|
||||
class Aftonbladet(Service):
|
||||
supported_domains = ['aftonbladet.se']
|
||||
|
||||
def get(self, options, url):
|
||||
parse = urlparse(url)
|
||||
data = get_http_data(url)
|
||||
def get(self, options):
|
||||
parse = urlparse(self.url)
|
||||
data = get_http_data(self.url)
|
||||
match = re.search("abTvArticlePlayer-player-(.*)-[0-9]+-[0-9]+-clickOverlay", data)
|
||||
if not match:
|
||||
log.error("Can't find video file")
|
||||
|
@ -14,8 +14,8 @@ from svtplay_dl.log import log
|
||||
class Dr(Service):
|
||||
supported_domains = ['dr.dk']
|
||||
|
||||
def get(self, options, url):
|
||||
data = get_http_data(url)
|
||||
def get(self, options):
|
||||
data = get_http_data(self.url)
|
||||
match = re.search(r'resource:[ ]*"([^"]*)",', data)
|
||||
if match:
|
||||
resource_url = match.group(1)
|
||||
|
@ -15,8 +15,8 @@ from svtplay_dl.utils.urllib import quote_plus
|
||||
class Expressen(Service):
|
||||
supported_domains = ['expressen.se']
|
||||
|
||||
def get(self, options, url):
|
||||
data = get_http_data(url)
|
||||
def get(self, options):
|
||||
data = get_http_data(self.url)
|
||||
match = re.search(r"xmlUrl: '(http://www.expressen.*)'", data)
|
||||
if not match:
|
||||
log.error("Can't find video file")
|
||||
|
@ -14,8 +14,8 @@ from svtplay_dl.fetcher.rtmp import download_rtmp
|
||||
class Hbo(Service):
|
||||
supported_domains = ['hbo.com']
|
||||
|
||||
def get(self, options, url):
|
||||
parse = urlparse(url)
|
||||
def get(self, options):
|
||||
parse = urlparse(self.url)
|
||||
try:
|
||||
other = parse[5]
|
||||
except KeyError:
|
||||
|
@ -24,8 +24,8 @@ class Justin(Service):
|
||||
r'^(?:(?:[a-z]{2}-)?[a-z]{2}\.)?(www\.)?twitch\.tv$',
|
||||
r'^(?:(?:[a-z]{2}-)?[a-z]{2}\.)?(www\.)?justin\.tv$']
|
||||
|
||||
def get(self, options, url):
|
||||
parse = urlparse(url)
|
||||
def get(self, options):
|
||||
parse = urlparse(self.url)
|
||||
match = re.search(r"/[-a-zA-Z0-9_]+/c/(\d+)", parse.path)
|
||||
if match:
|
||||
url = "http://api.justin.tv/api/broadcast/by_chapter/%s.xml?onsite=true" % match.group(1)
|
||||
|
@ -15,9 +15,9 @@ from svtplay_dl.fetcher.hls import download_hls
|
||||
class Kanal5(Service):
|
||||
supported_domains = ['kanal5play.se', 'kanal9play.se']
|
||||
|
||||
def get(self, options, url):
|
||||
def get(self, options):
|
||||
cj = CookieJar()
|
||||
match = re.search(r".*video/([0-9]+)", url)
|
||||
match = re.search(r".*video/([0-9]+)", self.url)
|
||||
if not match:
|
||||
log.error("Can't find video file")
|
||||
sys.exit(2)
|
||||
|
@ -12,8 +12,8 @@ from svtplay_dl.log import log
|
||||
class Mtvservices(Service):
|
||||
supported_domains = ['colbertnation.com', 'thedailyshow.com']
|
||||
|
||||
def get(self, options, url):
|
||||
data = get_http_data(url)
|
||||
def get(self, options):
|
||||
data = get_http_data(self.url)
|
||||
match = re.search(r"mgid=\"(mgid.*[0-9]+)\" data-wi", data)
|
||||
if not match:
|
||||
log.error("Can't find video file")
|
||||
|
@ -12,8 +12,8 @@ from svtplay_dl.fetcher.hls import download_hls
|
||||
class Nrk(Service):
|
||||
supported_domains = ['nrk.no']
|
||||
|
||||
def get(self, options, url):
|
||||
data = get_http_data(url)
|
||||
def get(self, options):
|
||||
data = get_http_data(self.url)
|
||||
match = re.search(r'data-media="(.*manifest.f4m)"', data)
|
||||
manifest_url = match.group(1)
|
||||
if options.hls:
|
||||
@ -25,7 +25,7 @@ class Nrk(Service):
|
||||
if options.subtitle:
|
||||
match = re.search("data-subtitlesurl = \"(/.*)\"", data)
|
||||
if match:
|
||||
parse = urlparse(url)
|
||||
parse = urlparse(self.url)
|
||||
subtitle = "%s://%s%s" % (parse.scheme, parse.netloc, match.group(1))
|
||||
data = get_http_data(subtitle)
|
||||
subtitle_tt(options, data)
|
||||
|
@ -13,17 +13,17 @@ from svtplay_dl.fetcher.rtmp import download_rtmp
|
||||
class Qbrick(Service):
|
||||
supported_domains = ['dn.se', 'di.se', 'svd.se', 'sydsvenskan.se']
|
||||
|
||||
def get(self, options, url):
|
||||
if re.findall(r"sydsvenskan.se", url):
|
||||
data = get_http_data(url)
|
||||
def get(self, options):
|
||||
if re.findall(r"sydsvenskan.se", self.url):
|
||||
data = get_http_data(self.url)
|
||||
match = re.search(r"data-qbrick-mcid=\"([0-9A-F]+)\"", data)
|
||||
if not match:
|
||||
log.error("Can't find video file")
|
||||
sys.exit(2)
|
||||
mcid = match.group(1)
|
||||
host = "http://vms.api.qbrick.com/rest/v3/getsingleplayer/%s" % mcid
|
||||
elif re.findall(r"di.se", url):
|
||||
data = get_http_data(url)
|
||||
elif re.findall(r"di.se", self.url):
|
||||
data = get_http_data(self.url)
|
||||
match = re.search("src=\"(http://qstream.*)\"></iframe", data)
|
||||
if not match:
|
||||
log.error("Can't find video info")
|
||||
@ -34,8 +34,8 @@ class Qbrick(Service):
|
||||
log.error("Can't find video file")
|
||||
sys.exit(2)
|
||||
host = "http://vms.api.qbrick.com/rest/v3/getplayer/%s" % match.group(1)
|
||||
elif re.findall(r"dn.se", url):
|
||||
data = get_http_data(url)
|
||||
elif re.findall(r"dn.se", self.url):
|
||||
data = get_http_data(self.url)
|
||||
match = re.search(r"'([0-9A-F]{8})',", data)
|
||||
if not match:
|
||||
match = re.search(r"mediaId = '([0-9A-F]{8})';", data)
|
||||
@ -43,8 +43,8 @@ class Qbrick(Service):
|
||||
log.error("Can't find video file")
|
||||
sys.exit(2)
|
||||
host = "http://vms.api.qbrick.com/rest/v3//getsingleplayer/%sDE1BA107?statusCode=xml" % match.group(1)
|
||||
elif re.findall(r"svd.se", url):
|
||||
match = re.search(r"_([0-9]+)\.svd", url)
|
||||
elif re.findall(r"svd.se", self.url):
|
||||
match = re.search(r"_([0-9]+)\.svd", self.url)
|
||||
if not match:
|
||||
log.error("Can't find video file")
|
||||
sys.exit(2)
|
||||
|
@ -19,10 +19,10 @@ from svtplay_dl.log import log
|
||||
class Radioplay(Service):
|
||||
supported_domains = ['radioplay.se']
|
||||
|
||||
def get(self, options, url):
|
||||
data = get_http_data(url)
|
||||
def get(self, options):
|
||||
data = get_http_data(self.url)
|
||||
match = re.search(r"liveStationsRedundancy = ({.*});</script>", data)
|
||||
parse = urlparse(url)
|
||||
parse = urlparse(self.url)
|
||||
station = parse.path[1:]
|
||||
streams = None
|
||||
if match:
|
||||
|
@ -10,8 +10,8 @@ from svtplay_dl.fetcher.hls import download_hls
|
||||
class Ruv(Service):
|
||||
supported_domains = ['ruv.is']
|
||||
|
||||
def get(self, options, url):
|
||||
data = get_http_data(url)
|
||||
def get(self, options):
|
||||
data = get_http_data(self.url)
|
||||
match = re.search(r'(http://load.cache.is/vodruv.*)"', data)
|
||||
js_url = match.group(1)
|
||||
js = get_http_data(js_url)
|
||||
|
@ -18,9 +18,9 @@ from svtplay_dl.fetcher.http import download_http
|
||||
class Sr(Service):
|
||||
supported_domains = ['sverigesradio.se']
|
||||
|
||||
def get(self, options, url):
|
||||
data = get_http_data(url)
|
||||
parse = urlparse(url)
|
||||
def get(self, options):
|
||||
data = get_http_data(self.url)
|
||||
parse = urlparse(self.url)
|
||||
|
||||
if "metafile" in parse_qs(parse.query):
|
||||
options.other = "%s?%s" % (parse.path, parse.query)
|
||||
|
@ -18,9 +18,9 @@ from svtplay_dl.log import log
|
||||
class Svtplay(Service):
|
||||
supported_domains = ['svtplay.se', 'svt.se', 'oppetarkiv.se', 'beta.svtplay.se']
|
||||
|
||||
def get(self, options, url):
|
||||
if re.findall("svt.se", url):
|
||||
data = get_http_data(url)
|
||||
def get(self, options):
|
||||
if re.findall("svt.se", self.url):
|
||||
data = get_http_data(self.url)
|
||||
match = re.search(r"data-json-href=\"(.*)\"", data)
|
||||
if match:
|
||||
filename = match.group(1).replace("&", "&").replace("&format=json", "")
|
||||
@ -28,6 +28,8 @@ class Svtplay(Service):
|
||||
else:
|
||||
log.error("Can't find video file")
|
||||
sys.exit(2)
|
||||
else:
|
||||
url = self.url
|
||||
|
||||
pos = url.find("?")
|
||||
if pos < 0:
|
||||
|
@ -15,20 +15,20 @@ from svtplay_dl.fetcher.hds import download_hds
|
||||
class Tv4play(Service):
|
||||
supported_domains = ['tv4play.se', 'tv4.se']
|
||||
|
||||
def get(self, options, url):
|
||||
parse = urlparse(url)
|
||||
if "tv4play.se" in url:
|
||||
def get(self, options):
|
||||
parse = urlparse(self.url)
|
||||
if "tv4play.se" in self.url:
|
||||
try:
|
||||
vid = parse_qs(parse[4])["video_id"][0]
|
||||
except KeyError:
|
||||
log.error("Can't find video file")
|
||||
sys.exit(2)
|
||||
else:
|
||||
match = re.search(r"-(\d+)$", url)
|
||||
match = re.search(r"-(\d+)$", self.url)
|
||||
if match:
|
||||
vid = match.group(1)
|
||||
else:
|
||||
data = get_http_data(url)
|
||||
data = get_http_data(self.url)
|
||||
match = re.search(r"\"vid\":\"(\d+)\",", data)
|
||||
if match:
|
||||
vid = match.group(1)
|
||||
|
@ -14,8 +14,8 @@ from svtplay_dl.log import log
|
||||
class Urplay(Service):
|
||||
supported_domains = ['urplay.se', 'ur.se']
|
||||
|
||||
def get(self, options, url):
|
||||
data = get_http_data(url)
|
||||
def get(self, options):
|
||||
data = get_http_data(self.url)
|
||||
match = re.search(r"urPlayer.init\((.*)\);", data)
|
||||
if not match:
|
||||
log.error("Can't find json info")
|
||||
|
@ -21,8 +21,8 @@ class Viaplay(Service):
|
||||
'tv3play.no', 'tv3play.dk', 'tv6play.no', 'viasat4play.no',
|
||||
'tv3play.ee', 'tv3play.lv', 'tv3play.lt']
|
||||
|
||||
def get(self, options, url):
|
||||
parse = urlparse(url)
|
||||
def get(self, options):
|
||||
parse = urlparse(self.url)
|
||||
match = re.search(r'\/play\/(\d+)/?', parse.path)
|
||||
if not match:
|
||||
log.error("Cant find video file")
|
||||
|
@ -13,8 +13,8 @@ from svtplay_dl.log import log
|
||||
class Vimeo(Service):
|
||||
supported_domains = ['vimeo.com']
|
||||
|
||||
def get(self, options, url):
|
||||
data = get_http_data(url)
|
||||
def get(self, options):
|
||||
data = get_http_data(self.url)
|
||||
match = re.search("data-config-url=\"(.*)\" data-fallback-url", data)
|
||||
if not match:
|
||||
log.error("Can't find data")
|
||||
|
Loading…
Reference in New Issue
Block a user