2015-10-15 18:23:09 -06:00
|
|
|
from .common import InfoExtractor
|
2015-10-28 09:42:01 -06:00
|
|
|
from ..utils import (
|
|
|
|
float_or_none,
|
2021-08-22 13:02:00 -06:00
|
|
|
parse_qs,
|
2018-08-07 10:27:08 -06:00
|
|
|
unified_timestamp,
|
2015-10-28 09:42:01 -06:00
|
|
|
)
|
2015-10-15 18:23:09 -06:00
|
|
|
|
|
|
|
|
|
|
|
class ClypIE(InfoExtractor):
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?clyp\.it/(?P<id>[a-z0-9]+)'
|
2018-08-07 10:27:08 -06:00
|
|
|
_TESTS = [{
|
2023-02-11 21:28:15 -07:00
|
|
|
'url': 'https://clyp.it/iynkjk4b',
|
|
|
|
'md5': '4bc6371c65210e7b372097fce4d92441',
|
2015-10-15 18:23:09 -06:00
|
|
|
'info_dict': {
|
2023-02-11 21:28:15 -07:00
|
|
|
'id': 'iynkjk4b',
|
|
|
|
'ext': 'ogg',
|
|
|
|
'title': 'research',
|
|
|
|
'description': '#Research',
|
|
|
|
'duration': 51.278,
|
|
|
|
'timestamp': 1435524981,
|
|
|
|
'upload_date': '20150628',
|
2015-10-15 18:23:09 -06:00
|
|
|
},
|
2018-08-07 10:27:08 -06:00
|
|
|
}, {
|
|
|
|
'url': 'https://clyp.it/b04p1odi?token=b0078e077e15835845c528a44417719d',
|
|
|
|
'info_dict': {
|
|
|
|
'id': 'b04p1odi',
|
2023-02-11 21:28:15 -07:00
|
|
|
'ext': 'ogg',
|
2018-08-07 10:27:08 -06:00
|
|
|
'title': 'GJ! (Reward Edit)',
|
|
|
|
'description': 'Metal Resistance (THE ONE edition)',
|
|
|
|
'duration': 177.789,
|
|
|
|
'timestamp': 1528241278,
|
|
|
|
'upload_date': '20180605',
|
|
|
|
},
|
|
|
|
'params': {
|
|
|
|
'skip_download': True,
|
|
|
|
},
|
2023-02-11 21:28:15 -07:00
|
|
|
}, {
|
|
|
|
'url': 'https://clyp.it/v42214lc',
|
|
|
|
'md5': '4aca4dfc3236fb6d6ddc4ea08314f33f',
|
|
|
|
'info_dict': {
|
|
|
|
'id': 'v42214lc',
|
|
|
|
'ext': 'wav',
|
|
|
|
'title': 'i dont wanna go (old version)',
|
|
|
|
'duration': 113.528,
|
|
|
|
'timestamp': 1607348505,
|
|
|
|
'upload_date': '20201207',
|
|
|
|
},
|
2018-08-07 10:27:08 -06:00
|
|
|
}]
|
2015-10-15 18:23:09 -06:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
audio_id = self._match_id(url)
|
|
|
|
|
2021-08-22 13:02:00 -06:00
|
|
|
qs = parse_qs(url)
|
2018-08-07 10:27:08 -06:00
|
|
|
token = qs.get('token', [None])[0]
|
|
|
|
|
|
|
|
query = {}
|
|
|
|
if token:
|
|
|
|
query['token'] = token
|
|
|
|
|
2015-10-28 09:42:01 -06:00
|
|
|
metadata = self._download_json(
|
2024-06-11 17:09:58 -06:00
|
|
|
f'https://api.clyp.it/{audio_id}', audio_id, query=query)
|
2015-10-28 09:42:01 -06:00
|
|
|
|
|
|
|
formats = []
|
|
|
|
for secure in ('', 'Secure'):
|
|
|
|
for ext in ('Ogg', 'Mp3'):
|
2024-06-11 17:09:58 -06:00
|
|
|
format_id = f'{secure}{ext}'
|
|
|
|
format_url = metadata.get(f'{format_id}Url')
|
2015-10-28 09:42:01 -06:00
|
|
|
if format_url:
|
|
|
|
formats.append({
|
|
|
|
'url': format_url,
|
|
|
|
'format_id': format_id,
|
|
|
|
'vcodec': 'none',
|
2023-02-11 21:28:15 -07:00
|
|
|
'acodec': ext.lower(),
|
2015-10-28 09:42:01 -06:00
|
|
|
})
|
2015-10-15 18:23:09 -06:00
|
|
|
|
2023-02-11 21:28:15 -07:00
|
|
|
page = self._download_webpage(url, video_id=audio_id)
|
|
|
|
wav_url = self._html_search_regex(
|
|
|
|
r'var\s*wavStreamUrl\s*=\s*["\'](?P<url>https?://[^\'"]+)', page, 'url', default=None)
|
|
|
|
if wav_url:
|
|
|
|
formats.append({
|
|
|
|
'url': wav_url,
|
|
|
|
'format_id': 'wavStreamUrl',
|
|
|
|
'vcodec': 'none',
|
|
|
|
'acodec': 'wav',
|
|
|
|
})
|
|
|
|
|
2015-10-28 09:42:01 -06:00
|
|
|
title = metadata['Title']
|
|
|
|
description = metadata.get('Description')
|
|
|
|
duration = float_or_none(metadata.get('Duration'))
|
2018-08-07 10:27:08 -06:00
|
|
|
timestamp = unified_timestamp(metadata.get('DateCreated'))
|
2015-10-15 18:23:09 -06:00
|
|
|
|
|
|
|
return {
|
|
|
|
'id': audio_id,
|
|
|
|
'title': title,
|
|
|
|
'description': description,
|
2015-10-28 09:42:01 -06:00
|
|
|
'duration': duration,
|
|
|
|
'timestamp': timestamp,
|
|
|
|
'formats': formats,
|
2015-10-15 18:23:09 -06:00
|
|
|
}
|