We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Request: Add more functions to facebook plugin
### Checklist

- [x] This is a bug report.
- [ ] This is a feature request.
- [x] This is a plugin (improvement) request.
- [ ] I have read the contribution guidelines.

### Description
Reminder that with the new initial support of Mpeg Dash #880 and #990 might be fixable now, depending on what streamlink supports and how Facebook's videos and livestreaming has changed since this was last looked it.


--- 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/facebook.py`
Content:
```
1 import re
2 
3 from streamlink.plugin import Plugin
4 from streamlink.stream import HLSStream
5 
6 _playlist_url = "https://www.facebook.com/video/playback/playlist.m3u8?v={0}"
7 
8 _url_re = re.compile(r"http(s)?://(www\.)?facebook\.com/[^/]+/videos/(?P<video_id>\d+)")
9 
10 
11 class Facebook(Plugin):
12     @classmethod
13     def can_handle_url(cls, url):
14         return _url_re.match(url)
15 
16     @Plugin.broken(990)
17     def _get_streams(self):
18         match = _url_re.match(self.url)
19         video = match.group("video_id")
20 
21         playlist = _playlist_url.format(video)
22 
23         return HLSStream.parse_variant_playlist(self.session, playlist)
24 
25 
26 __plugin__ = Facebook
27
```
--- 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()

```

diff --git a/src/streamlink/plugins/facebook.py b/src/streamlink/plugins/facebook.py
--- a/src/streamlink/plugins/facebook.py
+++ b/src/streamlink/plugins/facebook.py
@@ -1,26 +1,42 @@
 import re
 
 from streamlink.plugin import Plugin
-from streamlink.stream import HLSStream
-
-_playlist_url = "https://www.facebook.com/video/playback/playlist.m3u8?v={0}"
-
-_url_re = re.compile(r"http(s)?://(www\.)?facebook\.com/[^/]+/videos/(?P<video_id>\d+)")
+from streamlink.plugin.api import http, useragents
+from streamlink.stream import DASHStream, HTTPStream
+from streamlink.utils import parse_json
 
 
 class Facebook(Plugin):
+    _url_re = re.compile(r"https?://(?:www\.)?facebook\.com/[^/]+/videos")
+    _mpd_re = re.compile(r'''(sd|hd)_src["']?\s*:\s*(?P<quote>["'])(?P<url>.+?)(?P=quote)''')
+    _playlist_re = re.compile(r'''video:\[({url:".+?}\])''')
+    _plurl_re = re.compile(r'''url:"(.*?)"''')
+
     @classmethod
     def can_handle_url(cls, url):
-        return _url_re.match(url)
+        return cls._url_re.match(url)
 
-    @Plugin.broken(990)
     def _get_streams(self):
-        match = _url_re.match(self.url)
-        video = match.group("video_id")
+        res = http.get(self.url, headers={"User-Agent": useragents.CHROME})
+        with open("temp.html", "w") as f:
+            f.write(res.text)
+
+        for match in self._mpd_re.finditer(res.text):
+            manifest_url = match.group("url")
+            if "\\/" in manifest_url:
+                # if the URL is json encoded, decode it
+                manifest_url = parse_json("\"{}\"".format(manifest_url))
+            for s in DASHStream.parse_manifest(self.session, manifest_url).items():
+                yield s
+        else:
+            match = self._playlist_re.search(res.text)
+            playlist = match and match.group(1)
+            if playlist:
+                for url in {url.group(1) for url in self._plurl_re.finditer(playlist)}:
+                    yield "live", HTTPStream(self.session, url)
+
 
-        playlist = _playlist_url.format(video)
 
-        return HLSStream.parse_variant_playlist(self.session, playlist)
 
 
 __plugin__ = Facebook

