]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/vidme.py
1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
6 from ..compat
import compat_HTTPError
15 class VidmeIE(InfoExtractor
):
16 _VALID_URL
= r
'https?://vid\.me/(?:e/)?(?P<id>[\da-zA-Z]{,5})(?:[^\da-zA-Z]|$)'
18 'url': 'https://vid.me/QNB',
19 'md5': 'f42d05e7149aeaec5c037b17e5d3dc82',
23 'title': 'Fishing for piranha - the easy way',
24 'description': 'source: https://www.facebook.com/photo.php?v=312276045600871',
25 'thumbnail': 're:^https?://.*\.jpg',
26 'timestamp': 1406313244,
27 'upload_date': '20140725',
35 'url': 'https://vid.me/Gc6M',
36 'md5': 'f42d05e7149aeaec5c037b17e5d3dc82',
40 'title': 'O Mere Dil ke chain - Arnav and Khushi VM',
41 'thumbnail': 're:^https?://.*\.jpg',
42 'timestamp': 1441211642,
43 'upload_date': '20150902',
44 'uploader': 'SunshineM',
45 'uploader_id': '3552827',
53 'skip_download': True,
56 # tests uploader field
57 'url': 'https://vid.me/4Iib',
61 'title': 'The Carver',
62 'description': 'md5:e9c24870018ae8113be936645b93ba3c',
63 'thumbnail': 're:^https?://.*\.jpg',
64 'timestamp': 1433203629,
65 'upload_date': '20150602',
67 'uploader_id': '109747',
69 'duration': 97.859999999999999,
75 'skip_download': True,
78 # nsfw test from http://naked-yogi.tumblr.com/post/118312946248/naked-smoking-stretching
79 'url': 'https://vid.me/e/Wmur',
83 'title': 'naked smoking & stretching',
84 'thumbnail': 're:^https?://.*\.jpg',
85 'timestamp': 1430931613,
86 'upload_date': '20150506',
87 'uploader': 'naked-yogi',
88 'uploader_id': '1638622',
90 'duration': 653.26999999999998,
96 'skip_download': True,
100 'url': 'https://vid.me/dzGJ',
101 'only_matching': True,
104 'url': 'https://vid.me/Ox3G',
105 'only_matching': True,
108 'url': 'https://vid.me/KTPm',
109 'only_matching': True,
111 # no formats in the API response
112 'url': 'https://vid.me/e5g',
116 'title': 'Video upload (e5g)',
117 'thumbnail': 're:^https?://.*\.jpg',
118 'timestamp': 1401480195,
119 'upload_date': '20140530',
126 'comment_count': int,
129 'skip_download': True,
133 def _real_extract(self
, url
):
134 video_id
= self
._match
_id
(url
)
137 response
= self
._download
_json
(
138 'https://api.vid.me/videoByUrl/%s' % video_id
, video_id
)
139 except ExtractorError
as e
:
140 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
== 400:
141 response
= self
._parse
_json
(e
.cause
.read(), video_id
)
145 error
= response
.get('error')
147 raise ExtractorError(
148 '%s returned error: %s' % (self
.IE_NAME
, error
), expected
=True)
150 video
= response
['video']
152 if video
.get('state') == 'deleted':
153 raise ExtractorError(
154 'Vidme said: Sorry, this video has been deleted.',
157 if video
.get('state') in ('user-disabled', 'suspended'):
158 raise ExtractorError(
159 'Vidme said: This video has been suspended either due to a copyright claim, '
160 'or for violating the terms of use.',
164 'format_id': f
.get('type'),
166 'width': int_or_none(f
.get('width')),
167 'height': int_or_none(f
.get('height')),
168 'preference': 0 if f
.get('type', '').endswith('clip') else 1,
169 } for f
in video
.get('formats', []) if f
.get('uri')]
171 if not formats
and video
.get('complete_url'):
173 'url': video
.get('complete_url'),
174 'width': int_or_none(video
.get('width')),
175 'height': int_or_none(video
.get('height')),
178 self
._sort
_formats
(formats
)
180 title
= video
['title']
181 description
= video
.get('description')
182 thumbnail
= video
.get('thumbnail_url')
183 timestamp
= parse_iso8601(video
.get('date_created'), ' ')
184 uploader
= video
.get('user', {}).get('username')
185 uploader_id
= video
.get('user', {}).get('user_id')
186 age_limit
= 18 if video
.get('nsfw') is True else 0
187 duration
= float_or_none(video
.get('duration'))
188 view_count
= int_or_none(video
.get('view_count'))
189 like_count
= int_or_none(video
.get('likes_count'))
190 comment_count
= int_or_none(video
.get('comment_count'))
194 'title': title
or 'Video upload (%s)' % video_id
,
195 'description': description
,
196 'thumbnail': thumbnail
,
197 'uploader': uploader
,
198 'uploader_id': uploader_id
,
199 'age_limit': age_limit
,
200 'timestamp': timestamp
,
201 'duration': duration
,
202 'view_count': view_count
,
203 'like_count': like_count
,
204 'comment_count': comment_count
,
209 class VidmeUserIE(InfoExtractor
):
210 _VALID_URL
= r
'https?://vid\.me/(?:e/)?(?P<id>[\da-zA-Z]{6,})'
212 'url': 'https://vid.me/EFARCHIVE',
215 'title': 'EFARCHIVE',
217 'playlist_mincount': 238,
220 # Max possible limit according to https://docs.vid.me/#api-Videos-List
223 def _entries(self
, user_id
, user_name
):
224 for page_num
in itertools
.count(1):
225 page
= self
._download
_json
(
226 'https://api.vid.me/videos/list?user=%s&limit=%d&offset=%d'
227 % (user_id
, self
._LIMIT
, (page_num
- 1) * self
._LIMIT
), user_name
,
228 'Downloading user page %d' % page_num
)
230 videos
= page
.get('videos', [])
235 video_url
= video
.get('full_url') or video
.get('embed_url')
237 yield self
.url_result(video_url
, VidmeIE
.ie_key())
239 total
= int_or_none(page
.get('page', {}).get('total'))
240 if total
and self
._LIMIT
* page_num
>= total
:
243 def _real_extract(self
, url
):
244 user_name
= self
._match
_id
(url
)
246 user_id
= self
._download
_json
(
247 'https://api.vid.me/userByUsername?username=%s' % user_name
,
248 user_name
)['user']['user_id']
250 return self
.playlist_result(self
._entries
(user_id
, user_name
), user_id
, user_name
)