Repository: streamlink/streamlink

Issue:
BBC iPlayer plugin cannot find VPID
## Plugin Issue

- [x] This is a plugin issue and I have read the contribution guidelines.

### Description

The BBC IPlayer plugin cannot find the VPID for valid urls.

### Reproduction steps / Explicit stream URLs to test

The following command:

```streamlink -l debug 'https://www.bbc.co.uk/iplayer/episode/m000388w/australia-earths-magical-kingdom-series-1-1-land' best```

produces this output:

```
[baz@blackbox iplayer]
[cli][debug] OS:         Linux-5.0.2-arch1-1-ARCH-x86_64-with-arch
[cli][debug] Python:     3.7.2
[cli][debug] Streamlink: 1.0.0
[cli][debug] Requests(2.21.0), Socks(1.6.7), Websocket(0.55.0)
[cli][info] Found matching plugin bbciplayer for URL https://www.bbc.co.uk/iplayer/episode/m000388w/australia-earths-magical-kingdom-series-1-1-land
[cli][debug] Plugin specific arguments:
[cli][debug]  --bbciplayer-username=******** (username)
[cli][debug]  --bbciplayer-password=******** (password)
[plugin.bbciplayer][info] A TV License is required to watch BBC iPlayer streams, see the BBC website for more information: https://www.bbc.co.uk/iplayer/help/tvlicence
[plugin.bbciplayer][debug] Loading streams for episode: m000388w
[plugin.bbciplayer][debug] Looking for vpid on https://www.bbc.co.uk/iplayer/episode/m000388w/australia-earths-magical-kingdom-series-1-1-land
[plugin.bbciplayer][error] Could not find VPID for episode m000388w
error: No playable streams found on this URL: https://www.bbc.co.uk/iplayer/episode/m000388w/australia-earths-magical-kingdom-series-1-1-land
```

### Comments

This seems to be a another variation of #922.



Discussion:
Confirmed. I will take a look...

Resolving patch:
diff --git a/src/streamlink/plugins/bbciplayer.py b/src/streamlink/plugins/bbciplayer.py
--- a/src/streamlink/plugins/bbciplayer.py
+++ b/src/streamlink/plugins/bbciplayer.py
@@ -30,7 +30,7 @@ class BBCiPlayer(Plugin):
         )
     """, re.VERBOSE)
     mediator_re = re.compile(
-        r'window\.mediatorDefer\s*=\s*page\([^,]*,\s*({.*?})\);', re.DOTALL)
+        r'window\.__IPLAYER_REDUX_STATE__\s*=\s*({.*?});', re.DOTALL)
     tvip_re = re.compile(r'channel"\s*:\s*{\s*"id"\s*:\s*"(\w+?)"')
     tvip_master_re = re.compile(r'event_master_brand=(\w+?)&')
     account_locals_re = re.compile(r'window.bbcAccount.locals\s*=\s*({.*?});')
@@ -45,20 +45,19 @@ class BBCiPlayer(Plugin):
 
     mediator_schema = validate.Schema(
         {
-            "appStoreState": {
-                "versions": [{"id": validate.text}]
-            }
+            "versions": [{"id": validate.text}]
         },
-        validate.get("appStoreState"), validate.get("versions"), validate.get(0),
+        validate.get("versions"), validate.get(0),
         validate.get("id")
     )
     mediaselector_schema = validate.Schema(
         validate.transform(parse_json),
         {"media": [
-            {"connection": [{
-                validate.optional("href"): validate.url(),
-                validate.optional("transferFormat"): validate.text
-            }],
+            {"connection":
+                validate.all([{
+                    validate.optional("href"): validate.url(),
+                    validate.optional("transferFormat"): validate.text
+                }], validate.filter(lambda c: c.get("href"))),
                 "kind": validate.text}
         ]},
         validate.get("media"),


Test patch: