Repository: streamlink/streamlink

Issue:
ok.ru VODs
<!--
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
i enter link in #1884 but "https://raw.githubusercontent.com/back-to/plugins/master/plugins/ok_live.py" 404: Not Found. Thanks
<!-- Explain the plugin issue as thoroughly as you can. -->


### 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. D:\my\Streamlinkl\bin>streamlink -l debug "https://ok.ru/video/266205792931" best



### 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.
-->

```
[cli][debug] OS:         Windows 8.1
[cli][debug] Python:     3.5.2
[cli][debug] Streamlink: 0.14.2
[cli][debug] Requests(2.19.1), Socks(1.6.7), Websocket(0.48.0)
error: No plugin can handle URL: https://ok.ru/video/266205792931

```


### Additional comments, screenshots, etc.



[Love Streamlink? Please consider supporting our collective. Thanks!](https://opencollective.com/streamlink/donate)


Comments:

Patch:
diff --git a/docs/plugin_matrix.rst b/docs/plugin_matrix.rst
index e0b05c65..eea5b215 100644
--- a/docs/plugin_matrix.rst
+++ b/docs/plugin_matrix.rst
@@ -120,7 +120,7 @@ npo                     - npo.nl             Yes   Yes   Streams may be geo-rest
                         - zappelin.nl
 nrk                     - tv.nrk.no          Yes   Yes   Streams may be geo-restricted to Norway.
                         - radio.nrk.no
-ok_live                 ok.ru                Yes   --
+ok_live                 ok.ru                Yes   Yes
 olympicchannel          olympicchannel.com   Yes   Yes   Only non-premium content is available.
 onetv                   - 1tv.ru             Yes   Yes   Streams may be geo-restricted to Russia. VOD only for 1tv.ru
                         - ctc.ru
diff --git a/src/streamlink/plugins/ok_live.py b/src/streamlink/plugins/ok_live.py
index 233c510c..9528ca99 100644
--- a/src/streamlink/plugins/ok_live.py
+++ b/src/streamlink/plugins/ok_live.py
@@ -5,7 +5,7 @@ from streamlink.plugin.api import validate
 from streamlink.plugin.api import useragents
 from streamlink.stream import HLSStream
 
-_url_re = re.compile(r"https?://(www\.)?ok\.ru/live/\d+")
+_url_re = re.compile(r"https?://(www\.)?ok\.ru/(live|video)/\d+")
 _vod_re = re.compile(r";(?P<hlsurl>[^;]+video\.m3u8.+?)\\&quot;")
 
 _schema = validate.Schema(
@@ -21,7 +21,7 @@ _schema = validate.Schema(
 
 class OK_live(Plugin):
     """
-    Support for ok.ru live stream: http://www.ok.ru/live/
+    Support for ok.ru live stream: http://www.ok.ru/live/ and for ok.ru VoDs: http://www.ok.ru/video/
     """
     @classmethod
     def can_handle_url(cls, url):
diff --git a/src/streamlink/stream/dash_manifest.py b/src/streamlink/stream/dash_manifest.py
index cb3d76aa..68c7f56f 100644
--- a/src/streamlink/stream/dash_manifest.py
+++ b/src/streamlink/stream/dash_manifest.py
@@ -509,6 +509,10 @@ class SegmentTemplate(MPDNode):
 
     def format_media(self, **kwargs):
         if self.segmentTimeline:
+            if self.parent.id is None:
+                # workaround for invalid `self.root.timelines[self.parent.id]`
+                # creates a timeline for every mimeType instead of one for both
+                self.parent.id = self.parent.mimeType
             log.debug("Generating segment timeline for {0} playlist (id={1}))".format(self.root.type, self.parent.id))
             if self.root.type == "dynamic":
                 # if there is no delay, use a delay of 3 seconds


Test patch:
diff --git a/tests/plugins/test_ok_live.py b/tests/plugins/test_ok_live.py
index 60a02bcc..bfdcf458 100644
--- a/tests/plugins/test_ok_live.py
+++ b/tests/plugins/test_ok_live.py
@@ -9,6 +9,7 @@ class TestPluginOK_live(unittest.TestCase):
         self.assertTrue(OK_live.can_handle_url("https://ok.ru/live/12345"))
         self.assertTrue(OK_live.can_handle_url("http://ok.ru/live/12345"))
         self.assertTrue(OK_live.can_handle_url("http://www.ok.ru/live/12345"))
+        self.assertTrue(OK_live.can_handle_url("https://ok.ru/video/266205792931"))
 
         # shouldn't match
         self.assertFalse(OK_live.can_handle_url("http://www.tvcatchup.com/"))