1 from __future__ import unicode_literals
3 from .common import InfoExtractor
6 compat_urllib_parse_urlparse,
14 class ClypIE(InfoExtractor):
15 _VALID_URL = r'https?://(?:www\.)?clyp\.it/(?P<id>[a-z0-9]+)'
17 'url': 'https://clyp.it/ojz2wfah',
18 'md5': '1d4961036c41247ecfdcc439c0cddcbb',
22 'title': 'Krisson80 - bits wip wip',
23 'description': '#Krisson80BitsWipWip #chiptune\n#wip',
25 'timestamp': 1443515251,
26 'upload_date': '20150929',
29 'url': 'https://clyp.it/b04p1odi?token=b0078e077e15835845c528a44417719d',
33 'title': 'GJ! (Reward Edit)',
34 'description': 'Metal Resistance (THE ONE edition)',
36 'timestamp': 1528241278,
37 'upload_date': '20180605',
40 'skip_download': True,
44 def _real_extract(self, url):
45 audio_id = self._match_id(url)
47 qs = compat_parse_qs(compat_urllib_parse_urlparse(url).query)
48 token = qs.get('token', [None])[0]
52 query['token'] = token
54 metadata = self._download_json(
55 'https://api.clyp.it/%s' % audio_id, audio_id, query=query)
58 for secure in ('', 'Secure'):
59 for ext in ('Ogg', 'Mp3'):
60 format_id = '%s%s' % (secure, ext)
61 format_url = metadata.get('%sUrl' % format_id)
65 'format_id': format_id,
68 self._sort_formats(formats)
70 title = metadata['Title']
71 description = metadata.get('Description')
72 duration = float_or_none(metadata.get('Duration'))
73 timestamp = unified_timestamp(metadata.get('DateCreated'))
78 'description': description,
80 'timestamp': timestamp,