mirror of
https://github.com/spaam/svtplay-dl.git
synced 2024-11-24 04:05:39 +01:00
Introduce .handle function in classes
This commit is contained in:
parent
220fa2479d
commit
96b03b0d7d
105
svtplay_dl.py
105
svtplay_dl.py
@ -540,6 +540,9 @@ def select_quality(options, streams):
|
||||
return selected
|
||||
|
||||
class Justin():
|
||||
def handle(self, url):
|
||||
return ("twitch.com" in url) or ("justin.tv" in url)
|
||||
|
||||
def get(self, options, url):
|
||||
parse = urlparse(url)
|
||||
match = re.search("/b/(\d+)", parse.path)
|
||||
@ -586,6 +589,9 @@ class Justin():
|
||||
download_rtmp(options, test["url"])
|
||||
|
||||
class Hbo():
|
||||
def handle(self, url):
|
||||
return "hbo.com" in url
|
||||
|
||||
def get(self, url):
|
||||
parse = urlparse(url)
|
||||
try:
|
||||
@ -620,6 +626,9 @@ class Hbo():
|
||||
download_rtmp(options, test["path"])
|
||||
|
||||
class Sr():
|
||||
def handle(self, url):
|
||||
return "svergesradio.se" in url
|
||||
|
||||
def get(self, options, url):
|
||||
data = get_http_data(url)
|
||||
parse = urlparse(url)
|
||||
@ -639,6 +648,9 @@ class Sr():
|
||||
download_http(options, url)
|
||||
|
||||
class Urplay():
|
||||
def handle(self, url):
|
||||
return "urplay.se" in url
|
||||
|
||||
def get(self, options, url):
|
||||
data = get_http_data(url)
|
||||
match = re.search('file=(.*)\&plugins', data)
|
||||
@ -649,6 +661,9 @@ class Urplay():
|
||||
download_rtmp(options, "rtmp://streaming.ur.se/")
|
||||
|
||||
class Qbrick():
|
||||
def handle(self, url):
|
||||
return ("dn.se" in url) or ("di.se" in url) or ("svd.se" in url)
|
||||
|
||||
def get(self, options, url):
|
||||
if re.findall("dn.se", url):
|
||||
data = get_http_data(url)
|
||||
@ -710,6 +725,9 @@ class Qbrick():
|
||||
download_rtmp(options, server)
|
||||
|
||||
class Kanal5():
|
||||
def handle(self, url):
|
||||
return "kanal5play.se" in url
|
||||
|
||||
def get(self, options, url):
|
||||
match = re.search(".*video/([0-9]+)", url)
|
||||
if not match:
|
||||
@ -735,6 +753,9 @@ class Kanal5():
|
||||
download_rtmp(options, steambaseurl)
|
||||
|
||||
class Kanal9():
|
||||
def handle(self, url):
|
||||
return "kanal9play.se" in url
|
||||
|
||||
def get(self, options, url):
|
||||
data = get_http_data(url)
|
||||
match = re.search("@videoPlayer\" value=\"(.*)\"", data)
|
||||
@ -772,6 +793,9 @@ class Kanal9():
|
||||
download_rtmp(options, match.group(1))
|
||||
|
||||
class Expressen():
|
||||
def handle(self, url):
|
||||
return "expressen.se" in url
|
||||
|
||||
def get(self, options, url):
|
||||
parse = urlparse(url)
|
||||
match = re.search("/(.*[\/\+].*)/", unquote_plus(parse.path))
|
||||
@ -803,6 +827,9 @@ class Expressen():
|
||||
download_rtmp(options, filename)
|
||||
|
||||
class Aftonbladet():
|
||||
def handle(self, url):
|
||||
return "aftonbladet.se" in url
|
||||
|
||||
def get(self, options, url, start):
|
||||
parse = urlparse(url)
|
||||
data = get_http_data(url)
|
||||
@ -835,6 +862,9 @@ class Aftonbladet():
|
||||
download_http(options, filename)
|
||||
|
||||
class Viaplay():
|
||||
def handle(self, url):
|
||||
return ("tv3play.se" in url) or ("tv6play.se" in url) or ("tv8play.se" in url)
|
||||
|
||||
def get(self, options, url):
|
||||
parse = urlparse(url)
|
||||
match = re.search('\/play\/(.*)/?', parse.path)
|
||||
@ -856,6 +886,9 @@ class Viaplay():
|
||||
download_rtmp(options, filename)
|
||||
|
||||
class Tv4play():
|
||||
def handle(self, url):
|
||||
return "tv4play.se" in url
|
||||
|
||||
def get(self, options, url):
|
||||
parse = urlparse(url)
|
||||
try:
|
||||
@ -904,6 +937,9 @@ class Tv4play():
|
||||
download_hds(options, manifest, swf)
|
||||
|
||||
class Svtplay():
|
||||
def handle(self, url):
|
||||
return ("svtplay.se" in url) or ("svt.se" in url)
|
||||
|
||||
def get(self, options, url):
|
||||
if re.findall("svt.se", url):
|
||||
data = get_http_data(url)
|
||||
@ -964,6 +1000,9 @@ class Svtplay():
|
||||
download_http(options, test["url"])
|
||||
|
||||
class Nrk(object):
|
||||
def handle(self, url):
|
||||
return "nrk.no" in url
|
||||
|
||||
def get(self, options, url):
|
||||
data = get_http_data(url)
|
||||
match = re.search(r'data-media="(.*manifest.f4m)"', data)
|
||||
@ -976,6 +1015,9 @@ class Nrk(object):
|
||||
download_hds(options, manifest_url)
|
||||
|
||||
class Dr(object):
|
||||
def handle(self, url):
|
||||
return "dr.dk" in url
|
||||
|
||||
def get(self, options, url):
|
||||
data = get_http_data(url)
|
||||
match = re.search(r'resource:[ ]*"([^"]*)",', data)
|
||||
@ -994,6 +1036,9 @@ class Dr(object):
|
||||
download_rtmp(options, uri)
|
||||
|
||||
class Ruv(object):
|
||||
def handle(self, url):
|
||||
return "ruv.is" in url
|
||||
|
||||
def get(self, options, url):
|
||||
data = get_http_data(url)
|
||||
match = re.search(r'(http://load.cache.is/vodruv.*)"', data)
|
||||
@ -1040,6 +1085,17 @@ def progressbar(total, pos, msg=""):
|
||||
progress_stream.write(fmt % (pos, total, bar, msg))
|
||||
|
||||
def get_media(url, options):
|
||||
sites = [Aftonbladet(), Dr(), Expressen(), Hbo(), Justin(), Kanal5(), Kanal9(),
|
||||
Nrk(), Qbrick(), Ruv(), Sr(), Svtplay(), Tv4play(), Urplay(), Viaplay()]
|
||||
stream = None
|
||||
for i in sites:
|
||||
if i.handle(url):
|
||||
stream = i
|
||||
break
|
||||
if not stream:
|
||||
log.error("That site is not supported. Make a ticket or send a message")
|
||||
sys.exit(2)
|
||||
|
||||
if not options.output or os.path.isdir(options.output):
|
||||
data = get_http_data(url)
|
||||
match = re.search("(?i)<title>\s*(.*?)\s*</title>", data)
|
||||
@ -1057,54 +1113,7 @@ def get_media(url, options):
|
||||
else:
|
||||
options.output = unicode(re.sub('[-\s]+', '-', title))
|
||||
|
||||
if re.findall("(twitch|justin).tv", url):
|
||||
Justin().get(options, url)
|
||||
|
||||
if re.findall("hbo.com", url):
|
||||
Hbo().get(options, url)
|
||||
|
||||
if re.findall("tv4play", url):
|
||||
Tv4play().get(options, url)
|
||||
|
||||
elif re.findall("(tv3play|tv6play|tv8play)", url):
|
||||
Viaplay().get(options, url)
|
||||
|
||||
elif re.findall("aftonbladet", url):
|
||||
Aftonbladet().get(options, url, start)
|
||||
|
||||
elif re.findall("expressen", url):
|
||||
Expressen().get(options, url)
|
||||
|
||||
elif re.findall("kanal5play", url):
|
||||
Kanal5().get(options, url)
|
||||
|
||||
elif re.findall("kanal9play", url):
|
||||
Kanal9().get(options, url)
|
||||
|
||||
elif re.findall("(di|svd|dn).se", url):
|
||||
Qbrick().get(options, url)
|
||||
|
||||
elif re.findall("urplay.se", url):
|
||||
Urplay().get(options, url)
|
||||
|
||||
elif re.findall("sverigesradio", url):
|
||||
Sr().get(options, url)
|
||||
|
||||
elif re.findall("(svt|svtplay).se", url):
|
||||
Svtplay().get(options, url)
|
||||
|
||||
elif re.findall("tv.nrk.no", url):
|
||||
Nrk().get(options, url)
|
||||
|
||||
elif re.findall("dr.dk/TV", url):
|
||||
Dr().get(options, url)
|
||||
|
||||
elif re.findall("ruv.is", url):
|
||||
Ruv().get(options, url)
|
||||
|
||||
else:
|
||||
log.error("That site is not supported. Make a ticket or send a message")
|
||||
sys.exit(2)
|
||||
stream.get(options, url)
|
||||
|
||||
def setup_log(silent):
|
||||
if silent:
|
||||
|
Loading…
Reference in New Issue
Block a user