Control: tags 853772 + patch Control: tags 853772 + pending Dear maintainer,
I've prepared an NMU for svtplay-dl (versioned as 1.9.1-0.1) and
uploaded it to DELAYED/5. Please feel free to tell me if I
should delay it longer.
Regards.
--
regards,
Mattia Rizzolo
GPG Key: 66AE 2B4A FCCF 3F52 DA18 4D18 4B04 3FCD B944 4540 .''`.
more about me: https://mapreri.org : :' :
Launchpad user: https://launchpad.net/~mapreri `. `'`
Debian QA page: https://qa.debian.org/developer.php?login=mattia `-
diffstat for svtplay-dl-1.8 svtplay-dl-1.9.1 Makefile | 2 - README.rst | 15 ++++---- debian/changelog | 7 +++ debian/patches/debian-changes | 12 +++--- lib/svtplay_dl/__init__.py | 31 ++++++++++++---- lib/svtplay_dl/output.py | 4 +- lib/svtplay_dl/postprocess/__init__.py | 33 +++++++++++------ lib/svtplay_dl/service/dplay.py | 10 ++++- lib/svtplay_dl/service/oppetarkiv.py | 7 +-- lib/svtplay_dl/service/picsearch.py | 61 ++++++++++++++++++--------------- lib/svtplay_dl/service/solidtango.py | 8 ++++ lib/svtplay_dl/service/svtplay.py | 55 ++++++++++++++++------------- lib/svtplay_dl/service/tv4play.py | 12 +++++- lib/svtplay_dl/service/urplay.py | 50 +++++++++++---------------- lib/svtplay_dl/service/viaplay.py | 21 +++++++++-- lib/svtplay_dl/subtitle/__init__.py | 19 +++++++--- 16 files changed, 214 insertions(+), 133 deletions(-) diff -Nru svtplay-dl-1.8/debian/changelog svtplay-dl-1.9.1/debian/changelog --- svtplay-dl-1.8/debian/changelog 2016-11-15 20:25:32.000000000 +0100 +++ svtplay-dl-1.9.1/debian/changelog 2017-02-01 16:20:00.000000000 +0100 @@ -1,3 +1,10 @@ +svtplay-dl (1.9.1-0.1) unstable; urgency=medium + + * Non-maintainer upload. + * New upstream version 1.9.1. Closes: #853772; LP: #1660733 + + -- Gunnar Hjalmarsson <[email protected]> Wed, 01 Feb 2017 16:20:00 +0100 + svtplay-dl (1.8-1) unstable; urgency=medium * New upstream version 1.8 diff -Nru svtplay-dl-1.8/debian/patches/debian-changes svtplay-dl-1.9.1/debian/patches/debian-changes --- svtplay-dl-1.8/debian/patches/debian-changes 2016-11-15 20:25:32.000000000 +0100 +++ svtplay-dl-1.9.1/debian/patches/debian-changes 2017-02-01 16:20:00.000000000 +0100 @@ -8,19 +8,19 @@ For full commit history and separated commits, see the packaging Git repository. ---- svtplay-dl-1.8.orig/Makefile -+++ svtplay-dl-1.8/Makefile +--- svtplay-dl-1.9.1.orig/Makefile ++++ svtplay-dl-1.9.1/Makefile @@ -4,7 +4,7 @@ all: svtplay-dl release clean_releasedir $(RELEASE_DIR) # These variables describe the latest release: --VERSION = 1.8 -+export VERSION = 1.8 +-VERSION = 1.9.1 ++export VERSION = 1.9.1 LATEST_RELEASE = $(VERSION) # If we build a new release, this is what it will be called: ---- svtplay-dl-1.8.orig/lib/Makefile -+++ svtplay-dl-1.8/lib/Makefile +--- svtplay-dl-1.9.1.orig/lib/Makefile ++++ svtplay-dl-1.9.1/lib/Makefile @@ -19,7 +19,9 @@ export PYFILES = $(sort $(addsuffix /*.p PYTHON ?= /usr/bin/env python diff -Nru svtplay-dl-1.8/lib/svtplay_dl/__init__.py svtplay-dl-1.9.1/lib/svtplay_dl/__init__.py --- svtplay-dl-1.8/lib/svtplay_dl/__init__.py 2016-11-14 23:53:49.000000000 +0100 +++ svtplay-dl-1.9.1/lib/svtplay_dl/__init__.py 2017-01-27 02:14:20.000000000 +0100 @@ -54,7 +54,7 @@ from svtplay_dl.service.vimeo import Vimeo from svtplay_dl.service.youplay import Youplay -__version__ = "1.8" +__version__ = "1.9.1" sites = [ Aftonbladet, @@ -152,6 +152,20 @@ self.remux = False self.silent_semi = False +def get_multiple_media(urls, options): + if options.output and os.path.isfile(options.output): + log.error("Output must be a directory if used with multiple URLs") + sys.exit(2) + elif options.output and not os.path.exists(options.output): + try: + os.makedirs(options.output) + except OSError as e: + log.error("%s: %s", e.strerror, e.filename) + return + + for url in urls: + get_media(url, copy.copy(options)) + def get_media(url, options): if "http" not in url[:4]: url = "http://%s" % url @@ -173,9 +187,9 @@ url = ensure_unicode(url) if options.all_episodes: - get_all_episodes(stream, options, url) + get_all_episodes(stream, copy.copy(options), url) else: - get_one_media(stream, options) + get_one_media(stream, copy.copy(options)) def get_all_episodes(stream, options, url): @@ -343,7 +357,7 @@ def main(): """ Main program """ - usage = "Usage: %prog [options] url" + usage = "Usage: %prog [options] [urls]" parser = OptionParser(usage=usage, version=__version__) parser.add_option("-o", "--output", metavar="OUTPUT", help="outputs to the given filename or folder") @@ -418,7 +432,7 @@ if not args: parser.print_help() sys.exit(0) - if len(args) != 1: + if len(args) < 1: parser.error("Incorrect number of arguments") if options.exclude: options.exclude = options.exclude.split(",") @@ -438,10 +452,13 @@ log.error("flexible-quality requires a quality") sys.exit(4) - url = args[0] + urls = args try: - get_media(url, options) + if len(urls) == 1: + get_media(urls[0], options) + else: + get_multiple_media(urls, options) except KeyboardInterrupt: print("") diff -Nru svtplay-dl-1.8/lib/svtplay_dl/output.py svtplay-dl-1.9.1/lib/svtplay_dl/output.py --- svtplay-dl-1.8/lib/svtplay_dl/output.py 2016-11-14 23:53:49.000000000 +0100 +++ svtplay-dl-1.9.1/lib/svtplay_dl/output.py 2017-01-27 02:14:20.000000000 +0100 @@ -154,7 +154,9 @@ options.output = "%s.%s" % (options.output, extention) if options.output_auto and ext: options.output = "%s.%s" % (options.output, extention) - if extention == "srt" and ext: + elif extention == "srt" and ext: + options.output = "%s.srt" % options.output[:options.output.rfind(ext.group(1))] + if ext and extention == "srt" and ext.group(1).split(".")[-1] in subtitlefiles: options.output = "%s.srt" % options.output[:options.output.rfind(ext.group(1))] log.info("Outfile: %s", options.output) if os.path.isfile(options.output) or \ diff -Nru svtplay-dl-1.8/lib/svtplay_dl/postprocess/__init__.py svtplay-dl-1.9.1/lib/svtplay_dl/postprocess/__init__.py --- svtplay-dl-1.8/lib/svtplay_dl/postprocess/__init__.py 2016-11-14 23:53:49.000000000 +0100 +++ svtplay-dl-1.9.1/lib/svtplay_dl/postprocess/__init__.py 2017-01-27 02:14:20.000000000 +0100 @@ -3,9 +3,10 @@ from random import sample import subprocess import os +import platform from svtplay_dl.log import log -from svtplay_dl.utils import which +from svtplay_dl.utils import which, is_py3 class postprocess(object): @@ -29,8 +30,13 @@ lines = block.strip('-').split('\n') txt = '\r\n'.join(lines[2:]) return txt + + if platform.system() == "Windows" and is_py3: + fd = open(self, encoding="utf8") + else: + fd = open(self) return list(map(parse_block, - open(self).read().strip().replace('\r', '').split('\n\n'))) + fd.read().strip().replace('\r', '').split('\n\n'))) def query(self): random_sentences = ' '.join(sample(parse(self),8)).replace('\r\n', '') @@ -40,8 +46,11 @@ try: r = post(url, data=dumps(payload), headers=headers, timeout=30) # Note: reasonable timeout i guess? svtplay-dl is mainly used while multitasking i presume, and it is heroku after all (fast enough) if r.status_code == codes.ok: - response = r.json() - return response['language'] + try: + response = r.json() + return response['language'] + except TypeError: + return 'und' else: log.error("Server error appeared. Setting language as undetermined.") return 'und' @@ -88,14 +97,14 @@ if self.stream.options.output.endswith('.mp4') is False: orig_filename = self.stream.options.output name, ext = os.path.splitext(orig_filename) - new_name = "{}.mp4".format(name) + new_name = u"{}.mp4".format(name) if self.merge_subtitle: - log.info("Muxing %s and merging its subtitle into %s", orig_filename, new_name) + log.info(u"Muxing %s and merging its subtitle into %s", orig_filename, new_name) else: - log.info("Muxing %s into %s", orig_filename, new_name) - - tempfile = "{}.temp".format(orig_filename) + log.info(u"Muxing %s into %s".format(orig_filename, new_name)) + + tempfile = u"{}.temp".format(orig_filename) arguments = ["-map", "0:v", "-map", "0:a", "-c", "copy", "-copyts", "-f", "mp4"] if ext == ".ts": arguments += ["-bsf:a", "aac_adtstoasc"] @@ -146,10 +155,10 @@ log.info("Merge audio, video and subtitle into %s", orig_filename) else: log.info("Merge audio and video into %s", orig_filename) - - tempfile = "{}.temp".format(orig_filename) + + tempfile = u"{}.temp".format(orig_filename) name = os.path.splitext(orig_filename)[0] - audio_filename = "{}.m4a".format(name) + audio_filename = u"{}.m4a".format(name) arguments = ["-c:v", "copy", "-c:a", "copy", "-f", "mp4"] cmd = [self.detect, "-i", orig_filename, "-i", audio_filename] diff -Nru svtplay-dl-1.8/lib/svtplay_dl/service/dplay.py svtplay-dl-1.9.1/lib/svtplay_dl/service/dplay.py --- svtplay-dl-1.8/lib/svtplay_dl/service/dplay.py 2016-11-14 23:53:49.000000000 +0100 +++ svtplay-dl-1.9.1/lib/svtplay_dl/service/dplay.py 2017-01-27 02:14:20.000000000 +0100 @@ -13,7 +13,7 @@ from svtplay_dl.subtitle import subtitle from svtplay_dl.utils.urllib import quote, urlparse from svtplay_dl.error import ServiceError -from svtplay_dl.utils import filenamify +from svtplay_dl.utils import filenamify, is_py2 from svtplay_dl.log import log class Dplay(Service): @@ -105,7 +105,13 @@ season = jsondata["data"][0]["season"] episode = jsondata["data"][0]["episode"] title = jsondata["data"][0]["title"] - return filenamify("%s.s%se%s.%s" % (show, season, episode, title)) + if is_py2: + show = filenamify(show).encode("latin1") + title = filenamify(title).encode("latin1") + else: + show = filenamify(show) + title = filenamify(title) + return filenamify("{}.s{:02d}e{:02d}.{}".format(show, int(season), int(episode), title)) def _login(self, options): parse = urlparse(self.url) diff -Nru svtplay-dl-1.8/lib/svtplay_dl/service/oppetarkiv.py svtplay-dl-1.9.1/lib/svtplay_dl/service/oppetarkiv.py --- svtplay-dl-1.8/lib/svtplay_dl/service/oppetarkiv.py 2016-11-14 23:53:49.000000000 +0100 +++ svtplay-dl-1.9.1/lib/svtplay_dl/service/oppetarkiv.py 2017-01-27 02:14:20.000000000 +0100 @@ -203,11 +203,8 @@ season = 1 else: season = int(match.group(2)) - if season < 10: - season = "0%s" % season - episode = int(match.group(3)) - if episode < 10: - episode = "0%s" % episode + season = "{:02d}".format(season) + episode = "{:02d}".format(int(match.group(3))) return "S%sE%s" % (season, episode) else: return None \ No newline at end of file diff -Nru svtplay-dl-1.8/lib/svtplay_dl/service/picsearch.py svtplay-dl-1.9.1/lib/svtplay_dl/service/picsearch.py --- svtplay-dl-1.8/lib/svtplay_dl/service/picsearch.py 2016-11-14 23:53:49.000000000 +0100 +++ svtplay-dl-1.9.1/lib/svtplay_dl/service/picsearch.py 2017-01-27 02:14:20.000000000 +0100 @@ -6,9 +6,8 @@ import copy from svtplay_dl.service import Service, OpenGraphThumbMixin -from svtplay_dl.fetcher.rtmp import RTMP -from svtplay_dl.fetcher.hds import hdsparse from svtplay_dl.fetcher.hls import hlsparse +from svtplay_dl.fetcher.http import HTTP from svtplay_dl.error import ServiceError from svtplay_dl.utils.urllib import urlparse @@ -17,6 +16,8 @@ supported_domains = ['dn.se', 'mobil.dn.se', 'di.se', 'csp.picsearch.com', 'csp.screen9.com'] def get(self): + self.backupapi = None + if self.exclude(): yield ServiceError("Excluding video") return @@ -33,32 +34,30 @@ if not isinstance(mediaid, str): mediaid = mediaid.group(1) - jsondata = self.http.request("get", "http://csp.picsearch.com/rest?jsonp=&eventParam=1&auth=%s&method=embed&mediaid=%s" % (ajax_auth.group(1), mediaid)).text + jsondata = self.http.request("get", "http://csp.screen9.com/player?eventParam=1&ajaxauth=%s&method=embed&mediaid=%s" % (ajax_auth.group(1), mediaid)).text jsondata = json.loads(jsondata) - if "playerconfig" not in jsondata["media"]: - yield ServiceError(jsondata["error"]) - return - if "live" in jsondata["media"]["playerconfig"]["clip"]: - self.options.live = jsondata["media"]["playerconfig"]["clip"] - playlist = jsondata["media"]["playerconfig"]["playlist"][1] - if "bitrates" in playlist: - files = playlist["bitrates"] - server = jsondata["media"]["playerconfig"]["plugins"]["bwcheck"]["netConnectionUrl"] - - for i in files: - self.options.other = "-y '%s'" % i["url"] - yield RTMP(copy.copy(self.options), server, i["height"]) - if "provider" in playlist: - if playlist["provider"] != "rtmp": - if "live" in playlist: - self.options.live = playlist["live"] - if playlist["url"].endswith(".f4m"): - streams = hdsparse(self.options, self.http.request("get", playlist["url"], params={"hdcore": "3.7.0"}), playlist["url"]) - if streams: - for n in list(streams.keys()): - yield streams[n] - if ".m3u8" in playlist["url"]: - streams = hlsparse(self.options, self.http.request("get", playlist["url"]), playlist["url"]) + + if "data" in jsondata: + if "live" in jsondata["data"]["publishing_status"]: + self.options.live = jsondata["data"]["publishing_status"]["live"] + playlist = jsondata["data"]["streams"] + for i in playlist: + if "application/x-mpegurl" in i: + streams = hlsparse(self.options, self.http.request("get", i["application/x-mpegurl"]), i["application/x-mpegurl"]) + if streams: + for n in list(streams.keys()): + yield streams[n] + if "video/mp4" in i: + yield HTTP(copy.copy(self.options), i["video/mp4"], 800) + + if self.backupapi: + res = self.http.get(self.backupapi.replace("i=", ""), params={"i": "object"}) + data = res.text.replace("ps.embedHandler(", "").replace('"");', '') + data = data[:data.rfind(",")] + jansson = json.loads(data) + for i in jansson["media"]["playerconfig"]["playlist"]: + if "provider" in i and i["provider"] == "httpstreaming": + streams = hlsparse(self.options, self.http.request("get", i["url"]), i["url"]) if streams: for n in list(streams.keys()): yield streams[n] @@ -70,16 +69,22 @@ if not match: match = re.search('screen9"[ ]*:[ ]*"([^"]+)"', self.get_urldata()) if not match: + match = re.search('data-auth="([^"]+)"', self.get_urldata()) + if not match: match = re.search('s.src="(https://csp-ssl.picsearch.com[^"]+|http://csp.picsearch.com/rest[^"]+)', self.get_urldata()) if match: data = self.http.request("get", match.group(1)) + self.backupapi = match.group(1) match = re.search(r'ajaxAuth": "([^"]+)"', data.text) if not match: match = re.search('iframe src="(//csp.screen9.com[^"]+)"', self.get_urldata()) if match: url = "http:%s" % match.group(1) data = self.http.request("get", url) + self.backupapi = url match = re.search(r"picsearch_ajax_auth = '([^']+)'", data.text) + if not match: + match = re.search(r"screen9_ajax_auth = '([^']+)'", data.text) return match @@ -92,6 +97,8 @@ if not match: match = re.search(r'data-id="([^"]+)"', self.get_urldata()) if not match: + match = re.search(r'data-videoid="([^"]+)"', self.get_urldata()) + if not match: match = re.search('s.src="(https://csp-ssl.picsearch.com[^"]+|http://csp.picsearch.com/rest[^"]+)', self.get_urldata()) if match: data = self.http.request("get", match.group(1)) diff -Nru svtplay-dl-1.8/lib/svtplay_dl/service/solidtango.py svtplay-dl-1.9.1/lib/svtplay_dl/service/solidtango.py --- svtplay-dl-1.8/lib/svtplay_dl/service/solidtango.py 2016-11-14 23:53:49.000000000 +0100 +++ svtplay-dl-1.9.1/lib/svtplay_dl/service/solidtango.py 2017-01-27 02:14:20.000000000 +0100 @@ -33,11 +33,19 @@ match = re.search('is_livestream: true', data) if match: self.options.live = True + match = re.search('isLivestream: true', data) + if match: + self.options.live = True match = re.search('html5_source: "([^"]+)"', data) + match2 = re.search('hlsURI: "([^"]+)"', data) if match: streams = hlsparse(self.options, self.http.request("get", match.group(1)), match.group(1)) for n in list(streams.keys()): yield streams[n] + elif match2: + streams = hlsparse(self.options, self.http.request("get", match2.group(1)), match2.group(1)) + for n in list(streams.keys()): + yield streams[n] else: parse = urlparse(self.url) url2 = "https://%s/api/v1/play/%s.xml" % (parse.netloc, parse.path[parse.path.rfind("/")+1:]) diff -Nru svtplay-dl-1.8/lib/svtplay_dl/service/svtplay.py svtplay-dl-1.9.1/lib/svtplay_dl/service/svtplay.py --- svtplay-dl-1.8/lib/svtplay_dl/service/svtplay.py 2016-11-14 23:53:49.000000000 +0100 +++ svtplay-dl-1.9.1/lib/svtplay_dl/service/svtplay.py 2017-01-27 02:14:20.000000000 +0100 @@ -46,20 +46,27 @@ yield ServiceError("Excluding video") return - if "subtitles" in janson["video"]: - for i in janson["video"]["subtitles"]: - if i["format"] == "WebSRT": + if "programVersionId" in janson["video"]: + vid = janson["video"]["programVersionId"] + else: + vid = janson["video"]["id"] + res = self.http.get("http://api.svt.se/videoplayer-api/video/{}".format(vid)) + janson = res.json() + + if "subtitleReferences" in janson: + for i in janson["subtitleReferences"]: + if i["format"] == "websrt" and "url" in i: yield subtitle(copy.copy(self.options), "wrst", i["url"]) - if "videoReferences" in janson["video"]: - if len(janson["video"]["videoReferences"]) == 0: + if "videoReferences" in janson: + if len(janson["videoReferences"]) == 0: yield ServiceError("Media doesn't have any associated videos (yet?)") return - for i in janson["video"]["videoReferences"]: + for i in janson["videoReferences"]: parse = urlparse(i["url"]) query = parse_qs(parse.query) - if i["playerType"] == "hls" or i["playerType"] == "ios": + if i["format"] == "hls": streams = hlsparse(self.options, self.http.request("get", i["url"]), i["url"]) if streams: for n in list(streams.keys()): @@ -71,7 +78,7 @@ if streams: for n in list(streams.keys()): yield streams[n] - if i["playerType"] == "playerType" or i["playerType"] == "flash": + if i["format"] == "hds": match = re.search(r"\/se\/secure\/", i["url"]) if not match: streams = hdsparse(self.options, self.http.request("get", i["url"], params={"hdcore": "3.7.0"}), i["url"]) @@ -85,7 +92,7 @@ if streams: for n in list(streams.keys()): yield streams[n] - if i["playerType"] == "dash264" or i["playerType"] == "dashhbbtv": + if i["format"] == "dash264" or i["format"] == "dashhbbtv": streams = dashparse(self.options, self.http.request("get", i["url"]), i["url"]) if streams: for n in list(streams.keys()): @@ -119,7 +126,7 @@ def _genre(self, jansson): videos = [] - for i in jansson["clusterPage"]["content"]["clips"]: + for i in jansson["clusterPage"]["clips"]: videos.append(i["contentUrl"]) return videos @@ -147,16 +154,16 @@ if re.search("/genre", parse.path): videos = self._genre(dataj) else: - items = dataj["videoTitlePage"]["realatedVideosTabs"] + items = dataj["videoTitlePage"]["relatedVideosTabs"] for i in items: if "sasong" in i["slug"]: for n in i["videos"]: - if n["url"] not in videos: - videos.append(n["url"]) + if n["contentUrl"] not in videos: + videos.append(n["contentUrl"]) if "senast" in i["slug"]: for n in i["videos"]: - if n["url"] not in videos: - videos.append(n["url"]) + if n["contentUrl"] not in videos: + videos.append(n["contentUrl"]) episodes = [urljoin("http://www.svtplay.se", x) for x in videos] else: @@ -175,8 +182,9 @@ def outputfilename(self, data, filename): directory = os.path.dirname(filename) - name = data["video"]["titlePagePath"] + name = filenamify(data["video"]["programTitle"]) other = filenamify(data["video"]["title"]) + if "programVersionId" in data["video"]: vid = str(data["video"]["programVersionId"]) else: @@ -188,6 +196,9 @@ if name == other: other = None + elif name == None: + name = other + other = None season = self.seasoninfo(data) title = name if season: @@ -202,16 +213,10 @@ output = title return output - def seasoninfo(self, data): - if "season" in data["video"]: - season = data["video"]["season"] - if season < 10: - season = "0%s" % season - episode = data["video"]["episodeNumber"] - - if episode < 10: - episode = "0%s" % episode + if "season" in data["video"] and data["video"]["season"]: + season = "{:02d}".format(data["video"]["season"]) + episode = "{:02d}".format(data["video"]["episodeNumber"]) if int(season) == 0 and int(episode) == 0: return None return "S%sE%s" % (season, episode) diff -Nru svtplay-dl-1.8/lib/svtplay_dl/service/tv4play.py svtplay-dl-1.9.1/lib/svtplay_dl/service/tv4play.py --- svtplay-dl-1.8/lib/svtplay_dl/service/tv4play.py 2016-11-14 23:53:49.000000000 +0100 +++ svtplay-dl-1.9.1/lib/svtplay_dl/service/tv4play.py 2017-01-27 02:14:20.000000000 +0100 @@ -120,7 +120,11 @@ def _get_show_info(self): show = self._get_showname(self.url) - data = self.http.request("get", "http://webapi.tv4play.se/play/video_assets?type=episode&is_live=false&platform=web&node_nids=%s&per_page=99999" % show).text + if self.options.live: + live = "true" + else: + live = "false" + data = self.http.request("get", "http://webapi.tv4play.se/play/video_assets?type=episode&is_live=%s&platform=web&node_nids=%s&per_page=99999" % (live, show)).text jsondata = json.loads(data) return jsondata @@ -129,8 +133,12 @@ page = 1 assets = page * 1000 run = True + if self.options.live: + live = "true" + else: + live = "false" while run: - data = self.http.request("get", "http://webapi.tv4play.se/play/video_assets?type=clips&is_live=false&platform=web&node_nids=%s&per_page=1000&page=%s" % (show, page)).text + data = self.http.request("get", "http://webapi.tv4play.se/play/video_assets?type=clips&is_live=%s&platform=web&node_nids=%s&per_page=1000&page=%s" % (live, show, page)).text jsondata = json.loads(data) for i in jsondata["results"]: if vid == i["id"]: diff -Nru svtplay-dl-1.8/lib/svtplay_dl/service/urplay.py svtplay-dl-1.9.1/lib/svtplay_dl/service/urplay.py --- svtplay-dl-1.8/lib/svtplay_dl/service/urplay.py 2016-11-14 23:53:49.000000000 +0100 +++ svtplay-dl-1.9.1/lib/svtplay_dl/service/urplay.py 2017-01-27 02:14:20.000000000 +0100 @@ -4,10 +4,9 @@ import re import json import copy -import xml.etree.ElementTree as ET from svtplay_dl.service import Service, OpenGraphThumbMixin -from svtplay_dl.utils.urllib import urljoin +from svtplay_dl.utils.urllib import urljoin, urlparse from svtplay_dl.fetcher.hls import hlsparse from svtplay_dl.log import log from svtplay_dl.error import ServiceError @@ -34,11 +33,16 @@ if len(jsondata["subtitles"]) > 0: for sub in jsondata["subtitles"]: if "label" in sub: + absurl = urljoin(self.url, sub["file"].split(",")[0]) + if absurl.endswith("vtt"): + subtype = "wrst" + else: + subtype = "tt" if self.options.get_all_subtitles: - yield subtitle(copy.copy(self.options), "tt", sub["file"].split(",")[0], "-" + filenamify(sub["label"])) + yield subtitle(copy.copy(self.options), subtype, absurl, "-" + filenamify(sub["label"])) else: - yield subtitle(copy.copy(self.options), "tt", sub["file"].split(",")[0]) - + yield subtitle(copy.copy(self.options), subtype, absurl) + if "streamer" in jsondata["streaming_config"]: basedomain = jsondata["streaming_config"]["streamer"]["redirect"] else: @@ -60,32 +64,20 @@ for n in list(streams.keys()): yield streams[n] - def scrape_episodes(self, options): - res = [] - for relurl in re.findall(r'<a class="puff tv video"\s+title="[^"]*"\s+href="([^"]*)"', - self.get_urldata()): - res.append(urljoin(self.url, relurl.replace("&", "&"))) - - for relurl in re.findall(r'<a class="card program"\s+href="([^"]*)"', - self.get_urldata()): - res.append(urljoin(self.url, relurl.replace("&", "&"))) - - if options.all_last != -1: - res = res[-options.all_last:] - - return res - def find_all_episodes(self, options): - match = re.search(r'<link rel="alternate" type="application/rss\+xml" [^>]*href="([^"]+)"', - self.get_urldata()) - if match is None: - log.info("Couldn't retrieve episode list as rss, trying to scrape") - return self.scrape_episodes(options) - - url = "http://urplay.se%s" % match.group(1).replace("&", "&") - xml = ET.XML(self.http.request("get", url).content) + parse = urlparse(self.url) + match = re.search("/program/\d+-(\w+)-", parse.path) + if not match: + log.error("Can't find any videos") + return None + keyword = match.group(1) + episodes = [] + all_links = re.findall('card-link" href="([^"]+)"', self.get_urldata()) + for i in all_links: + match = re.search("/program/\d+-(\w+)-", i) + if match and match.group(1) == keyword: + episodes.append(urljoin("http://urplay.se/", i)) - episodes = [x.text for x in xml.findall(".//item/link")] episodes_new = [] n = 0 for i in episodes: diff -Nru svtplay-dl-1.8/lib/svtplay_dl/service/viaplay.py svtplay-dl-1.9.1/lib/svtplay_dl/service/viaplay.py --- svtplay-dl-1.8/lib/svtplay_dl/service/viaplay.py 2016-11-14 23:53:49.000000000 +0100 +++ svtplay-dl-1.9.1/lib/svtplay_dl/service/viaplay.py 2017-01-27 02:14:20.000000000 +0100 @@ -142,9 +142,22 @@ self.options.output = title if dataj["sami_path"]: - yield subtitle(copy.copy(self.options), "sami", dataj["sami_path"]) + if dataj["sami_path"].endswith("vtt"): + subtype = "wrst" + else: + subtype = "sami" + yield subtitle(copy.copy(self.options), subtype, dataj["sami_path"]) + if dataj["subtitles_webvtt"]: + yield subtitle(copy.copy(self.options), "wrst", dataj["subtitles_webvtt"]) if dataj["subtitles_for_hearing_impaired"]: - yield subtitle(copy.copy(self.options), "sami", dataj["subtitles_for_hearing_impaired"]) + if dataj["subtitles_for_hearing_impaired"].endswith("vtt"): + subtype = "wrst" + else: + subtype = "sami" + if self.options.get_all_subtitles: + yield subtitle(copy.copy(self.options), subtype, dataj["subtitles_for_hearing_impaired"],"-SDH") + else: + yield subtitle(copy.copy(self.options), subtype, dataj["subtitles_for_hearing_impaired"]) if streamj["streams"]["medium"]: filename = streamj["streams"]["medium"] @@ -200,7 +213,7 @@ episode = dataj["format_position"]["episode"] name = filenamify(program) if season: - name = "%s.s%s" % (name, season) + name = "{}.s{:02d}".format(name, int(season)) if episode: - name = "%se%s" % (name, episode) + name = "{}e{:02d}".format(name, int(episode)) return name \ No newline at end of file diff -Nru svtplay-dl-1.8/lib/svtplay_dl/subtitle/__init__.py svtplay-dl-1.9.1/lib/svtplay_dl/subtitle/__init__.py --- svtplay-dl-1.8/lib/svtplay_dl/subtitle/__init__.py 2016-11-14 23:53:49.000000000 +0100 +++ svtplay-dl-1.9.1/lib/svtplay_dl/subtitle/__init__.py 2017-01-27 02:14:20.000000000 +0100 @@ -2,10 +2,9 @@ import json import re from svtplay_dl.log import log -from svtplay_dl.utils import is_py2, is_py3, decode_html_entities +from svtplay_dl.utils import is_py2, is_py3, decode_html_entities, HTTP from svtplay_dl.utils.io import StringIO from svtplay_dl.output import output -from requests import Session from requests import __build__ as requests_version import platform @@ -16,8 +15,9 @@ self.subtitle = None self.options = options self.subtype = subtype - self.http = Session() + self.http = HTTP(options) self.subfix = subfix + self.bom = False def download(self): subdata = self.http.request("get", self.url, cookies=self.options.cookies) @@ -26,7 +26,10 @@ return data = None - + if "mtgx" in self.url and subdata.content[:3] == b"\xef\xbb\xbf": + subdata.encoding = "utf-8" + self.bom = True + if self.subtype == "tt": data = self.tt(subdata) if self.subtype == "json": @@ -191,12 +194,18 @@ number = 0 block = 0 subnr = False + if self.bom: + ssubdata.read(1) for i in ssubdata.readlines(): match = re.search(r"^[\r\n]+", i) match2 = re.search(r"([\d:\.]+ --> [\d:\.]+)", i) match3 = re.search(r"^(\d+)\s", i) if i[:6] == "WEBVTT": - pass + continue + elif "X-TIMESTAMP" in i: + continue + elif match and number_b == 1 and self.bom: + continue elif match and number_b > 1: block = 0 srt += "\n" diff -Nru svtplay-dl-1.8/Makefile svtplay-dl-1.9.1/Makefile --- svtplay-dl-1.8/Makefile 2016-11-14 23:53:49.000000000 +0100 +++ svtplay-dl-1.9.1/Makefile 2017-01-27 02:14:20.000000000 +0100 @@ -4,7 +4,7 @@ release clean_releasedir $(RELEASE_DIR) # These variables describe the latest release: -VERSION = 1.8 +VERSION = 1.9.1 LATEST_RELEASE = $(VERSION) # If we build a new release, this is what it will be called: diff -Nru svtplay-dl-1.8/README.rst svtplay-dl-1.9.1/README.rst --- svtplay-dl-1.8/README.rst 2016-11-14 23:53:49.000000000 +0100 +++ svtplay-dl-1.9.1/README.rst 2017-01-27 02:14:20.000000000 +0100 @@ -30,6 +30,11 @@ You can download windows binaries from `svtplay-dl.se`_ +If you want to build your own windows binaries +Install pyinstaller 3.1.1 (https://pypi.python.org/pypi/PyInstaller/3.1.1) +Follow the steps listed under From source below +Run scripts\pyinstaller.exe --noupx --onefile c:\path\to\svtplay-dl-clone\spec\svtplay-dl.spec (where you replace the path with the correct one) + Other systems with python ~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -107,23 +112,19 @@ - svd.se - sverigesradio.se - svtplay.se -- tv10play.se -- tv3play.dk +- viafree.se (former tv3play.se, tv6play.se, tv8play.se, tv10play.se) +- viafree.dk (former tv3play.dk) +- viafree.se (former tv3play.no, viasat4play.no) - tv3play.ee - tv3play.lt - tv3play.lv -- tv3play.no -- tv3play.se - tv4.se - tv4play.se -- tv6play.se -- tv8play.se - twitch.tv - ur.se - urplay.se - vg.no - viagame.com -- viasat4play.no License -------
signature.asc
Description: PGP signature

