Repository: streamlink/streamlink

Issue:
itv player fails
<!--
Thanks for reporting a plugin issue!
USE THE TEMPLATE. Otherwise your plugin issue may be rejected.

First, see the contribution guidelines:
https://github.com/streamlink/streamlink/blob/master/CONTRIBUTING.md#contributing-to-streamlink

Also check the list of open and closed plugin issues:
https://github.com/streamlink/streamlink/issues?q=is%3Aissue+label%3A%22plugin+issue%22

Please see the text preview to avoid unnecessary formatting errors.
-->


## Plugin Issue

<!-- Replace [ ] with [x] in order to check the box -->
- [x] This is a plugin issue and I have read the contribution guidelines.


### Description

<!-- When using itv player to stream I get the error Error while executing subprocess -->
When using itv player to stream I get the error Error while executing subprocess also error not found


### Reproduction steps / Explicit stream URLs to test

<!-- How can we reproduce this? Please note the exact steps below using the list format supplied. If you need more steps please add them. -->

1. .../usr/local/bin/streamlink https://www.itv.com/hub/itv worst --player-external-http --player-external-http-port 23599 -l debug
2. .../usr/local/bin/streamlink https://www.itv.com/hub/itv2 worst --player-external-http --player-external-http-port 23599 -l debug
3. ...


### Log output

<!--
TEXT LOG OUTPUT IS REQUIRED for a plugin issue!
Use the `--loglevel debug` parameter and avoid using parameters which suppress log output.
https://streamlink.github.io/cli.html#cmdoption-l

Make sure to **remove usernames and passwords**
You can copy the output to https://gist.github.com/ or paste it below.
-->

