1
0
mirror of https://github.com/l1ving/youtube-dl synced 2025-03-10 06:57:17 +08:00

fix facebook thumbnail

This commit is contained in:
bhodaya 2020-06-29 09:28:58 +03:00
parent a1986b5bf2
commit 0f45a3da23
2 changed files with 2 additions and 15 deletions

View File

@ -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)

View File

@ -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):