Repository: streamlink/streamlink

Issue:
Playtv uk
playtv.fr working fine is there any possibility to run http://uk.play.tv/    looks like both sites france and uk owned by same  company. As streamlink support tvplay.fr. hope u get support for uk playtv.
http://uk.play.tv/live-tv/363/pick-tv/
http://uk.play.tv/live-tv/752/itv4-1/
http://uk.play.tv/live-tv/1106/itv3-1/
http://uk.play.tv/live-tv/1105/itv-1/
Playtv uk
playtv.fr working fine is there any possibility to run http://uk.play.tv/    looks like both sites france and uk owned by same  company. As streamlink support tvplay.fr. hope u get support for uk playtv.
http://uk.play.tv/live-tv/363/pick-tv/
http://uk.play.tv/live-tv/752/itv4-1/
http://uk.play.tv/live-tv/1106/itv3-1/
http://uk.play.tv/live-tv/1105/itv-1/


Discussion:
This doesn't meet the plugin request template requirements and I believe you were notified of this before on another issue, so why are you not using the template and including the required information?
@gravyboat i m happy to do it mate. any donation link here. and please if u add link of template i m happy to do it through that process. regards.
All of these streams are just embedded, just use the source website.
This doesn't meet the plugin request template requirements and I believe you were notified of this before on another issue, so why are you not using the template and including the required information?
@gravyboat i m happy to do it mate. any donation link here. and please if u add link of template i m happy to do it through that process. regards.
All of these streams are just embedded, just use the source website.

Resolving patch:
diff --git a/src/streamlink/plugins/playtv.py b/src/streamlink/plugins/playtv.py
--- a/src/streamlink/plugins/playtv.py
+++ b/src/streamlink/plugins/playtv.py
@@ -1,3 +1,5 @@
+import base64
+import json
 import re
 
 from streamlink.plugin import Plugin
@@ -5,11 +7,17 @@
 from streamlink.stream import HDSStream, HLSStream
 
 
+def jwt_decode(token):
+     info, payload, sig = token.split(".")
+     data = base64.urlsafe_b64decode(payload + '=' * (-len(payload) % 4))
+     return json.loads(data)
+
+
 class PlayTV(Plugin):
-    FORMATS_URL = 'http://playtv.fr/player/initialize/{0}/'
-    API_URL = 'http://playtv.fr/player/play/{0}/?format={1}&language={2}&bitrate={3}'
+    FORMATS_URL = 'https://playtv.fr/player/initialize/{0}/'
+    API_URL = 'https://playtv.fr/player/play/{0}/?format={1}&language={2}&bitrate={3}'
 
-    _url_re = re.compile(r'http://(?:playtv\.fr/television|play\.tv/live-tv/\d+)/(?P<channel>[^/]+)/?')
+    _url_re = re.compile(r'https?://(?:playtv\.fr/television|(:?\w+\.)?play\.tv/live-tv/\d+)/(?P<channel>[^/]+)/?')
 
     _formats_schema = validate.Schema({
         'streams': validate.any(
@@ -27,9 +35,13 @@ class PlayTV(Plugin):
             }
         )
     })
-    _api_schema = validate.Schema({
-        'url': validate.url()
-    })
+
+    _api_schema = validate.Schema(
+        validate.transform(lambda x: jwt_decode(x)),
+        {
+            'url': validate.url()
+        }
+    )
 
     @classmethod
     def can_handle_url(cls, url):
@@ -57,7 +69,7 @@ def _get_streams(self):
                         continue
                     api_url = self.API_URL.format(channel, protocol, language, bitrate['value'])
                     res = self.session.http.get(api_url)
-                    video_url = self.session.http.json(res, schema=self._api_schema)['url']
+                    video_url = self._api_schema.validate(res.text)['url']
                     bs = '{0}k'.format(bitrate['value'])
 
                     if protocol == 'hls':


Test patch: