]>
Commit | Line | Data |
---|---|---|
2ecbd2ad | 1 | import re |
0c070681 | 2 | |
5da6bd00 | 3 | from .common import InfoExtractor |
cf282071 | 4 | from ..compat import compat_b64decode |
0c070681 | 5 | from ..utils import parse_duration |
5da6bd00 LP |
6 | |
7 | ||
8 | class ChirbitIE(InfoExtractor): | |
04e8c110 | 9 | IE_NAME = 'chirbit' |
a65d4e7f S |
10 | _VALID_URL = r'https?://(?:www\.)?chirb\.it/(?:(?:wp|pl)/|fb_chirbit_player\.swf\?key=)?(?P<id>[\da-zA-Z]+)' |
11 | _TESTS = [{ | |
0c070681 | 12 | 'url': 'http://chirb.it/be2abG', |
5da6bd00 | 13 | 'info_dict': { |
0c070681 | 14 | 'id': 'be2abG', |
5da6bd00 | 15 | 'ext': 'mp3', |
0c070681 S |
16 | 'title': 'md5:f542ea253f5255240be4da375c6a5d7e', |
17 | 'description': 'md5:f24a4e22a71763e32da5fed59e47c770', | |
18 | 'duration': 306, | |
30dda24d | 19 | 'uploader': 'Gerryaudio', |
0c070681 S |
20 | }, |
21 | 'params': { | |
22 | 'skip_download': True, | |
5da6bd00 | 23 | } |
a65d4e7f S |
24 | }, { |
25 | 'url': 'https://chirb.it/fb_chirbit_player.swf?key=PrIPv5', | |
26 | 'only_matching': True, | |
0c070681 S |
27 | }, { |
28 | 'url': 'https://chirb.it/wp/MN58c2', | |
29 | 'only_matching': True, | |
a65d4e7f | 30 | }] |
5da6bd00 LP |
31 | |
32 | def _real_extract(self, url): | |
a65d4e7f S |
33 | audio_id = self._match_id(url) |
34 | ||
35 | webpage = self._download_webpage( | |
36 | 'http://chirb.it/%s' % audio_id, audio_id) | |
37 | ||
0c070681 S |
38 | data_fd = self._search_regex( |
39 | r'data-fd=(["\'])(?P<url>(?:(?!\1).)+)\1', | |
40 | webpage, 'data fd', group='url') | |
41 | ||
42 | # Reverse engineered from https://chirb.it/js/chirbit.player.js (look | |
43 | # for soundURL) | |
cf282071 | 44 | audio_url = compat_b64decode(data_fd[::-1]).decode('utf-8') |
5da6bd00 | 45 | |
a65d4e7f | 46 | title = self._search_regex( |
0c070681 S |
47 | r'class=["\']chirbit-title["\'][^>]*>([^<]+)', webpage, 'title') |
48 | description = self._search_regex( | |
49 | r'<h3>Description</h3>\s*<pre[^>]*>([^<]+)</pre>', | |
50 | webpage, 'description', default=None) | |
51 | duration = parse_duration(self._search_regex( | |
52 | r'class=["\']c-length["\'][^>]*>([^<]+)', | |
53 | webpage, 'duration', fatal=False)) | |
30dda24d GG |
54 | uploader = self._search_regex( |
55 | r'id=["\']chirbit-username["\'][^>]*>([^<]+)', | |
56 | webpage, 'uploader', fatal=False) | |
5da6bd00 LP |
57 | |
58 | return { | |
a65d4e7f S |
59 | 'id': audio_id, |
60 | 'url': audio_url, | |
61 | 'title': title, | |
0c070681 | 62 | 'description': description, |
a65d4e7f | 63 | 'duration': duration, |
30dda24d | 64 | 'uploader': uploader, |
5da6bd00 | 65 | } |
365577f5 | 66 | |
a65d4e7f | 67 | |
365577f5 | 68 | class ChirbitProfileIE(InfoExtractor): |
04e8c110 | 69 | IE_NAME = 'chirbit:profile' |
92519402 | 70 | _VALID_URL = r'https?://(?:www\.)?chirbit\.com/(?:rss/)?(?P<id>[^/]+)' |
365577f5 LP |
71 | _TEST = { |
72 | 'url': 'http://chirbit.com/ScarletBeauty', | |
365577f5 | 73 | 'info_dict': { |
a65d4e7f | 74 | 'id': 'ScarletBeauty', |
a65d4e7f S |
75 | }, |
76 | 'playlist_mincount': 3, | |
365577f5 LP |
77 | } |
78 | ||
79 | def _real_extract(self, url): | |
80 | profile_id = self._match_id(url) | |
81 | ||
2ecbd2ad | 82 | webpage = self._download_webpage(url, profile_id) |
365577f5 | 83 | |
a65d4e7f | 84 | entries = [ |
2ecbd2ad YCH |
85 | self.url_result(self._proto_relative_url('//chirb.it/' + video_id)) |
86 | for _, video_id in re.findall(r'<input[^>]+id=([\'"])copy-btn-(?P<id>[0-9a-zA-Z]+)\1', webpage)] | |
365577f5 | 87 | |
2ecbd2ad | 88 | return self.playlist_result(entries, profile_id) |