Repository: streamlink/streamlink
Pull request #2887 (2020-04-12 06:25:57)

plugins.zattoo: fix app token and new recording URL
closes https://github.com/streamlink/streamlink/issues/2725
closes https://github.com/streamlink/streamlink/issues/2885
closes https://github.com/streamlink/streamlink/issues/2886

codecov[bot]: # [Codecov](https://codecov.io/gh/streamlink/streamlink/pull/2887?src=pr&el=h1) Report
> Merging [#2887](https://codecov.io/gh/streamlink/streamlink/pull/2887?src=pr&el=desc) into [master](https://codecov.io/gh/streamlink/streamlink/commit/2007b32102db68b738c655d382976e55d0d686c3&el=desc) will **decrease** coverage by `0.01%`.
> The diff coverage is `0.00%`.


```diff
@@            Coverage Diff             @@
##           master    #2887      +/-   ##
==========================================
- Coverage   52.68%   52.66%   -0.02%     
==========================================
  Files         250      250              
  Lines       15701    15704       +3     
==========================================
- Hits         8272     8271       -1     
- Misses       7429     7433       +4     
```

gravyboat: Thanks @back-to.

Patch:
diff --git a/src/streamlink/plugins/zattoo.py b/src/streamlink/plugins/zattoo.py
index e04be31b..56404b2e 100644
--- a/src/streamlink/plugins/zattoo.py
+++ b/src/streamlink/plugins/zattoo.py
@@ -50,7 +50,7 @@ class Zattoo(Plugin):
         )/
         (?:
             (?:
-                recordings\?recording=
+                recording(?:s\?recording=|/)
                 |
                 (?:ondemand/)?(?:watch/(?:[^/\s]+)(?:/[^/]+/))
             )(?P<recording_id>\d+)
@@ -155,7 +155,11 @@ class Zattoo(Plugin):
 
         # a new session is required for the app_token
         self.session.http.cookies = cookiejar_from_dict({})
-        res = self.session.http.get(self.base_url)
+        if self.base_url == 'https://zattoo.com':
+            app_token_url = 'https://zattoo.com/int/'
+        else:
+            app_token_url = self.base_url
+        res = self.session.http.get(app_token_url)
         match = self._app_token_re.search(res.text)
 
         app_token = match.group(1)


Test patch:
diff --git a/tests/plugins/test_zattoo.py b/tests/plugins/test_zattoo.py
index fe0adbab..2af55783 100644
--- a/tests/plugins/test_zattoo.py
+++ b/tests/plugins/test_zattoo.py
@@ -39,15 +39,17 @@ class TestPluginZattoo(unittest.TestCase):
             "https://zattoo.com/ondemand/watch/srf_zwei/110223896-die-schweizermacher/52845783/1455130800000"
             + "/1455137700000/6900000",
             "https://zattoo.com/watch/tve/130920738-viaje-al-centro-de-la-tele/96847859/1508777100000/1508779800000/0",
+            "https://zattoo.com/recording/193074536",
             "https://zattoo.com/recordings?recording=186466965"
         ]
         for url in should_match:
-            self.assertTrue(Zattoo.can_handle_url(url))
+            self.assertTrue(Zattoo.can_handle_url(url), url)
 
+    def test_can_handle_url_negative(self):
         should_not_match = [
             "https://ewe.de",
             "https://netcologne.de",
             "https://zattoo.com"
         ]
         for url in should_not_match:
-            self.assertFalse(Zattoo.can_handle_url(url))
+            self.assertFalse(Zattoo.can_handle_url(url), url)