]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/vidme.py
1 from __future__
import unicode_literals
3 from .common
import InfoExtractor
4 from ..compat
import compat_HTTPError
13 class VidmeIE(InfoExtractor
):
14 _VALID_URL
= r
'https?://vid\.me/(?:e/)?(?P<id>[\da-zA-Z]+)'
16 'url': 'https://vid.me/QNB',
17 'md5': 'c62f1156138dc3323902188c5b5a8bd6',
21 'title': 'Fishing for piranha - the easy way',
22 'description': 'source: https://www.facebook.com/photo.php?v=312276045600871',
23 'thumbnail': 're:^https?://.*\.jpg',
24 'timestamp': 1406313244,
25 'upload_date': '20140725',
33 'url': 'https://vid.me/Gc6M',
34 'md5': 'f42d05e7149aeaec5c037b17e5d3dc82',
38 'title': 'O Mere Dil ke chain - Arnav and Khushi VM',
39 'thumbnail': 're:^https?://.*\.jpg',
40 'timestamp': 1441211642,
41 'upload_date': '20150902',
42 'uploader': 'SunshineM',
43 'uploader_id': '3552827',
51 'skip_download': True,
54 # tests uploader field
55 'url': 'https://vid.me/4Iib',
59 'title': 'The Carver',
60 'description': 'md5:e9c24870018ae8113be936645b93ba3c',
61 'thumbnail': 're:^https?://.*\.jpg',
62 'timestamp': 1433203629,
63 'upload_date': '20150602',
65 'uploader_id': '109747',
67 'duration': 97.859999999999999,
73 'skip_download': True,
76 # nsfw test from http://naked-yogi.tumblr.com/post/118312946248/naked-smoking-stretching
77 'url': 'https://vid.me/e/Wmur',
81 'title': 'naked smoking & stretching',
82 'thumbnail': 're:^https?://.*\.jpg',
83 'timestamp': 1430931613,
84 'upload_date': '20150506',
85 'uploader': 'naked-yogi',
86 'uploader_id': '1638622',
88 'duration': 653.26999999999998,
94 'skip_download': True,
98 def _real_extract(self
, url
):
99 video_id
= self
._match
_id
(url
)
102 response
= self
._download
_json
(
103 'https://api.vid.me/videoByUrl/%s' % video_id
, video_id
)
104 except ExtractorError
as e
:
105 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
== 400:
106 response
= self
._parse
_json
(e
.cause
.read(), video_id
)
110 error
= response
.get('error')
112 raise ExtractorError(
113 '%s returned error: %s' % (self
.IE_NAME
, error
), expected
=True)
115 video
= response
['video']
117 if video
.get('state') == 'user-disabled':
118 raise ExtractorError(
119 'Vidme said: This video has been suspended either due to a copyright claim, '
120 'or for violating the terms of use.',
124 'format_id': f
.get('type'),
126 'width': int_or_none(f
.get('width')),
127 'height': int_or_none(f
.get('height')),
128 'preference': 0 if f
.get('type', '').endswith('clip') else 1,
129 } for f
in video
.get('formats', []) if f
.get('uri')]
130 self
._sort
_formats
(formats
)
132 title
= video
['title']
133 description
= video
.get('description')
134 thumbnail
= video
.get('thumbnail_url')
135 timestamp
= parse_iso8601(video
.get('date_created'), ' ')
136 uploader
= video
.get('user', {}).get('username')
137 uploader_id
= video
.get('user', {}).get('user_id')
138 age_limit
= 18 if video
.get('nsfw') is True else 0
139 duration
= float_or_none(video
.get('duration'))
140 view_count
= int_or_none(video
.get('view_count'))
141 like_count
= int_or_none(video
.get('likes_count'))
142 comment_count
= int_or_none(video
.get('comment_count'))
147 'description': description
,
148 'thumbnail': thumbnail
,
149 'uploader': uploader
,
150 'uploader_id': uploader_id
,
151 'age_limit': age_limit
,
152 'timestamp': timestamp
,
153 'duration': duration
,
154 'view_count': view_count
,
155 'like_count': like_count
,
156 'comment_count': comment_count
,