2 from __future__ import unicode_literals
6 from .common import InfoExtractor
10 compat_urllib_request,
16 class TapelyIE(InfoExtractor):
17 _VALID_URL = r'https?://(?:www\.)?tape\.ly/(?P<id>[A-Za-z0-9\-_]+)(?:/(?P<songnr>\d+))?'
18 _API_URL = 'http://tape.ly/showtape?id={0:}'
19 _S3_SONG_URL = 'http://mytape.s3.amazonaws.com/{0:}'
22 'url': 'http://tape.ly/my-grief-as-told-by-water',
25 'title': 'my grief as told by water',
26 'thumbnail': 're:^https?://.*\.png$',
28 'timestamp': 1411848286,
29 'description': 'For Robin and Ponkers, whom the tides of life have taken out to sea.',
34 'url': 'http://tape.ly/my-grief-as-told-by-water/1',
35 'md5': '79031f459fdec6530663b854cbc5715c',
38 'title': 'Dreaming Awake (My Brightest Diamond)',
44 def _real_extract(self, url):
45 mobj = re.match(self._VALID_URL, url)
46 display_id = mobj.group('id')
48 playlist_url = self._API_URL.format(display_id)
49 request = compat_urllib_request.Request(playlist_url)
50 request.add_header('X-Requested-With', 'XMLHttpRequest')
51 request.add_header('Accept', 'application/json')
53 playlist = self._download_json(request, display_id)
55 tape = playlist['tape']
58 for s in tape['songs']:
62 'duration': float_or_none(song.get('songduration'), 1000),
63 'title': song['title'],
65 if song['source'] == 'S3':
67 'url': self._S3_SONG_URL.format(song['filename']),
70 elif song['source'] == 'YT':
71 _, _, yt_id = song['filename'].split('/')
72 entry.update(self.url_result(yt_id, 'Youtube', video_id=yt_id))
75 self.report_warning('Unknown song source: %s' % song['source'])
77 if mobj.group('songnr'):
78 songnr = int(mobj.group('songnr')) - 1
80 return entries[songnr]
83 'No song with index: %s' % mobj.group('songnr'),
89 'display_id': display_id,
90 'title': tape['name'],
92 'thumbnail': tape.get('image_url'),
93 'description': clean_html(tape.get('subtext')),
94 'like_count': tape.get('likescount'),
95 'uploader_id': tape.get('user_id'),
96 'timestamp': parse_iso8601(tape.get('published_at')),