Subject: Collected Debian patches for svtplay-dl
Author: Olof Johansson <olof@ethup.se>

The svtplay-dl package is maintained in Git rather than maintaining
patches as separate files, and separating the patches doesn't seem to
be worth the effort.  They are therefore all included in this single
Debian patch.

For full commit history and separated commits, see the packaging Git
repository.
--- svtplay-dl-0.9.2014.08.28.orig/Makefile
+++ svtplay-dl-0.9.2014.08.28/Makefile
@@ -27,7 +27,7 @@ PYLINT_OPTS = --report=no -d I -d C -d R
 
 # If you don't have a python3 environment (e.g. mock for py3 and
 # nosetests3), you can remove the -3 flag.
-TEST_OPTS = -2 -3
+TEST_OPTS ?= -2 -3
 
 install: svtplay-dl $(MANFILE)
 	install -d $(DESTDIR)$(BINDIR)
--- svtplay-dl-0.9.2014.08.28.orig/lib/svtplay_dl/fetcher/hls.py
+++ svtplay-dl-0.9.2014.08.28/lib/svtplay_dl/fetcher/hls.py
@@ -85,7 +85,7 @@ class HLS(VideoRetriever):
         if hasattr(file_d, "read") is False:
             return
 
-        n = 0
+        n = 1
         eta = ETA(len(files))
         for i in files:
             item = _get_full_url(i[0], self.url)
--- svtplay-dl-0.9.2014.08.28.orig/lib/svtplay_dl/service/picsearch.py
+++ svtplay-dl-0.9.2014.08.28/lib/svtplay_dl/service/picsearch.py
@@ -12,7 +12,7 @@ from svtplay_dl.fetcher.rtmp import RTMP
 from svtplay_dl.log import log
 
 class Picsearch(Service, OpenGraphThumbMixin):
-    supported_domains = ['dn.se']
+    supported_domains = ['dn.se', 'mobil.dn.se']
 
     def get(self, options):
         data = self.get_urldata()
--- svtplay-dl-0.9.2014.08.28.orig/lib/svtplay_dl/service/tv4play.py
+++ svtplay-dl-0.9.2014.08.28/lib/svtplay_dl/service/tv4play.py
@@ -33,15 +33,15 @@ class Tv4play(Service, OpenGraphThumbMix
                 log.error("Can't find video file")
                 sys.exit(2)
         else:
-            match = re.search(r"-(\d+)$", self.url)
+            match = re.search(r"\"vid\":\"(\d+)\",", self.get_urldata())
             if match:
                 vid = match.group(1)
             else:
-                match = re.search(r"\"vid\":\"(\d+)\",", self.get_urldata())
+                match = re.search(r"-(\d+)$", self.url)
                 if match:
                     vid = match.group(1)
                 else:
-                    log.error("Can't find video file")
+                    log.error("Can't find video id")
                     sys.exit(2)
 
         url = "http://premium.tv4play.se/api/web/asset/%s/play" % vid
@@ -107,7 +107,9 @@ class Tv4play(Service, OpenGraphThumbMix
 
     def find_all_episodes(self, options):
         parse =  urlparse(self.url)
-        show = quote_plus(parse.path[parse.path.find("/", 1)+1:])
+        show = parse.path[parse.path.find("/", 1)+1:]
+        if not re.search("%", show):
+            show = quote_plus(show)
         data = get_http_data("http://webapi.tv4play.se/play/video_assets?type=episode&is_live=false&platform=web&node_nids=%s&per_page=99999" % show)
         jsondata = json.loads(data)
         episodes = []
--- svtplay-dl-0.9.2014.08.28.orig/lib/svtplay_dl/service/viaplay.py
+++ svtplay-dl-0.9.2014.08.28/lib/svtplay_dl/service/viaplay.py
@@ -69,7 +69,8 @@ class Viaplay(Service, OpenGraphThumbMix
             if live == "true":
                 options.live = True
 
-        yield subtitle_sami(xml.find("Product").find("SamiFile").text)
+        if xml.find("Product").find("SamiFile").text:
+            yield subtitle_sami(xml.find("Product").find("SamiFile").text)
 
         # Fulhack.. expose error code from get_http_data.
         filename = xml.find("Product").find("Videos").find("Video").find("Url").text
