]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/googleplus.py
4 from .common
import InfoExtractor
10 class GooglePlusIE(InfoExtractor
):
11 """Information extractor for plus.google.com."""
13 _VALID_URL
= r
'(?:https://)?plus\.google\.com/(?:[^/]+/)*?posts/(\w+)'
14 IE_NAME
= u
'plus.google'
16 def _real_extract(self
, url
):
18 mobj
= re
.match(self
._VALID
_URL
, url
)
20 raise ExtractorError(u
'Invalid URL: %s' % url
)
22 post_url
= mobj
.group(0)
23 video_id
= mobj
.group(1)
25 video_extension
= 'flv'
27 # Step 1, Retrieve post webpage to extract further information
28 webpage
= self
._download
_webpage
(post_url
, video_id
, u
'Downloading entry webpage')
30 self
.report_extraction(video_id
)
33 upload_date
= self
._html
_search
_regex
('title="Timestamp">(.*?)</a>',
34 webpage
, u
'upload date', fatal
=False)
36 # Convert timestring to a format suitable for filename
37 upload_date
= datetime
.datetime
.strptime(upload_date
, "%Y-%m-%d")
38 upload_date
= upload_date
.strftime('%Y%m%d')
41 uploader
= self
._html
_search
_regex
(r
'rel\="author".*?>(.*?)</a>',
42 webpage
, u
'uploader', fatal
=False)
45 # Get the first line for title
46 video_title
= self
._html
_search
_regex
(r
'<meta name\=\"Description\" content\=\"(.*?)[\n<"]',
47 webpage
, 'title', default
=u
'NA')
49 # Step 2, Simulate clicking the image box to launch video
50 DOMAIN
= 'https://plus.google.com'
51 video_page
= self
._search
_regex
(r
'<a href="((?:%s)?/photos/.*?)"' % re
.escape(DOMAIN
),
52 webpage
, u
'video page URL')
53 if not video_page
.startswith(DOMAIN
):
54 video_page
= DOMAIN
+ video_page
56 webpage
= self
._download
_webpage
(video_page
, video_id
, u
'Downloading video page')
58 # Extract video links on video page
59 """Extract video links of all sizes"""
60 pattern
= r
'\d+,\d+,(\d+),"(http\://redirector\.googlevideo\.com.*?)"'
61 mobj
= re
.findall(pattern
, webpage
)
63 raise ExtractorError(u
'Unable to extract video links')
68 # Choose the lowest of the sort, i.e. highest resolution
70 # Only get the url. The resolution part in the tuple has no use anymore
71 video_url
= video_url
[-1]
72 # Treat escaped \u0026 style hex
74 video_url
= video_url
.decode("unicode_escape")
75 except AttributeError: # Python 3
76 video_url
= bytes(video_url
, 'ascii').decode('unicode-escape')
83 'upload_date': upload_date
,
85 'ext': video_extension
,