Repository: streamlink/streamlink
Pull request #2646 (2019-10-03 12:58:11)

plugins.zattoo: _url_re update for some new urls
closes https://github.com/streamlink/streamlink/issues/2623


Patch:
diff --git a/src/streamlink/plugins/zattoo.py b/src/streamlink/plugins/zattoo.py
index c4f726a1..e04be31b 100644
--- a/src/streamlink/plugins/zattoo.py
+++ b/src/streamlink/plugins/zattoo.py
@@ -30,7 +30,7 @@ class Zattoo(Plugin):
     TIME_CONTROL = 60 * 60 * 2
     TIME_SESSION = 60 * 60 * 24 * 30
 
-    _url_re = re.compile(r'''
+    _url_re = re.compile(r'''(?x)
         https?://
         (?P<base_url>
             (?:(?:
@@ -49,13 +49,19 @@ class Zattoo(Plugin):
             |www\.meinewelt\.cc
         )/
         (?:
-            (?:ondemand/)?(?:watch/(?:[^/\s]+)(?:/[^/]+/(?P<recording_id>\d+)))
+            (?:
+                recordings\?recording=
+                |
+                (?:ondemand/)?(?:watch/(?:[^/\s]+)(?:/[^/]+/))
+            )(?P<recording_id>\d+)
             |
-            watch/(?P<channel>[^/\s]+)
+            (?:
+                (?:live/|watch/)|(?:channels(?:/\w+)?|guide)\?channel=
+            )(?P<channel>[^/\s]+)
             |
-            ondemand/watch/(?P<vod_id>[^-]+)-
+            ondemand(?:\?video=|/watch/)(?P<vod_id>[^-]+)
         )
-        ''', re.VERBOSE)
+        ''')
 
     _app_token_re = re.compile(r"""window\.appToken\s+=\s+'([^']+)'""")
 
@@ -127,10 +133,8 @@ class Zattoo(Plugin):
         self._uuid = self._session_attributes.get('uuid')
         self._authed = (self._session_attributes.get('power_guide_hash')
                         and self._uuid
-                        and self.session.http.cookies.get(
-                                'pzuid', domain=self.domain)
-                        and self.session.http.cookies.get(
-                                'beaker.session.id', domain=self.domain)
+                        and self.session.http.cookies.get('pzuid', domain=self.domain)
+                        and self.session.http.cookies.get('beaker.session.id', domain=self.domain)
                         )
         self._session_control = self._session_attributes.get('session_control',
                                                              False)


Test patch:
diff --git a/tests/plugins/test_zattoo.py b/tests/plugins/test_zattoo.py
index cc9360e4..ce32b6ea 100644
--- a/tests/plugins/test_zattoo.py
+++ b/tests/plugins/test_zattoo.py
@@ -26,12 +26,18 @@ class TestPluginZattoo(unittest.TestCase):
         # zattoo live
         self.assertTrue(Zattoo.can_handle_url('https://zattoo.com/watch/daserste'))
         self.assertTrue(Zattoo.can_handle_url('https://zattoo.com/watch/zdf'))
+        self.assertTrue(Zattoo.can_handle_url('https://zattoo.com/live/zdf'))
+        self.assertTrue(Zattoo.can_handle_url('https://zattoo.com/channels?channel=daserste'))
+        self.assertTrue(Zattoo.can_handle_url('https://zattoo.com/channels/favorites?channel=zdf'))
+        self.assertTrue(Zattoo.can_handle_url('https://zattoo.com/channels/zattoo?channel=zdf'))
         # zattoo vod
         self.assertTrue(Zattoo.can_handle_url('https://zattoo.com/ondemand/watch/ibR2fpisWFZGvmPBRaKnFnuT-alarm-am-airport'))
         self.assertTrue(Zattoo.can_handle_url('https://zattoo.com/ondemand/watch/G8S7JxcewY2jEwAgMzvFWK8c-berliner-schnauzen'))
+        self.assertTrue(Zattoo.can_handle_url('https://zattoo.com/ondemand?video=x4hUTiCv4FLAA72qLvahiSFp'))
         # zattoo recording
         self.assertTrue(Zattoo.can_handle_url('https://zattoo.com/ondemand/watch/srf_zwei/110223896-die-schweizermacher/52845783/1455130800000/1455137700000/6900000'))
         self.assertTrue(Zattoo.can_handle_url('https://zattoo.com/watch/tve/130920738-viaje-al-centro-de-la-tele/96847859/1508777100000/1508779800000/0'))
+        self.assertTrue(Zattoo.can_handle_url('https://zattoo.com/recordings?recording=186466965'))
 
     def test_can_handle_url_negative(self):
         # shouldn't match