```
/usr/local/bin/streamlink https://www.itv.com/hub/itv worst --player-external-http --player-external-http-port 23599 -l debug
[cli][info] streamlink is running as root! Be careful!
[cli][debug] OS:         Linux-4.15.0-50-generic-x86_64-with-Ubuntu-18.04-bionic
[cli][debug] Python:     2.7.17
[cli][debug] Streamlink: 1.3.1
[cli][debug] Requests(2.23.0), Socks(1.7.1), Websocket(0.57.0)
[cli][info] Found matching plugin itvplayer for URL https://www.itv.com/hub/itv
[plugin.itvplayer][debug] XML data path: https://mediaplayer.itv.com/flash/playlists/ukonly/itv1.xml
[cli][info] Available streams: live (worst, best)
[cli][info] Starting server, access with one of:
[cli][info]  http://127.0.0.1:23599/
[cli][info]  http://185.247.117.123:23599/
[cli][info] Got HTTP request from VLC/3.0.8 LibVLC/3.0.8
[cli][info] Opening stream: live (rtmp)
[stream.streamprocess][debug] Spawning command: /usr/bin/rtmpdump --flv - --live --playpath itv1static@45475 --rtmp rtmpe://cp532701.live.edgefcs.net/live --swfVfy https://mediaplayer.itv.com/2.19.5%2Bbuild.a23aa62b1e/ITVMediaPlayer.swf
[cli][error] Could not open stream: Error while executing subprocess, error output logged to: /dev/null
[plugin.itvplayer][debug] XML data path: https://mediaplayer.itv.com/flash/playlists/ukonly/itv1.xml
[cli][info] Opening stream: live (rtmp)
[stream.streamprocess][debug] Spawning command: /usr/bin/rtmpdump --flv - --live --playpath itv1static@45475 --rtmp rtmpe://cp532701.live.edgefcs.net/live --swfVfy https://mediaplayer.itv.com/2.19.5%2Bbuild.a23aa62b1e/ITVMediaPlayer.swf
[cli][error] Could not open stream: Error while executing subprocess, error output logged to: /dev/null
[plugin.itvplayer][debug] XML data path: https://mediaplayer.itv.com/flash/playlists/ukonly/itv1.xml
[cli][info] Opening stream: live (rtmp)
[stream.streamprocess][debug] Spawning command: /usr/bin/rtmpdump --flv - --live --playpath itv1static@45475 --rtmp rtmpe://cp532701.live.edgefcs.net/live --swfVfy https://mediaplayer.itv.com/2.19.5%2Bbuild.a23aa62b1e/ITVMediaPlayer.swf
[cli][error] Could not open stream: Error while executing subprocess, error output logged to: /dev/null
[plugin.itvplayer][debug] XML data path: https://mediaplayer.itv.com/flash/playlists/ukonly/itv1.xml
[cli][info] Opening stream: live (rtmp)
[stream.streamprocess][debug] Spawning command: /usr/bin/rtmpdump --flv - --live --playpath itv1static@45475 --rtmp rtmpe://cp532701.live.edgefcs.net/live --swfVfy https://mediaplayer.itv.com/2.19.5%2Bbuild.a23aa62b1e/ITVMediaPlayer.swf
[cli][error] Could not open stream: Error while executing subprocess, error output logged to: /dev/null
[plugin.itvplayer][debug] XML data path: https://mediaplayer.itv.com/flash/playlists/ukonly/itv1.xml
[cli][info] Opening stream: live (rtmp)
[stream.streamprocess][debug] Spawning command: /usr/bin/rtmpdump --flv - --live --playpath itv1static@45475 --rtmp rtmpe://cp532701.live.edgefcs.net/live --swfVfy https://mediaplayer.itv.com/2.19.5%2Bbuild.a23aa62b1e/ITVMediaPlayer.swf
[cli][error] Could not open stream: Error while executing subprocess, error output logged to: /dev/null
[plugin.itvplayer][debug] XML data path: https://mediaplayer.itv.com/flash/playlists/ukonly/itv1.xml
[cli][info] Opening stream: live (rtmp)
[stream.streamprocess][debug] Spawning command: /usr/bin/rtmpdump --flv - --live --playpath itv1static@45475 --rtmp rtmpe://cp532701.live.edgefcs.net/live --swfVfy https://mediaplayer.itv.com/2.19.5%2Bbuild.a23aa62b1e/ITVMediaPlayer.swf
[cli][error] Could not open stream: Error while executing subprocess, error output logged to: /dev/null
[plugin.itvplayer][debug] XML data path: https://mediaplayer.itv.com/flash/playlists/ukonly/itv1.xml
[cli][info] Opening stream: live (rtmp)
[stream.streamprocess][debug] Spawning command: /usr/bin/rtmpdump --flv - --live --playpath itv1static@45475 --rtmp rtmpe://cp532701.live.edgefcs.net/live --swfVfy https://mediaplayer.itv.com/2.19.5%2Bbuild.a23aa62b1e/ITVMediaPlayer.swf
[cli][error] Could not open stream: Error while executing subprocess, error output logged to: /dev/null
[plugin.itvplayer][debug] XML data path: https://mediaplayer.itv.com/flash/playlists/ukonly/itv1.xml
[cli][info] Opening stream: live (rtmp)
[stream.streamprocess][debug] Spawning command: /usr/bin/rtmpdump --flv - --live --playpath itv1static@45475 --rtmp rtmpe://cp532701.live.edgefcs.net/live --swfVfy https://mediaplayer.itv.com/2.19.5%2Bbuild.a23aa62b1e/ITVMediaPlayer.swf
[cli][error] Could not open stream: Error while executing subprocess, error output logged to: /dev/null
[plugin.itvplayer][debug] XML data path: https://mediaplayer.itv.com/flash/playlists/ukonly/itv1.xml
[cli][info] Opening stream: live (rtmp)
[stream.streamprocess][debug] Spawning command: /usr/bin/rtmpdump --flv - --live --playpath itv1static@45475 --rtmp rtmpe://cp532701.live.edgefcs.net/live --swfVfy https://mediaplayer.itv.com/2.19.5%2Bbuild.a23aa62b1e/ITVMediaPlayer.swf
[cli][error] Could not open stream: Error while executing subprocess, error output logged to: /dev/null
[plugin.itvplayer][debug] XML data path: https://mediaplayer.itv.com/flash/playlists/ukonly/itv1.xml
[cli][info] Opening stream: live (rtmp)
[stream.streamprocess][debug] Spawning command: /usr/bin/rtmpdump --flv - --live --playpath itv1static@45475 --rtmp rtmpe://cp532701.live.edgefcs.net/live --swfVfy https://mediaplayer.itv.com/2.19.5%2Bbuild.a23aa62b1e/ITVMediaPlayer.swf
[cli][error] Could not open stream: Error while executing subprocess, error output logged to: /dev/null
[plugin.itvplayer][debug] XML data path: https://mediaplayer.itv.com/flash/playlists/ukonly/itv1.xml
[cli][info] Opening stream: live (rtmp)
[stream.streamprocess][debug] Spawning command: /usr/bin/rtmpdump --flv - --live --playpath itv1static@45475 --rtmp rtmpe://cp532701.live.edgefcs.net/live --swfVfy https://mediaplayer.itv.com/2.19.5%2Bbuild.a23aa62b1e/ITVMediaPlayer.swf
[cli][error] Could not open stream: Error while executing subprocess, error output logged to: /dev/null
[plugin.itvplayer][debug] XML data path: https://mediaplayer.itv.com/flash/playlists/ukonly/itv1.xml
[cli][info] Opening stream: live (rtmp)
[stream.streamprocess][debug] Spawning command: /usr/bin/rtmpdump --flv - --live --playpath itv1static@45475 --rtmp rtmpe://cp532701.live.edgefcs.net/live --swfVfy https://mediaplayer.itv.com/2.19.5%2Bbuild.a23aa62b1e/ITVMediaPlayer.swf
[cli][error] Could not open stream: Error while executing subprocess, error output logged to: /dev/null
^CInterrupted! Exiting...
```
LOG2
/usr/local/bin/streamlink https://www.itv.com/hub/itv2 worst --player-external-http --player-external-http-port 23599 -l debug
[cli][info] streamlink is running as root! Be careful!
[cli][debug] OS:         Linux-4.15.0-50-generic-x86_64-with-Ubuntu-18.04-bionic
[cli][debug] Python:     2.7.17
[cli][debug] Streamlink: 1.3.1
[cli][debug] Requests(2.23.0), Socks(1.7.1), Websocket(0.57.0)
[cli][info] Found matching plugin itvplayer for URL https://www.itv.com/hub/itv2
[plugin.itvplayer][debug] Video ID info response: {'AdditionalInfo': {'Message': None}, 'Playlist': {'VideoType': u'SIMULCAST', 'Video': {'Base': u'https://dotcom-itv2-hls.akamaized.net/hls/live/', 'MediaFiles': [{'Href': u'626380/itvlive/itv2/master.m3u8?hdnea=st=1587839941~exp=1587861541~acl=/*~data=nohubplus~hmac=af7ac8d7952154581bf47d17286d7feb2b3e5d0b42f5e66731a69159e6676473', 'KeyServiceUrl': None}], 'Subtitles': None}}, 'StatusCode': 200}
[utils.l10n][debug] Language code: en_US
[cli][info] Available streams: 615k (worst), 660k, 818k, 880k, 1222k, 1320k, 1526k, 1650k, 1830k, 1980k (best)
[cli][info] Starting server, access with one of:
[cli][info]  http://127.0.0.1:23599/
[cli][info]  http://185.247.117.123:23599/
[cli][info] Got HTTP request from VLC/3.0.8 LibVLC/3.0.8
[cli][info] Opening stream: 615k (hls)
[stream.hls][debug] Reloading playlist
[cli][error] Could not open stream: Unable to open URL: https://dotcom-itv2-hls.akamaized.net/hls/live/626380/itvlive/itv2/master_Main600.m3u8 (404 Client Error: Not Found for url: https://dotcom-itv2-hls.akamaized.net/hls/live/626380/itvlive/itv2/master_Main600.m3u8)
[plugin.itvplayer][debug] Video ID info response: {'AdditionalInfo': {'Message': None}, 'Playlist': {'VideoType': u'SIMULCAST', 'Video': {'Base': u'https://dotcom-itv2-hls.akamaized.net/hls/live/', 'MediaFiles': [{'Href': u'626380/itvlive/itv2/master.m3u8?hdnea=st=1587839973~exp=1587861573~acl=/*~data=nohubplus~hmac=e537ef1486198e2ff2dba0f0cc85cd35d45577339975ef433418121d8493b02d', 'KeyServiceUrl': None}], 'Subtitles': None}}, 'StatusCode': 200}
[utils.l10n][debug] Language code: en_US
[cli][info] Opening stream: 615k (hls)
[stream.hls][debug] Reloading playlist
[cli][error] Could not open stream: Unable to open URL: https://dotcom-itv2-hls.akamaized.net/hls/live/626380/itvlive/itv2/master_Main600.m3u8 (404 Client Error: Not Found for url: https://dotcom-itv2-hls.akamaized.net/hls/live/626380/itvlive/itv2/master_Main600.m3u8)
[plugin.itvplayer][debug] Video ID info response: {'AdditionalInfo': {'Message': None}, 'Playlist': {'VideoType': u'SIMULCAST', 'Video': {'Base': u'https://dotcom-itv2-hls.akamaized.net/hls/live/', 'MediaFiles': [{'Href': u'626380/itvlive/itv2/master.m3u8?hdnea=st=1587839976~exp=1587861576~acl=/*~data=nohubplus~hmac=cebdac4a123cd01c330c1546575c92814b6b4326770ce2ddb0926fbef604be54', 'KeyServiceUrl': None}], 'Subtitles': None}}, 'StatusCode': 200}
[utils.l10n][debug] Language code: en_US
[cli][info] Opening stream: 615k (hls)
[stream.hls][debug] Reloading playlist


