]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/vine.py
42995226e584b0ce4e0d207b6b702157ec6f4030
1 from __future__
import unicode_literals
7 from .common
import InfoExtractor
8 from ..utils
import unified_strdate
11 class VineIE(InfoExtractor
):
12 _VALID_URL
= r
'https?://(?:www\.)?vine\.co/v/(?P<id>\w+)'
14 'url': 'https://vine.co/v/b9KOOWX7HUx',
15 'md5': '2f36fed6235b16da96ce9b4dc890940d',
20 'description': 'Chicken.',
21 'upload_date': '20130519',
22 'uploader': 'Jack Dorsey',
27 def _real_extract(self
, url
):
28 mobj
= re
.match(self
._VALID
_URL
, url
)
29 video_id
= mobj
.group('id')
31 webpage
= self
._download
_webpage
('https://vine.co/v/' + video_id
, video_id
)
33 data
= json
.loads(self
._html
_search
_regex
(
34 r
'window\.POST_DATA = { %s: ({.+?}) }' % video_id
, webpage
, 'vine data'))
38 'url': data
['videoLowURL'],
43 'url': data
['videoUrl'],
45 'format_id': 'standard',
51 'title': self
._og
_search
_title
(webpage
),
52 'description': data
['description'],
53 'thumbnail': data
['thumbnailUrl'],
54 'upload_date': unified_strdate(data
['created']),
55 'uploader': data
['username'],
56 'uploader_id': data
['userIdStr'],
57 'like_count': data
['likes']['count'],
58 'comment_count': data
['comments']['count'],
59 'repost_count': data
['reposts']['count'],
64 class VineUserIE(InfoExtractor
):
66 _VALID_URL
= r
'(?:https?://)?vine\.co/(?P<user>[^/]+)/?(\?.*)?$'
67 _VINE_BASE_URL
= "https://vine.co/"
69 'url': 'https://vine.co/Visa',
73 'playlist_mincount': 46,
76 def _real_extract(self
, url
):
77 mobj
= re
.match(self
._VALID
_URL
, url
)
78 user
= mobj
.group('user')
80 profile_url
= "%sapi/users/profiles/vanity/%s" % (
81 self
._VINE
_BASE
_URL
, user
)
82 profile_data
= self
._download
_json
(
83 profile_url
, user
, note
='Downloading user profile data')
85 user_id
= profile_data
['data']['userId']
87 for pagenum
in itertools
.count(1):
88 timeline_url
= "%sapi/timelines/users/%s?page=%s" % (
89 self
._VINE
_BASE
_URL
, user_id
, pagenum
)
90 timeline_page
= self
._download
_json
(
91 timeline_url
, user
, note
='Downloading page %d' % pagenum
)
92 timeline_data
.extend(timeline_page
['data']['records'])
93 if timeline_page
['data']['nextPage'] is None:
97 self
.url_result(e
['permalinkUrl'], 'Vine') for e
in timeline_data
]
98 return self
.playlist_result(entries
, user
)