]>
Commit | Line | Data |
---|---|---|
5da6bd00 LP |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
4 | from .common import InfoExtractor | |
a65d4e7f S |
5 | from ..utils import ( |
6 | parse_duration, | |
7 | int_or_none, | |
8 | ) | |
5da6bd00 LP |
9 | |
10 | ||
11 | class ChirbitIE(InfoExtractor): | |
04e8c110 | 12 | IE_NAME = 'chirbit' |
a65d4e7f S |
13 | _VALID_URL = r'https?://(?:www\.)?chirb\.it/(?:(?:wp|pl)/|fb_chirbit_player\.swf\?key=)?(?P<id>[\da-zA-Z]+)' |
14 | _TESTS = [{ | |
5da6bd00 LP |
15 | 'url': 'http://chirb.it/PrIPv5', |
16 | 'md5': '9847b0dad6ac3e074568bf2cfb197de8', | |
17 | 'info_dict': { | |
18 | 'id': 'PrIPv5', | |
5da6bd00 LP |
19 | 'ext': 'mp3', |
20 | 'title': 'Фасадстрой', | |
a65d4e7f S |
21 | 'duration': 52, |
22 | 'view_count': int, | |
23 | 'comment_count': int, | |
5da6bd00 | 24 | } |
a65d4e7f S |
25 | }, { |
26 | 'url': 'https://chirb.it/fb_chirbit_player.swf?key=PrIPv5', | |
27 | 'only_matching': True, | |
28 | }] | |
5da6bd00 LP |
29 | |
30 | def _real_extract(self, url): | |
a65d4e7f S |
31 | audio_id = self._match_id(url) |
32 | ||
33 | webpage = self._download_webpage( | |
34 | 'http://chirb.it/%s' % audio_id, audio_id) | |
35 | ||
36 | audio_url = self._search_regex( | |
37 | r'"setFile"\s*,\s*"([^"]+)"', webpage, 'audio url') | |
5da6bd00 | 38 | |
a65d4e7f S |
39 | title = self._search_regex( |
40 | r'itemprop="name">([^<]+)', webpage, 'title') | |
41 | duration = parse_duration(self._html_search_meta( | |
42 | 'duration', webpage, 'duration', fatal=False)) | |
43 | view_count = int_or_none(self._search_regex( | |
44 | r'itemprop="playCount"\s*>(\d+)', webpage, | |
45 | 'listen count', fatal=False)) | |
46 | comment_count = int_or_none(self._search_regex( | |
47 | r'>(\d+) Comments?:', webpage, | |
48 | 'comment count', fatal=False)) | |
5da6bd00 LP |
49 | |
50 | return { | |
a65d4e7f S |
51 | 'id': audio_id, |
52 | 'url': audio_url, | |
53 | 'title': title, | |
54 | 'duration': duration, | |
55 | 'view_count': view_count, | |
56 | 'comment_count': comment_count, | |
5da6bd00 | 57 | } |
365577f5 | 58 | |
a65d4e7f | 59 | |
365577f5 | 60 | class ChirbitProfileIE(InfoExtractor): |
04e8c110 | 61 | IE_NAME = 'chirbit:profile' |
a65d4e7f | 62 | _VALID_URL = r'https?://(?:www\.)?chirbit.com/(?:rss/)?(?P<id>[^/]+)' |
365577f5 LP |
63 | _TEST = { |
64 | 'url': 'http://chirbit.com/ScarletBeauty', | |
365577f5 | 65 | 'info_dict': { |
a65d4e7f S |
66 | 'id': 'ScarletBeauty', |
67 | 'title': 'Chirbits by ScarletBeauty', | |
68 | }, | |
69 | 'playlist_mincount': 3, | |
365577f5 LP |
70 | } |
71 | ||
72 | def _real_extract(self, url): | |
73 | profile_id = self._match_id(url) | |
74 | ||
a65d4e7f S |
75 | rss = self._download_xml( |
76 | 'http://chirbit.com/rss/%s' % profile_id, profile_id) | |
365577f5 | 77 | |
a65d4e7f S |
78 | entries = [ |
79 | self.url_result(audio_url.text, 'Chirbit') | |
80 | for audio_url in rss.findall('./channel/item/link')] | |
365577f5 | 81 | |
a65d4e7f | 82 | title = rss.find('./channel/title').text |
365577f5 | 83 | |
a65d4e7f | 84 | return self.playlist_result(entries, profile_id, title) |