### Additional comments, screenshots, etc.



[Love Streamlink? Please consider supporting our collective. Thanks!](https://opencollective.com/streamlink/donate)



Discussion:
Unfortunately, the ITV player plugin has been broken for some time now, due to their implementation of DRM on the streams.  See:

https://github.com/streamlink/streamlink/issues/2718
https://github.com/streamlink/streamlink/issues/2727

Yep as mkbloke noted they added DRM and we don't circumvent DRM so I'm going to close this one out, we should probably remove the plugin from the next release.

Resolving patch:
diff --git a/src/streamlink/plugins/itvplayer.py b/src/streamlink/plugins/itvplayer.py
deleted file mode 100644
--- a/src/streamlink/plugins/itvplayer.py
+++ /dev/null
@@ -1,101 +0,0 @@
-import json
-import logging
-import re
-
-from streamlink.compat import urljoin
-from streamlink.plugin import Plugin
-from streamlink.plugin.api import useragents, validate
-from streamlink.plugin.api.utils import itertags
-from streamlink.stream import HLSStream, RTMPStream
-
-log = logging.getLogger(__name__)
-
-
-class ITVPlayer(Plugin):
-    _url_re = re.compile(r"https?://(?:www\.)?itv\.com/hub/(?P<stream>.+)")
-    swf_url = "https://mediaplayer.itv.com/2.19.5%2Bbuild.a23aa62b1e/ITVMediaPlayer.swf"
-    _video_info_schema = validate.Schema({
-        "StatusCode": 200,
-        "AdditionalInfo": {
-            "Message": validate.any(None, validate.text)
-        },
-        "Playlist": {
-            "VideoType": validate.text,
-            "Video": {
-                "Subtitles": validate.any(None, [{
-                    "Href": validate.url(),
-                }]),
-                "Base": validate.url(),
-                "MediaFiles": [
-                    {"Href": validate.text,
-                     "KeyServiceUrl": validate.any(None, validate.url())}
-                ]
-            }
-        }
-    })
-
-    @classmethod
-    def can_handle_url(cls, url):
-        return cls._url_re.match(url) is not None
-
-    @property
-    def device_info(self):
-        return {"user": {},
-                "device": {"manufacturer": "Chrome", "model": "66",
-                           "os": {"name": "Windows", "version": "10", "type": "desktop"}},
-                "client": {"version": "4.1", "id": "browser"},
-                "variantAvailability": {"featureset": {"min": ["hls", "aes"],
-                                                       "max": ["hls", "aes"]},
-                                        "platformTag": "dotcom"}}
-
-    def video_info(self):
-        page = self.session.http.get(self.url)
-        for div in itertags(page.text, 'div'):
-            if div.attributes.get("id") == "video":
-                return div.attributes
-
-    def _get_html5_streams(self, video_info_url):
-        video_info = self.video_info()
-        res = self.session.http.post(video_info_url,
-                                     data=json.dumps(self.device_info),
-                                     headers={"hmac": video_info.get("data-video-hmac")})
-        data = self.session.http.json(res, schema=self._video_info_schema)
-
-        log.debug("Video ID info response: {0}".format(data))
-
-        stype = data['Playlist']['VideoType']
-
-        for media in data['Playlist']['Video']['MediaFiles']:
-            url = urljoin(data['Playlist']['Video']['Base'], media['Href'])
-            name_fmt = "{pixels}_{bitrate}" if stype == "CATCHUP" else None
-            for s in HLSStream.parse_variant_playlist(self.session, url, name_fmt=name_fmt).items():
-                yield s
-
-    def _get_rtmp_streams(self, video_info_url):
-        log.debug("XML data path: {0}".format(video_info_url))
-        res = self.session.http.get(video_info_url)
-        playlist = self.session.http.xml(res, ignore_ns=True)
-        mediafiles = playlist.find(".//Playlist/VideoEntries/Video/MediaFiles")
-        playpath = mediafiles.find("./MediaFile/URL")
-        return {"live": RTMPStream(self.session, {"rtmp": mediafiles.attrib.get("base"),
-                                                  "playpath": playpath.text,
-                                                  "live": True,
-                                                  "swfVfy": self.swf_url
-                                                  })}
-
-    def _get_streams(self):
-        """
-            Find all the streams for the ITV url
-            :return: Mapping of quality to stream
-        """
-        self.session.http.headers.update({"User-Agent": useragents.FIREFOX})
-        stream = self._url_re.match(self.url).group("stream")
-        video_info = self.video_info()
-        video_info_url = video_info.get("data-video-id" if stream.lower() in ("itv", "itv4") else "data-html5-playlist")
-        if video_info_url.endswith(".xml"):
-            return self._get_rtmp_streams(video_info_url)
-        else:
-            return self._get_html5_streams(video_info_url)
-
-
-__plugin__ = ITVPlayer


Test patch:
diff --git a/tests/plugins/test_itvplayer.py b/tests/plugins/test_itvplayer.py
deleted file mode 100644
--- a/tests/plugins/test_itvplayer.py
+++ /dev/null
@@ -1,20 +0,0 @@
-import unittest
-
-from streamlink.plugins.itvplayer import ITVPlayer
-
-
-class TestPluginITVPlayer(unittest.TestCase):
-    def test_can_handle_url(self):
-        should_match = [
-            'https://www.itv.com/hub/itv',
-            'https://www.itv.com/hub/itv2',
-        ]
-        for url in should_match:
-            self.assertTrue(ITVPlayer.can_handle_url(url))
-
-    def test_can_handle_url_negative(self):
-        should_not_match = [
-            'https://example.com/index.html',
-        ]
-        for url in should_not_match:
-            self.assertFalse(ITVPlayer.can_handle_url(url))