prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <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/
  
  </issue>
  <code>
  [start of src/streamlink/plugins/playtv.py]
  1 import re
  2 
  3 from streamlink.plugin import Plugin
  4 from streamlink.plugin.api import validate
  5 from streamlink.stream import HDSStream, HLSStream
  6 
  7 
  8 class PlayTV(Plugin):
  9     FORMATS_URL = 'http://playtv.fr/player/initialize/{0}/'
  10     API_URL = 'http://playtv.fr/player/play/{0}/?format={1}&language={2}&bitrate={3}'
  11 
  12     _url_re = re.compile(r'http://(?:playtv\.fr/television|play\.tv/live-tv/\d+)/(?P<channel>[^/]+)/?')
  13 
  14     _formats_schema = validate.Schema({
  15         'streams': validate.any(
  16             [],
  17             {
  18                 validate.text: validate.Schema({
  19                     validate.text: {
  20                         'bitrates': validate.all([
  21                             validate.Schema({
  22                                 'value': int
  23                             })
  24                         ])
  25                     }
  26                 })
  27             }
  28         )
  29     })
  30     _api_schema = validate.Schema({
  31         'url': validate.url()
  32     })
  33 
  34     @classmethod
  35     def can_handle_url(cls, url):
  36         return PlayTV._url_re.match(url)
  37 
  38     def _get_streams(self):
  39         match = self._url_re.match(self.url)
  40         channel = match.group('channel')
  41 
  42         res = self.session.http.get(self.FORMATS_URL.format(channel))
  43         streams = self.session.http.json(res, schema=self._formats_schema)['streams']
  44         if streams == []:
  45             self.logger.error('Channel may be geo-restricted, not directly provided by PlayTV or not freely available')
  46             return
  47 
  48         for language in streams:
  49             for protocol, bitrates in list(streams[language].items()):
  50                 # - Ignore non-supported protocols (RTSP, DASH)
  51                 # - Ignore deprecated Flash (RTMPE/HDS) streams (PlayTV doesn't provide anymore a Flash player)
  52                 if protocol in ['rtsp', 'flash', 'dash', 'hds']:
  53                     continue
  54 
  55                 for bitrate in bitrates['bitrates']:
  56                     if bitrate['value'] == 0:
  57                         continue
  58                     api_url = self.API_URL.format(channel, protocol, language, bitrate['value'])
  59                     res = self.session.http.get(api_url)
  60                     video_url = self.session.http.json(res, schema=self._api_schema)['url']
  61                     bs = '{0}k'.format(bitrate['value'])
  62 
  63                     if protocol == 'hls':
  64                         for _, stream in HLSStream.parse_variant_playlist(self.session, video_url).items():
  65                             yield bs, stream
  66                     elif protocol == 'hds':
  67                         for _, stream in HDSStream.parse_manifest(self.session, video_url).items():
  68                             yield bs, stream
  69 
  70 
  71 __plugin__ = PlayTV
  72
  [end of src/streamlink/plugins/playtv.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: 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 @@
               }
           )
       })
  -    _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 @@
                           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':
  
