From 0f45a3da23690f9138f7b2c3083b72951c40e392 Mon Sep 17 00:00:00 2001 From: bhodaya Date: Mon, 29 Jun 2020 09:28:58 +0300 Subject: [PATCH] fix facebook thumbnail --- test/ci/test_facebook.py | 2 +- youtube_dl/extractor/facebook.py | 15 +-------------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/test/ci/test_facebook.py b/test/ci/test_facebook.py index 383017c09..8910b3261 100644 --- a/test/ci/test_facebook.py +++ b/test/ci/test_facebook.py @@ -28,7 +28,7 @@ class facebookMetaData(unittest.TestCase): def test_meta_data(self): params = {} - url = "https://www.facebook.com/watch?v=177407933624543/" + url = "https://www.facebook.com/parapsychological.centr/videos/177407933624543/" ydl = youtube_dl.YoutubeDL(params) info = ydl.extract_info(url, download=False) self.assertGreater(info.get('comment_count'), 0) diff --git a/youtube_dl/extractor/facebook.py b/youtube_dl/extractor/facebook.py index f18eb872b..8db50e89f 100644 --- a/youtube_dl/extractor/facebook.py +++ b/youtube_dl/extractor/facebook.py @@ -802,8 +802,7 @@ class FacebookIE(InfoExtractor): thumbnail = self._html_search_meta(['og:image', 'twitter:image'], webpage) if not thumbnail: - page = self.resolve_full_webpage(tahoe_data) - thumbnail = self._search_regex(r'"thumbnailUrl":"(.+?)"', page, 'thumbnail', fatal=False) + thumbnail = self._search_regex(r'"thumbnailUrl":"(.+?)"', webpage, 'thumbnail', fatal=False) thumbnail = str(thumbnail).replace('\\', "") return thumbnail @@ -825,18 +824,6 @@ class FacebookIE(InfoExtractor): elif '>You must log in to continue' in webpage: self.raise_login_required() - def resolve_full_webpage(self, tahoe_data): - import urllib2 - user_agent = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.63 Safari/534.3' - headers = {'User-Agent': user_agent} - full_url = self._search_regex(r'"permalinkURL":"(.+?)"', tahoe_data.primary, 'video_url', fatal=False) - full_url = str(full_url).replace('\\', "") - req = urllib2.Request(full_url, None, headers) - response = urllib2.urlopen(req) - page = response.read() - response.close() - return page - class FacebookTahoeData: def __init__(self, extractor, page, video_id):