]>
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, Stimulate clicking the image box to launch video
50 video_page
= self
._search
_regex
('"(https\://plus\.google\.com/photos/.*?)",,"image/jpeg","video"\]',
51 webpage
, u
'video page URL')
52 webpage
= self
._download
_webpage
(video_page
, video_id
, u
'Downloading video page')
54 # Extract video links on video page
55 """Extract video links of all sizes"""
56 pattern
= '\d+,\d+,(\d+),"(http\://redirector\.googlevideo\.com.*?)"'
57 mobj
= re
.findall(pattern
, webpage
)
59 raise ExtractorError(u
'Unable to extract video links')
64 # Choose the lowest of the sort, i.e. highest resolution
66 # Only get the url. The resolution part in the tuple has no use anymore
67 video_url
= video_url
[-1]
68 # Treat escaped \u0026 style hex
70 video_url
= video_url
.decode("unicode_escape")
71 except AttributeError: # Python 3
72 video_url
= bytes(video_url
, 'ascii').decode('unicode-escape')
79 'upload_date': upload_date
,
81 'ext': video_extension
,