verification_info: {"golden_diff": "diff --git a/src/streamlink/plugins/playtv.py b/src/streamlink/plugins/playtv.py\n--- a/src/streamlink/plugins/playtv.py\n+++ b/src/streamlink/plugins/playtv.py\n@@ -1,3 +1,5 @@\n+import base64\n+import json\n import re\n \n from streamlink.plugin import Plugin\n@@ -5,11 +7,17 @@\n from streamlink.stream import HDSStream, HLSStream\n \n \n+def jwt_decode(token):\n+     info, payload, sig = token.split(\".\")\n+     data = base64.urlsafe_b64decode(payload + '=' * (-len(payload) % 4))\n+     return json.loads(data)\n+\n+\n class PlayTV(Plugin):\n-    FORMATS_URL = 'http://playtv.fr/player/initialize/{0}/'\n-    API_URL = 'http://playtv.fr/player/play/{0}/?format={1}&language={2}&bitrate={3}'\n+    FORMATS_URL = 'https://playtv.fr/player/initialize/{0}/'\n+    API_URL = 'https://playtv.fr/player/play/{0}/?format={1}&language={2}&bitrate={3}'\n \n-    _url_re = re.compile(r'http://(?:playtv\\.fr/television|play\\.tv/live-tv/\\d+)/(?P<channel>[^/]+)/?')\n+    _url_re = re.compile(r'https?://(?:playtv\\.fr/television|(:?\\w+\\.)?play\\.tv/live-tv/\\d+)/(?P<channel>[^/]+)/?')\n \n     _formats_schema = validate.Schema({\n         'streams': validate.any(\n@@ -27,9 +35,13 @@\n             }\n         )\n     })\n-    _api_schema = validate.Schema({\n-        'url': validate.url()\n-    })\n+\n+    _api_schema = validate.Schema(\n+        validate.transform(lambda x: jwt_decode(x)),\n+        {\n+            'url': validate.url()\n+        }\n+    )\n \n     @classmethod\n     def can_handle_url(cls, url):\n@@ -57,7 +69,7 @@\n                         continue\n                     api_url = self.API_URL.format(channel, protocol, language, bitrate['value'])\n                     res = self.session.http.get(api_url)\n-                    video_url = self.session.http.json(res, schema=self._api_schema)['url']\n+                    video_url = self._api_schema.validate(res.text)['url']\n                     bs = '{0}k'.format(bitrate['value'])\n \n                     if protocol == 'hls':\n", "issue": "Playtv uk\nplaytv.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.\r\nhttp://uk.play.tv/live-tv/363/pick-tv/\r\nhttp://uk.play.tv/live-tv/752/itv4-1/\r\nhttp://uk.play.tv/live-tv/1106/itv3-1/\r\nhttp://uk.play.tv/live-tv/1105/itv-1/\nPlaytv uk\nplaytv.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.\r\nhttp://uk.play.tv/live-tv/363/pick-tv/\r\nhttp://uk.play.tv/live-tv/752/itv4-1/\r\nhttp://uk.play.tv/live-tv/1106/itv3-1/\r\nhttp://uk.play.tv/live-tv/1105/itv-1/\n", "before_files": [{"content": "import re\n\nfrom streamlink.plugin import Plugin\nfrom streamlink.plugin.api import validate\nfrom streamlink.stream import HDSStream, HLSStream\n\n\nclass PlayTV(Plugin):\n    FORMATS_URL = 'http://playtv.fr/player/initialize/{0}/'\n    API_URL = 'http://playtv.fr/player/play/{0}/?format={1}&language={2}&bitrate={3}'\n\n    _url_re = re.compile(r'http://(?:playtv\\.fr/television|play\\.tv/live-tv/\\d+)/(?P<channel>[^/]+)/?')\n\n    _formats_schema = validate.Schema({\n        'streams': validate.any(\n            [],\n            {\n                validate.text: validate.Schema({\n                    validate.text: {\n                        'bitrates': validate.all([\n                            validate.Schema({\n                                'value': int\n                            })\n                        ])\n                    }\n                })\n            }\n        )\n    })\n    _api_schema = validate.Schema({\n        'url': validate.url()\n    })\n\n    @classmethod\n    def can_handle_url(cls, url):\n        return PlayTV._url_re.match(url)\n\n    def _get_streams(self):\n        match = self._url_re.match(self.url)\n        channel = match.group('channel')\n\n        res = self.session.http.get(self.FORMATS_URL.format(channel))\n        streams = self.session.http.json(res, schema=self._formats_schema)['streams']\n        if streams == []:\n            self.logger.error('Channel may be geo-restricted, not directly provided by PlayTV or not freely available')\n            return\n\n        for language in streams:\n            for protocol, bitrates in list(streams[language].items()):\n                # - Ignore non-supported protocols (RTSP, DASH)\n                # - Ignore deprecated Flash (RTMPE/HDS) streams (PlayTV doesn't provide anymore a Flash player)\n                if protocol in ['rtsp', 'flash', 'dash', 'hds']:\n                    continue\n\n                for bitrate in bitrates['bitrates']:\n                    if bitrate['value'] == 0:\n                        continue\n                    api_url = self.API_URL.format(channel, protocol, language, bitrate['value'])\n                    res = self.session.http.get(api_url)\n                    video_url = self.session.http.json(res, schema=self._api_schema)['url']\n                    bs = '{0}k'.format(bitrate['value'])\n\n                    if protocol == 'hls':\n                        for _, stream in HLSStream.parse_variant_playlist(self.session, video_url).items():\n                            yield bs, stream\n                    elif protocol == 'hds':\n                        for _, stream in HDSStream.parse_manifest(self.session, video_url).items():\n                            yield bs, stream\n\n\n__plugin__ = PlayTV\n", "path": "src/streamlink/plugins/playtv.py"}]}