{"golden_diff": "diff --git a/src/streamlink/plugins/facebook.py b/src/streamlink/plugins/facebook.py\n--- a/src/streamlink/plugins/facebook.py\n+++ b/src/streamlink/plugins/facebook.py\n@@ -1,26 +1,42 @@\n import re\n \n from streamlink.plugin import Plugin\n-from streamlink.stream import HLSStream\n-\n-_playlist_url = \"https://www.facebook.com/video/playback/playlist.m3u8?v={0}\"\n-\n-_url_re = re.compile(r\"http(s)?://(www\\.)?facebook\\.com/[^/]+/videos/(?P<video_id>\\d+)\")\n+from streamlink.plugin.api import http, useragents\n+from streamlink.stream import DASHStream, HTTPStream\n+from streamlink.utils import parse_json\n \n \n class Facebook(Plugin):\n+    _url_re = re.compile(r\"https?://(?:www\\.)?facebook\\.com/[^/]+/videos\")\n+    _mpd_re = re.compile(r'''(sd|hd)_src[\"']?\\s*:\\s*(?P<quote>[\"'])(?P<url>.+?)(?P=quote)''')\n+    _playlist_re = re.compile(r'''video:\\[({url:\".+?}\\])''')\n+    _plurl_re = re.compile(r'''url:\"(.*?)\"''')\n+\n     @classmethod\n     def can_handle_url(cls, url):\n-        return _url_re.match(url)\n+        return cls._url_re.match(url)\n \n-    @Plugin.broken(990)\n     def _get_streams(self):\n-        match = _url_re.match(self.url)\n-        video = match.group(\"video_id\")\n+        res = http.get(self.url, headers={\"User-Agent\": useragents.CHROME})\n+        with open(\"temp.html\", \"w\") as f:\n+            f.write(res.text)\n+\n+        for match in self._mpd_re.finditer(res.text):\n+            manifest_url = match.group(\"url\")\n+            if \"\\\\/\" in manifest_url:\n+                # if the URL is json encoded, decode it\n+                manifest_url = parse_json(\"\\\"{}\\\"\".format(manifest_url))\n+            for s in DASHStream.parse_manifest(self.session, manifest_url).items():\n+                yield s\n+        else:\n+            match = self._playlist_re.search(res.text)\n+            playlist = match and match.group(1)\n+            if playlist:\n+                for url in {url.group(1) for url in self._plurl_re.finditer(playlist)}:\n+                    yield \"live\", HTTPStream(self.session, url)\n+\n \n-        playlist = _playlist_url.format(video)\n \n-        return HLSStream.parse_variant_playlist(self.session, playlist)\n \n \n __plugin__ = Facebook\n", "issue": "Request: Add more functions to facebook plugin\n### Checklist\r\n\r\n- [x] This is a bug report.\r\n- [ ] This is a feature request.\r\n- [x] This is a plugin (improvement) request.\r\n- [ ] I have read the contribution guidelines.\r\n\r\n### Description\r\nReminder that with the new initial support of Mpeg Dash #880 and #990 might be fixable now, depending on what streamlink supports and how Facebook's videos and livestreaming has changed since this was last looked it.\r\n\n", "before_files": [{"content": "import re\n\nfrom streamlink.plugin import Plugin\nfrom streamlink.stream import HLSStream\n\n_playlist_url = \"https://www.facebook.com/video/playback/playlist.m3u8?v={0}\"\n\n_url_re = re.compile(r\"http(s)?://(www\\.)?facebook\\.com/[^/]+/videos/(?P<video_id>\\d+)\")\n\n\nclass Facebook(Plugin):\n    @classmethod\n    def can_handle_url(cls, url):\n        return _url_re.match(url)\n\n    @Plugin.broken(990)\n    def _get_streams(self):\n        match = _url_re.match(self.url)\n        video = match.group(\"video_id\")\n\n        playlist = _playlist_url.format(video)\n\n        return HLSStream.parse_variant_playlist(self.session, playlist)\n\n\n__plugin__ = Facebook\n", "path": "src/streamlink/plugins/facebook.py"}], "after_files": [{"content": "import re\n\nfrom streamlink.plugin import Plugin\nfrom streamlink.plugin.api import http, useragents\nfrom streamlink.stream import DASHStream, HTTPStream\nfrom streamlink.utils import parse_json\n\n\nclass Facebook(Plugin):\n    _url_re = re.compile(r\"https?://(?:www\\.)?facebook\\.com/[^/]+/videos\")\n    _mpd_re = re.compile(r'''(sd|hd)_src[\"']?\\s*:\\s*(?P<quote>[\"'])(?P<url>.+?)(?P=quote)''')\n    _playlist_re = re.compile(r'''video:\\[({url:\".+?}\\])''')\n    _plurl_re = re.compile(r'''url:\"(.*?)\"''')\n\n    @classmethod\n    def can_handle_url(cls, url):\n        return cls._url_re.match(url)\n\n    def _get_streams(self):\n        res = http.get(self.url, headers={\"User-Agent\": useragents.CHROME})\n        with open(\"temp.html\", \"w\") as f:\n            f.write(res.text)\n\n        for match in self._mpd_re.finditer(res.text):\n            manifest_url = match.group(\"url\")\n            if \"\\\\/\" in manifest_url:\n                # if the URL is json encoded, decode it\n                manifest_url = parse_json(\"\\\"{}\\\"\".format(manifest_url))\n            for s in DASHStream.parse_manifest(self.session, manifest_url).items():\n                yield s\n        else:\n            match = self._playlist_re.search(res.text)\n            playlist = match and match.group(1)\n            if playlist:\n                for url in {url.group(1) for url in self._plurl_re.finditer(playlist)}:\n                    yield \"live\", HTTPStream(self.session, url)\n\n\n\n\n\n__plugin__ = Facebook\n", "path": "src/streamlink/plugins/facebook.py"}]}