diff options
author | Philipp Hagemeister <phihag@phihag.de> | 2020-06-14 13:17:51 +0200 |
---|---|---|
committer | Philipp Hagemeister <phihag@phihag.de> | 2020-06-14 13:17:51 +0200 |
commit | 48bd042ce76f93b22196ce0a73c41a81a406d856 (patch) | |
tree | 9ee58f15c7b9ebbcb20fadc29efa007e6070f79f /youtube_dl | |
parent | 84213ea8d41d5fe1608333a16ac578dccdf9a915 (diff) |
[facebook] Support single-video ID links
I stumbled upon this at https://www.facebook.com/bwfbadminton/posts/10157127020046316 . No idea how prevalent it is yet.
Diffstat (limited to 'youtube_dl')
-rw-r--r-- | youtube_dl/extractor/facebook.py | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/youtube_dl/extractor/facebook.py b/youtube_dl/extractor/facebook.py index ce64e2683..610d66745 100644 --- a/youtube_dl/extractor/facebook.py +++ b/youtube_dl/extractor/facebook.py @@ -466,15 +466,18 @@ class FacebookIE(InfoExtractor): return info_dict if '/posts/' in url: - entries = [ - self.url_result('facebook:%s' % vid, FacebookIE.ie_key()) - for vid in self._parse_json( - self._search_regex( - r'(["\'])video_ids\1\s*:\s*(?P<ids>\[.+?\])', - webpage, 'video ids', group='ids'), - video_id)] - - return self.playlist_result(entries, video_id) + video_id_json = self._search_regex( + r'(["\'])video_ids\1\s*:\s*(?P<ids>\[.+?\])', webpage, 'video ids', group='ids', + default='') + if video_id_json: + entries = [ + self.url_result('facebook:%s' % vid, FacebookIE.ie_key()) + for vid in self._parse_json(video_id_json, video_id)] + return self.playlist_result(entries, video_id) + + # Single Video? + video_id = self._search_regex(r'video_id:\s*"([0-9]+)"', webpage, 'single video id') + return self.url_result('facebook:%s' % video_id, FacebookIE.ie_key()) else: _, info_dict = self._extract_from_url( self._VIDEO_PAGE_TEMPLATE % video_id, |