prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  plugins.atresplayer: Live streams is not working.
  ### Checklist
  
  - [X] This is a plugin issue and not a different kind of issue
  - [X] [I have read the contribution guidelines](https://github.com/streamlink/streamlink/blob/master/CONTRIBUTING.md#contributing-to-streamlink)
  - [X] [I have checked the list of open and recently closed plugin issues](https://github.com/streamlink/streamlink/issues?q=is%3Aissue+label%3A%22plugin+issue%22)
  - [X] [I have checked the commit log of the master branch](https://github.com/streamlink/streamlink/commits/master)
  
  ### Streamlink version
  
  Latest stable release
  
  ### Description
  
  As for today, Atresplayer live streams is not working.
  
  ### Debug log
  
  ```text
  [cli][debug] OS:         Windows 10
  [cli][debug] Python:     3.10.6
  [cli][debug] Streamlink: 4.3.0
  [cli][debug] Dependencies:
  [cli][debug]  isodate: 0.6.1
  [cli][debug]  lxml: 4.9.1
  [cli][debug]  pycountry: 22.3.5
  [cli][debug]  pycryptodome: 3.15.0
  [cli][debug]  PySocks: 1.7.1
  [cli][debug]  requests: 2.28.1
  [cli][debug]  websocket-client: 1.3.3
  [cli][debug] Arguments:
  [cli][debug]  url=https://www.atresplayer.com/directos/antena3/
  [cli][debug]  stream=['best']
  [cli][debug]  --loglevel=debug
  [cli][debug]  --hls-live-edge=1
  [cli][debug]  --ffmpeg-ffmpeg=C:\Program Files\Streamlink\ffmpeg\ffmpeg.exe
  [cli][info] Found matching plugin atresplayer for URL https://www.atresplayer.com/directos/antena3/
  error: Unable to validate response text: ValidationError(NoneOrAllSchema):
    ValidationError(type):
      Type of <generator object search_dict at 0x000002C64BA79930> should be list, but is generator
  ```
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `src/streamlink/plugins/atresplayer.py`
  Content:
  ```
  1 """
  2 $description Spanish live TV channels from Atresmedia Television, including Antena 3 and laSexta.
  3 $url atresplayer.com
  4 $type live
  5 $region Spain
  6 """
  7 
  8 import logging
  9 import re
  10 
  11 from streamlink.plugin import Plugin, pluginmatcher
  12 from streamlink.plugin.api import validate
  13 from streamlink.stream.dash import DASHStream
  14 from streamlink.stream.hls import HLSStream
  15 from streamlink.utils.data import search_dict
  16 from streamlink.utils.url import update_scheme
  17 
  18 log = logging.getLogger(__name__)
  19 
  20 
  21 @pluginmatcher(re.compile(
  22     r"https?://(?:www\.)?atresplayer\.com/"
  23 ))
  24 class AtresPlayer(Plugin):
  25     def _get_streams(self):
  26         self.url = update_scheme("https://", self.url)
  27 
  28         api_url = self.session.http.get(self.url, schema=validate.Schema(
  29             re.compile(r"""window.__PRELOADED_STATE__\s*=\s*({.*?});""", re.DOTALL),
  30             validate.none_or_all(
  31                 validate.get(1),
  32                 validate.parse_json(),
  33                 validate.transform(search_dict, key="href"),
  34                 [validate.url()],
  35                 validate.get(0),
  36             ),
  37         ))
  38         if not api_url:
  39             return
  40         log.debug(f"API URL: {api_url}")
  41 
  42         player_api_url = self.session.http.get(api_url, schema=validate.Schema(
  43             validate.parse_json(),
  44             validate.transform(search_dict, key="urlVideo"),
  45         ))
  46 
  47         stream_schema = validate.Schema(
  48             validate.parse_json(),
  49             {
  50                 "sources": [
  51                     validate.all(
  52                         {
  53                             "src": validate.url(),
  54                             validate.optional("type"): str,
  55                         },
  56                     ),
  57                 ],
  58             },
  59             validate.get("sources"),
  60         )
  61 
  62         for api_url in player_api_url:
  63             log.debug(f"Player API URL: {api_url}")
  64             for source in self.session.http.get(api_url, schema=stream_schema):
  65                 log.debug(f"Stream source: {source['src']} ({source.get('type', 'n/a')})")
  66 
  67                 if "type" not in source or source["type"] == "application/vnd.apple.mpegurl":
  68                     streams = HLSStream.parse_variant_playlist(self.session, source["src"])
  69                     if not streams:
  70                         yield "live", HLSStream(self.session, source["src"])
  71                     else:
  72                         yield from streams.items()
  73                 elif source["type"] == "application/dash+xml":
  74                     yield from DASHStream.parse_manifest(self.session, source["src"]).items()
  75 
  76 
  77 __plugin__ = AtresPlayer
  78
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/src/streamlink/plugins/atresplayer.py b/src/streamlink/plugins/atresplayer.py
  --- a/src/streamlink/plugins/atresplayer.py
  +++ b/src/streamlink/plugins/atresplayer.py
  @@ -7,12 +7,12 @@
   
   import logging
   import re
  +from urllib.parse import urlparse
   
   from streamlink.plugin import Plugin, pluginmatcher
   from streamlink.plugin.api import validate
   from streamlink.stream.dash import DASHStream
   from streamlink.stream.hls import HLSStream
  -from streamlink.utils.data import search_dict
   from streamlink.utils.url import update_scheme
   
   log = logging.getLogger(__name__)
  @@ -24,15 +24,15 @@
   class AtresPlayer(Plugin):
       def _get_streams(self):
           self.url = update_scheme("https://", self.url)
  +        path = urlparse(self.url).path
   
           api_url = self.session.http.get(self.url, schema=validate.Schema(
               re.compile(r"""window.__PRELOADED_STATE__\s*=\s*({.*?});""", re.DOTALL),
               validate.none_or_all(
                   validate.get(1),
                   validate.parse_json(),
  -                validate.transform(search_dict, key="href"),
  -                [validate.url()],
  -                validate.get(0),
  +                {"links": {path: {"href": validate.url()}}},
  +                validate.get(("links", path, "href")),
               ),
           ))
           if not api_url:
  @@ -41,37 +41,46 @@
   
           player_api_url = self.session.http.get(api_url, schema=validate.Schema(
               validate.parse_json(),
  -            validate.transform(search_dict, key="urlVideo"),
  +            {"urlVideo": validate.url()},
  +            validate.get("urlVideo"),
           ))
   
  -        stream_schema = validate.Schema(
  +        log.debug(f"Player API URL: {player_api_url}")
  +        sources = self.session.http.get(player_api_url, acceptable_status=(200, 403), schema=validate.Schema(
               validate.parse_json(),
  -            {
  -                "sources": [
  -                    validate.all(
  -                        {
  -                            "src": validate.url(),
  -                            validate.optional("type"): str,
  -                        },
  -                    ),
  -                ],
  -            },
  -            validate.get("sources"),
  -        )
  +            validate.any(
  +                {
  +                    "error": str,
  +                    "error_description": str,
  +                },
  +                {
  +                    "sources": [
  +                        validate.all(
  +                            {
  +                                "src": validate.url(),
  +                                validate.optional("type"): str,
  +                            },
  +                            validate.union_get("type", "src"),
  +                        ),
  +                    ],
  +                },
  +            ),
  +        ))
  +        if "error" in sources:
  +            log.error(f"Player API error: {sources['error']} - {sources['error_description']}")
  +            return
   
  -        for api_url in player_api_url:
  -            log.debug(f"Player API URL: {api_url}")
  -            for source in self.session.http.get(api_url, schema=stream_schema):
  -                log.debug(f"Stream source: {source['src']} ({source.get('type', 'n/a')})")
  +        for streamtype, streamsrc in sources.get("sources"):
  +            log.debug(f"Stream source: {streamsrc} ({streamtype or 'n/a'})")
   
  -                if "type" not in source or source["type"] == "application/vnd.apple.mpegurl":
  -                    streams = HLSStream.parse_variant_playlist(self.session, source["src"])
  -                    if not streams:
  -                        yield "live", HLSStream(self.session, source["src"])
  -                    else:
  -                        yield from streams.items()
  -                elif source["type"] == "application/dash+xml":
  -                    yield from DASHStream.parse_manifest(self.session, source["src"]).items()
  +            if streamtype == "application/vnd.apple.mpegurl":
  +                streams = HLSStream.parse_variant_playlist(self.session, streamsrc)
  +                if not streams:
  +                    yield "live", HLSStream(self.session, streamsrc)
  +                else:
  +                    yield from streams.items()
  +            elif streamtype == "application/dash+xml":
  +                yield from DASHStream.parse_manifest(self.session, streamsrc).items()
   
   
   __plugin__ = AtresPlayer
  
verification_info: {"golden_diff": "diff --git a/src/streamlink/plugins/atresplayer.py b/src/streamlink/plugins/atresplayer.py\n--- a/src/streamlink/plugins/atresplayer.py\n+++ b/src/streamlink/plugins/atresplayer.py\n@@ -7,12 +7,12 @@\n \n import logging\n import re\n+from urllib.parse import urlparse\n \n from streamlink.plugin import Plugin, pluginmatcher\n from streamlink.plugin.api import validate\n from streamlink.stream.dash import DASHStream\n from streamlink.stream.hls import HLSStream\n-from streamlink.utils.data import search_dict\n from streamlink.utils.url import update_scheme\n \n log = logging.getLogger(__name__)\n@@ -24,15 +24,15 @@\n class AtresPlayer(Plugin):\n     def _get_streams(self):\n         self.url = update_scheme(\"https://\", self.url)\n+        path = urlparse(self.url).path\n \n         api_url = self.session.http.get(self.url, schema=validate.Schema(\n             re.compile(r\"\"\"window.__PRELOADED_STATE__\\s*=\\s*({.*?});\"\"\", re.DOTALL),\n             validate.none_or_all(\n                 validate.get(1),\n                 validate.parse_json(),\n-                validate.transform(search_dict, key=\"href\"),\n-                [validate.url()],\n-                validate.get(0),\n+                {\"links\": {path: {\"href\": validate.url()}}},\n+                validate.get((\"links\", path, \"href\")),\n             ),\n         ))\n         if not api_url:\n@@ -41,37 +41,46 @@\n \n         player_api_url = self.session.http.get(api_url, schema=validate.Schema(\n             validate.parse_json(),\n-            validate.transform(search_dict, key=\"urlVideo\"),\n+            {\"urlVideo\": validate.url()},\n+            validate.get(\"urlVideo\"),\n         ))\n \n-        stream_schema = validate.Schema(\n+        log.debug(f\"Player API URL: {player_api_url}\")\n+        sources = self.session.http.get(player_api_url, acceptable_status=(200, 403), schema=validate.Schema(\n             validate.parse_json(),\n-            {\n-                \"sources\": [\n-                    validate.all(\n-                        {\n-                            \"src\": validate.url(),\n-                            validate.optional(\"type\"): str,\n-                        },\n-                    ),\n-                ],\n-            },\n-            validate.get(\"sources\"),\n-        )\n+            validate.any(\n+                {\n+                    \"error\": str,\n+                    \"error_description\": str,\n+                },\n+                {\n+                    \"sources\": [\n+                        validate.all(\n+                            {\n+                                \"src\": validate.url(),\n+                                validate.optional(\"type\"): str,\n+                            },\n+                            validate.union_get(\"type\", \"src\"),\n+                        ),\n+                    ],\n+                },\n+            ),\n+        ))\n+        if \"error\" in sources:\n+            log.error(f\"Player API error: {sources['error']} - {sources['error_description']}\")\n+            return\n \n-        for api_url in player_api_url:\n-            log.debug(f\"Player API URL: {api_url}\")\n-            for source in self.session.http.get(api_url, schema=stream_schema):\n-                log.debug(f\"Stream source: {source['src']} ({source.get('type', 'n/a')})\")\n+        for streamtype, streamsrc in sources.get(\"sources\"):\n+            log.debug(f\"Stream source: {streamsrc} ({streamtype or 'n/a'})\")\n \n-                if \"type\" not in source or source[\"type\"] == \"application/vnd.apple.mpegurl\":\n-                    streams = HLSStream.parse_variant_playlist(self.session, source[\"src\"])\n-                    if not streams:\n-                        yield \"live\", HLSStream(self.session, source[\"src\"])\n-                    else:\n-                        yield from streams.items()\n-                elif source[\"type\"] == \"application/dash+xml\":\n-                    yield from DASHStream.parse_manifest(self.session, source[\"src\"]).items()\n+            if streamtype == \"application/vnd.apple.mpegurl\":\n+                streams = HLSStream.parse_variant_playlist(self.session, streamsrc)\n+                if not streams:\n+                    yield \"live\", HLSStream(self.session, streamsrc)\n+                else:\n+                    yield from streams.items()\n+            elif streamtype == \"application/dash+xml\":\n+                yield from DASHStream.parse_manifest(self.session, streamsrc).items()\n \n \n __plugin__ = AtresPlayer\n", "issue": "plugins.atresplayer: Live streams is not working.\n### Checklist\r\n\r\n- [X] This is a plugin issue and not a different kind of issue\r\n- [X] [I have read the contribution guidelines](https://github.com/streamlink/streamlink/blob/master/CONTRIBUTING.md#contributing-to-streamlink)\r\n- [X] [I have checked the list of open and recently closed plugin issues](https://github.com/streamlink/streamlink/issues?q=is%3Aissue+label%3A%22plugin+issue%22)\r\n- [X] [I have checked the commit log of the master branch](https://github.com/streamlink/streamlink/commits/master)\r\n\r\n### Streamlink version\r\n\r\nLatest stable release\r\n\r\n### Description\r\n\r\nAs for today, Atresplayer live streams is not working.\r\n\r\n### Debug log\r\n\r\n```text\r\n[cli][debug] OS:         Windows 10\r\n[cli][debug] Python:     3.10.6\r\n[cli][debug] Streamlink: 4.3.0\r\n[cli][debug] Dependencies:\r\n[cli][debug]  isodate: 0.6.1\r\n[cli][debug]  lxml: 4.9.1\r\n[cli][debug]  pycountry: 22.3.5\r\n[cli][debug]  pycryptodome: 3.15.0\r\n[cli][debug]  PySocks: 1.7.1\r\n[cli][debug]  requests: 2.28.1\r\n[cli][debug]  websocket-client: 1.3.3\r\n[cli][debug] Arguments:\r\n[cli][debug]  url=https://www.atresplayer.com/directos/antena3/\r\n[cli][debug]  stream=['best']\r\n[cli][debug]  --loglevel=debug\r\n[cli][debug]  --hls-live-edge=1\r\n[cli][debug]  --ffmpeg-ffmpeg=C:\\Program Files\\Streamlink\\ffmpeg\\ffmpeg.exe\r\n[cli][info] Found matching plugin atresplayer for URL https://www.atresplayer.com/directos/antena3/\r\nerror: Unable to validate response text: ValidationError(NoneOrAllSchema):\r\n  ValidationError(type):\r\n    Type of <generator object search_dict at 0x000002C64BA79930> should be list, but is generator\r\n```\r\n\n", "before_files": [{"content": "\"\"\"\n$description Spanish live TV channels from Atresmedia Television, including Antena 3 and laSexta.\n$url atresplayer.com\n$type live\n$region Spain\n\"\"\"\n\nimport logging\nimport re\n\nfrom streamlink.plugin import Plugin, pluginmatcher\nfrom streamlink.plugin.api import validate\nfrom streamlink.stream.dash import DASHStream\nfrom streamlink.stream.hls import HLSStream\nfrom streamlink.utils.data import search_dict\nfrom streamlink.utils.url import update_scheme\n\nlog = logging.getLogger(__name__)\n\n\n@pluginmatcher(re.compile(\n    r\"https?://(?:www\\.)?atresplayer\\.com/\"\n))\nclass AtresPlayer(Plugin):\n    def _get_streams(self):\n        self.url = update_scheme(\"https://\", self.url)\n\n        api_url = self.session.http.get(self.url, schema=validate.Schema(\n            re.compile(r\"\"\"window.__PRELOADED_STATE__\\s*=\\s*({.*?});\"\"\", re.DOTALL),\n            validate.none_or_all(\n                validate.get(1),\n                validate.parse_json(),\n                validate.transform(search_dict, key=\"href\"),\n                [validate.url()],\n                validate.get(0),\n            ),\n        ))\n        if not api_url:\n            return\n        log.debug(f\"API URL: {api_url}\")\n\n        player_api_url = self.session.http.get(api_url, schema=validate.Schema(\n            validate.parse_json(),\n            validate.transform(search_dict, key=\"urlVideo\"),\n        ))\n\n        stream_schema = validate.Schema(\n            validate.parse_json(),\n            {\n                \"sources\": [\n                    validate.all(\n                        {\n                            \"src\": validate.url(),\n                            validate.optional(\"type\"): str,\n                        },\n                    ),\n                ],\n            },\n            validate.get(\"sources\"),\n        )\n\n        for api_url in player_api_url:\n            log.debug(f\"Player API URL: {api_url}\")\n            for source in self.session.http.get(api_url, schema=stream_schema):\n                log.debug(f\"Stream source: {source['src']} ({source.get('type', 'n/a')})\")\n\n                if \"type\" not in source or source[\"type\"] == \"application/vnd.apple.mpegurl\":\n                    streams = HLSStream.parse_variant_playlist(self.session, source[\"src\"])\n                    if not streams:\n                        yield \"live\", HLSStream(self.session, source[\"src\"])\n                    else:\n                        yield from streams.items()\n                elif source[\"type\"] == \"application/dash+xml\":\n                    yield from DASHStream.parse_manifest(self.session, source[\"src\"]).items()\n\n\n__plugin__ = AtresPlayer\n", "path": "src/streamlink/plugins/atresplayer.py"}], "after_files": [{"content": "\"\"\"\n$description Spanish live TV channels from Atresmedia Television, including Antena 3 and laSexta.\n$url atresplayer.com\n$type live\n$region Spain\n\"\"\"\n\nimport logging\nimport re\nfrom urllib.parse import urlparse\n\nfrom streamlink.plugin import Plugin, pluginmatcher\nfrom streamlink.plugin.api import validate\nfrom streamlink.stream.dash import DASHStream\nfrom streamlink.stream.hls import HLSStream\nfrom streamlink.utils.url import update_scheme\n\nlog = logging.getLogger(__name__)\n\n\n@pluginmatcher(re.compile(\n    r\"https?://(?:www\\.)?atresplayer\\.com/\"\n))\nclass AtresPlayer(Plugin):\n    def _get_streams(self):\n        self.url = update_scheme(\"https://\", self.url)\n        path = urlparse(self.url).path\n\n        api_url = self.session.http.get(self.url, schema=validate.Schema(\n            re.compile(r\"\"\"window.__PRELOADED_STATE__\\s*=\\s*({.*?});\"\"\", re.DOTALL),\n            validate.none_or_all(\n                validate.get(1),\n                validate.parse_json(),\n                {\"links\": {path: {\"href\": validate.url()}}},\n                validate.get((\"links\", path, \"href\")),\n            ),\n        ))\n        if not api_url:\n            return\n        log.debug(f\"API URL: {api_url}\")\n\n        player_api_url = self.session.http.get(api_url, schema=validate.Schema(\n            validate.parse_json(),\n            {\"urlVideo\": validate.url()},\n            validate.get(\"urlVideo\"),\n        ))\n\n        log.debug(f\"Player API URL: {player_api_url}\")\n        sources = self.session.http.get(player_api_url, acceptable_status=(200, 403), schema=validate.Schema(\n            validate.parse_json(),\n            validate.any(\n                {\n                    \"error\": str,\n                    \"error_description\": str,\n                },\n                {\n                    \"sources\": [\n                        validate.all(\n                            {\n                                \"src\": validate.url(),\n                                validate.optional(\"type\"): str,\n                            },\n                            validate.union_get(\"type\", \"src\"),\n                        ),\n                    ],\n                },\n            ),\n        ))\n        if \"error\" in sources:\n            log.error(f\"Player API error: {sources['error']} - {sources['error_description']}\")\n            return\n\n        for streamtype, streamsrc in sources.get(\"sources\"):\n            log.debug(f\"Stream source: {streamsrc} ({streamtype or 'n/a'})\")\n\n            if streamtype == \"application/vnd.apple.mpegurl\":\n                streams = HLSStream.parse_variant_playlist(self.session, streamsrc)\n                if not streams:\n                    yield \"live\", HLSStream(self.session, streamsrc)\n                else:\n                    yield from streams.items()\n            elif streamtype == \"application/dash+xml\":\n                yield from DASHStream.parse_manifest(self.session, streamsrc).items()\n\n\n__plugin__ = AtresPlayer\n", "path": "src/streamlink/plugins/atresplayer.py"}]}