[clyp] Add support for token protected media (closes #17184)
This commit is contained in:
parent
a62460aa21
commit
d37dc6e1c9
1 changed files with 30 additions and 5 deletions
|
@ -1,15 +1,19 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
from ..compat import (
|
||||||
|
compat_parse_qs,
|
||||||
|
compat_urllib_parse_urlparse,
|
||||||
|
)
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
float_or_none,
|
float_or_none,
|
||||||
parse_iso8601,
|
unified_timestamp,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ClypIE(InfoExtractor):
|
class ClypIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:www\.)?clyp\.it/(?P<id>[a-z0-9]+)'
|
_VALID_URL = r'https?://(?:www\.)?clyp\.it/(?P<id>[a-z0-9]+)'
|
||||||
_TEST = {
|
_TESTS = [{
|
||||||
'url': 'https://clyp.it/ojz2wfah',
|
'url': 'https://clyp.it/ojz2wfah',
|
||||||
'md5': '1d4961036c41247ecfdcc439c0cddcbb',
|
'md5': '1d4961036c41247ecfdcc439c0cddcbb',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
|
@ -21,13 +25,34 @@ class ClypIE(InfoExtractor):
|
||||||
'timestamp': 1443515251,
|
'timestamp': 1443515251,
|
||||||
'upload_date': '20150929',
|
'upload_date': '20150929',
|
||||||
},
|
},
|
||||||
}
|
}, {
|
||||||
|
'url': 'https://clyp.it/b04p1odi?token=b0078e077e15835845c528a44417719d',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'b04p1odi',
|
||||||
|
'ext': 'mp3',
|
||||||
|
'title': 'GJ! (Reward Edit)',
|
||||||
|
'description': 'Metal Resistance (THE ONE edition)',
|
||||||
|
'duration': 177.789,
|
||||||
|
'timestamp': 1528241278,
|
||||||
|
'upload_date': '20180605',
|
||||||
|
},
|
||||||
|
'params': {
|
||||||
|
'skip_download': True,
|
||||||
|
},
|
||||||
|
}]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
audio_id = self._match_id(url)
|
audio_id = self._match_id(url)
|
||||||
|
|
||||||
|
qs = compat_parse_qs(compat_urllib_parse_urlparse(url).query)
|
||||||
|
token = qs.get('token', [None])[0]
|
||||||
|
|
||||||
|
query = {}
|
||||||
|
if token:
|
||||||
|
query['token'] = token
|
||||||
|
|
||||||
metadata = self._download_json(
|
metadata = self._download_json(
|
||||||
'https://api.clyp.it/%s' % audio_id, audio_id)
|
'https://api.clyp.it/%s' % audio_id, audio_id, query=query)
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
for secure in ('', 'Secure'):
|
for secure in ('', 'Secure'):
|
||||||
|
@ -45,7 +70,7 @@ class ClypIE(InfoExtractor):
|
||||||
title = metadata['Title']
|
title = metadata['Title']
|
||||||
description = metadata.get('Description')
|
description = metadata.get('Description')
|
||||||
duration = float_or_none(metadata.get('Duration'))
|
duration = float_or_none(metadata.get('Duration'))
|
||||||
timestamp = parse_iso8601(metadata.get('DateCreated'))
|
timestamp = unified_timestamp(metadata.get('DateCreated'))
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': audio_id,
|
'id': audio_id,
|
||||||
|
|
Loading…
Reference in a new issue