]>
Commit | Line | Data |
---|---|---|
38349518 CR |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
e825c380 | 4 | import os.path |
38349518 CR |
5 | import re |
6 | ||
7 | from .common import InfoExtractor | |
1cc79574 | 8 | from ..compat import ( |
38349518 CR |
9 | compat_urllib_parse, |
10 | compat_urllib_request, | |
11 | ) | |
12 | ||
13 | ||
589d3d7c | 14 | class MonikerIE(InfoExtractor): |
0529eef5 | 15 | IE_DESC = 'allmyvideos.net and vidspot.net' |
37bfe8ac | 16 | _VALID_URL = r'https?://(?:www\.)?(?:allmyvideos|vidspot)\.net/(?P<id>[a-zA-Z0-9_-]+)' |
38349518 | 17 | |
0529eef5 | 18 | _TESTS = [{ |
38349518 | 19 | 'url': 'http://allmyvideos.net/jih3nce3x6wn', |
e825c380 | 20 | 'md5': '710883dee1bfc370ecf9fa6a89307c88', |
38349518 CR |
21 | 'info_dict': { |
22 | 'id': 'jih3nce3x6wn', | |
23 | 'ext': 'mp4', | |
24 | 'title': 'youtube-dl test video', | |
25 | }, | |
0529eef5 PH |
26 | }, { |
27 | 'url': 'http://vidspot.net/l2ngsmhs8ci5', | |
28 | 'md5': '710883dee1bfc370ecf9fa6a89307c88', | |
29 | 'info_dict': { | |
30 | 'id': 'l2ngsmhs8ci5', | |
31 | 'ext': 'mp4', | |
32 | 'title': 'youtube-dl test video', | |
33 | }, | |
37bfe8ac PH |
34 | }, { |
35 | 'url': 'https://www.vidspot.net/l2ngsmhs8ci5', | |
36 | 'only_matching': True, | |
0529eef5 | 37 | }] |
38349518 CR |
38 | |
39 | def _real_extract(self, url): | |
1cc79574 | 40 | video_id = self._match_id(url) |
7cdd5339 | 41 | orig_webpage = self._download_webpage(url, video_id) |
1cc79574 | 42 | |
7cdd5339 | 43 | fields = re.findall(r'type="hidden" name="(.+?)"\s* value="?(.+?)">', orig_webpage) |
e825c380 | 44 | data = dict(fields) |
7cdd5339 CR |
45 | |
46 | post = compat_urllib_parse.urlencode(data) | |
47 | headers = { | |
48 | b'Content-Type': b'application/x-www-form-urlencoded', | |
49 | } | |
50 | req = compat_urllib_request.Request(url, post, headers) | |
e825c380 PH |
51 | webpage = self._download_webpage( |
52 | req, video_id, note='Downloading video page ...') | |
53 | ||
54 | title = os.path.splitext(data['fname'])[0] | |
7cdd5339 | 55 | |
5f6a1245 | 56 | # Could be several links with different quality |
7cdd5339 | 57 | links = re.findall(r'"file" : "?(.+?)",', webpage) |
e825c380 PH |
58 | # Assume the links are ordered in quality |
59 | formats = [{ | |
60 | 'url': l, | |
61 | 'quality': i, | |
62 | } for i, l in enumerate(links)] | |
63 | self._sort_formats(formats) | |
7cdd5339 CR |
64 | |
65 | return { | |
66 | 'id': video_id, | |
e825c380 PH |
67 | 'title': title, |
68 | 'formats': formats, | |
69 | } |