]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/tapely.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
18 class TapelyIE(InfoExtractor
):
19 _VALID_URL
= r
'https?://(?:www\.)?(?:tape\.ly|tapely\.com)/(?P<id>[A-Za-z0-9\-_]+)(?:/(?P<songnr>\d+))?'
20 _API_URL
= 'http://tape.ly/showtape?id={0:}'
21 _S3_SONG_URL
= 'http://mytape.s3.amazonaws.com/{0:}'
22 _SOUNDCLOUD_SONG_URL
= 'http://api.soundcloud.com{0:}'
25 'url': 'http://tape.ly/my-grief-as-told-by-water',
28 'title': 'my grief as told by water',
29 'thumbnail': 're:^https?://.*\.png$',
31 'timestamp': 1411848286,
32 'description': 'For Robin and Ponkers, whom the tides of life have taken out to sea.',
37 'url': 'http://tape.ly/my-grief-as-told-by-water/1',
38 'md5': '79031f459fdec6530663b854cbc5715c',
41 'title': 'Dreaming Awake (My Brightest Diamond)',
46 'url': 'https://tapely.com/my-grief-as-told-by-water',
47 'only_matching': True,
51 def _real_extract(self
, url
):
52 mobj
= re
.match(self
._VALID
_URL
, url
)
53 display_id
= mobj
.group('id')
55 playlist_url
= self
._API
_URL
.format(display_id
)
56 request
= compat_urllib_request
.Request(playlist_url
)
57 request
.add_header('X-Requested-With', 'XMLHttpRequest')
58 request
.add_header('Accept', 'application/json')
59 request
.add_header('Referer', url
)
61 playlist
= self
._download
_json
(request
, display_id
)
63 tape
= playlist
['tape']
66 for s
in tape
['songs']:
70 'duration': float_or_none(song
.get('songduration'), 1000),
71 'title': song
['title'],
73 if song
['source'] == 'S3':
75 'url': self
._S
3_SONG
_URL
.format(song
['filename']),
78 elif song
['source'] == 'YT':
79 self
.to_screen('YouTube video detected')
80 yt_id
= song
['filename'].replace('/youtube/', '')
81 entry
.update(self
.url_result(yt_id
, 'Youtube', video_id
=yt_id
))
83 elif song
['source'] == 'SC':
84 self
.to_screen('SoundCloud song detected')
85 sc_url
= self
._SOUNDCLOUD
_SONG
_URL
.format(song
['filename'])
86 entry
.update(self
.url_result(sc_url
, 'Soundcloud'))
89 self
.report_warning('Unknown song source: %s' % song
['source'])
91 if mobj
.group('songnr'):
92 songnr
= int(mobj
.group('songnr')) - 1
94 return entries
[songnr
]
97 'No song with index: %s' % mobj
.group('songnr'),
103 'display_id': display_id
,
104 'title': tape
['name'],
106 'thumbnail': tape
.get('image_url'),
107 'description': clean_html(tape
.get('subtext')),
108 'like_count': tape
.get('likescount'),
109 'uploader_id': tape
.get('user_id'),
110 'timestamp': parse_iso8601(tape
.get('published_at')),