You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
3.8 KiB

Switch codebase to use sanitized_Request instead of compat_urllib_request.Request [downloader/dash] Use sanitized_Request [downloader/http] Use sanitized_Request [atresplayer] Use sanitized_Request [bambuser] Use sanitized_Request [bliptv] Use sanitized_Request [brightcove] Use sanitized_Request [cbs] Use sanitized_Request [ceskatelevize] Use sanitized_Request [collegerama] Use sanitized_Request [extractor/common] Use sanitized_Request [crunchyroll] Use sanitized_Request [dailymotion] Use sanitized_Request [dcn] Use sanitized_Request [dramafever] Use sanitized_Request [dumpert] Use sanitized_Request [eitb] Use sanitized_Request [escapist] Use sanitized_Request [everyonesmixtape] Use sanitized_Request [extremetube] Use sanitized_Request [facebook] Use sanitized_Request [fc2] Use sanitized_Request [flickr] Use sanitized_Request [4tube] Use sanitized_Request [gdcvault] Use sanitized_Request [extractor/generic] Use sanitized_Request [hearthisat] Use sanitized_Request [hotnewhiphop] Use sanitized_Request [hypem] Use sanitized_Request [iprima] Use sanitized_Request [ivi] Use sanitized_Request [keezmovies] Use sanitized_Request [letv] Use sanitized_Request [lynda] Use sanitized_Request [metacafe] Use sanitized_Request [minhateca] Use sanitized_Request [miomio] Use sanitized_Request [meovideo] Use sanitized_Request [mofosex] Use sanitized_Request [moniker] Use sanitized_Request [mooshare] Use sanitized_Request [movieclips] Use sanitized_Request [mtv] Use sanitized_Request [myvideo] Use sanitized_Request [neteasemusic] Use sanitized_Request [nfb] Use sanitized_Request [niconico] Use sanitized_Request [noco] Use sanitized_Request [nosvideo] Use sanitized_Request [novamov] Use sanitized_Request [nowness] Use sanitized_Request [nuvid] Use sanitized_Request [played] Use sanitized_Request [pluralsight] Use sanitized_Request [pornhub] Use sanitized_Request [pornotube] Use sanitized_Request [primesharetv] Use sanitized_Request [promptfile] Use sanitized_Request [qqmusic] Use sanitized_Request [rtve] Use sanitized_Request [safari] Use sanitized_Request [sandia] Use sanitized_Request [shared] Use sanitized_Request [sharesix] Use sanitized_Request [sina] Use sanitized_Request [smotri] Use sanitized_Request [sohu] Use sanitized_Request [spankwire] Use sanitized_Request [sportdeutschland] Use sanitized_Request [streamcloud] Use sanitized_Request [streamcz] Use sanitized_Request [tapely] Use sanitized_Request [tube8] Use sanitized_Request [tubitv] Use sanitized_Request [twitch] Use sanitized_Request [twitter] Use sanitized_Request [udemy] Use sanitized_Request [vbox7] Use sanitized_Request [veoh] Use sanitized_Request [vessel] Use sanitized_Request [vevo] Use sanitized_Request [viddler] Use sanitized_Request [videomega] Use sanitized_Request [viewvster] Use sanitized_Request [viki] Use sanitized_Request [vk] Use sanitized_Request [vodlocker] Use sanitized_Request [voicerepublic] Use sanitized_Request [wistia] Use sanitized_Request [xfileshare] Use sanitized_Request [xtube] Use sanitized_Request [xvideos] Use sanitized_Request [yandexmusic] Use sanitized_Request [youku] Use sanitized_Request [youporn] Use sanitized_Request [youtube] Use sanitized_Request [patreon] Use sanitized_Request [extractor/common] Remove unused import [nfb] PEP 8
9 years ago
Switch codebase to use sanitized_Request instead of compat_urllib_request.Request [downloader/dash] Use sanitized_Request [downloader/http] Use sanitized_Request [atresplayer] Use sanitized_Request [bambuser] Use sanitized_Request [bliptv] Use sanitized_Request [brightcove] Use sanitized_Request [cbs] Use sanitized_Request [ceskatelevize] Use sanitized_Request [collegerama] Use sanitized_Request [extractor/common] Use sanitized_Request [crunchyroll] Use sanitized_Request [dailymotion] Use sanitized_Request [dcn] Use sanitized_Request [dramafever] Use sanitized_Request [dumpert] Use sanitized_Request [eitb] Use sanitized_Request [escapist] Use sanitized_Request [everyonesmixtape] Use sanitized_Request [extremetube] Use sanitized_Request [facebook] Use sanitized_Request [fc2] Use sanitized_Request [flickr] Use sanitized_Request [4tube] Use sanitized_Request [gdcvault] Use sanitized_Request [extractor/generic] Use sanitized_Request [hearthisat] Use sanitized_Request [hotnewhiphop] Use sanitized_Request [hypem] Use sanitized_Request [iprima] Use sanitized_Request [ivi] Use sanitized_Request [keezmovies] Use sanitized_Request [letv] Use sanitized_Request [lynda] Use sanitized_Request [metacafe] Use sanitized_Request [minhateca] Use sanitized_Request [miomio] Use sanitized_Request [meovideo] Use sanitized_Request [mofosex] Use sanitized_Request [moniker] Use sanitized_Request [mooshare] Use sanitized_Request [movieclips] Use sanitized_Request [mtv] Use sanitized_Request [myvideo] Use sanitized_Request [neteasemusic] Use sanitized_Request [nfb] Use sanitized_Request [niconico] Use sanitized_Request [noco] Use sanitized_Request [nosvideo] Use sanitized_Request [novamov] Use sanitized_Request [nowness] Use sanitized_Request [nuvid] Use sanitized_Request [played] Use sanitized_Request [pluralsight] Use sanitized_Request [pornhub] Use sanitized_Request [pornotube] Use sanitized_Request [primesharetv] Use sanitized_Request [promptfile] Use sanitized_Request [qqmusic] Use sanitized_Request [rtve] Use sanitized_Request [safari] Use sanitized_Request [sandia] Use sanitized_Request [shared] Use sanitized_Request [sharesix] Use sanitized_Request [sina] Use sanitized_Request [smotri] Use sanitized_Request [sohu] Use sanitized_Request [spankwire] Use sanitized_Request [sportdeutschland] Use sanitized_Request [streamcloud] Use sanitized_Request [streamcz] Use sanitized_Request [tapely] Use sanitized_Request [tube8] Use sanitized_Request [tubitv] Use sanitized_Request [twitch] Use sanitized_Request [twitter] Use sanitized_Request [udemy] Use sanitized_Request [vbox7] Use sanitized_Request [veoh] Use sanitized_Request [vessel] Use sanitized_Request [vevo] Use sanitized_Request [viddler] Use sanitized_Request [videomega] Use sanitized_Request [viewvster] Use sanitized_Request [viki] Use sanitized_Request [vk] Use sanitized_Request [vodlocker] Use sanitized_Request [voicerepublic] Use sanitized_Request [wistia] Use sanitized_Request [xfileshare] Use sanitized_Request [xtube] Use sanitized_Request [xvideos] Use sanitized_Request [yandexmusic] Use sanitized_Request [youku] Use sanitized_Request [youporn] Use sanitized_Request [youtube] Use sanitized_Request [patreon] Use sanitized_Request [extractor/common] Remove unused import [nfb] PEP 8
9 years ago
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. clean_html,
  7. ExtractorError,
  8. float_or_none,
  9. parse_iso8601,
  10. sanitized_Request,
  11. )
  12. class TapelyIE(InfoExtractor):
  13. _VALID_URL = r'https?://(?:www\.)?(?:tape\.ly|tapely\.com)/(?P<id>[A-Za-z0-9\-_]+)(?:/(?P<songnr>\d+))?'
  14. _API_URL = 'http://tape.ly/showtape?id={0:}'
  15. _S3_SONG_URL = 'http://mytape.s3.amazonaws.com/{0:}'
  16. _SOUNDCLOUD_SONG_URL = 'http://api.soundcloud.com{0:}'
  17. _TESTS = [
  18. {
  19. 'url': 'http://tape.ly/my-grief-as-told-by-water',
  20. 'info_dict': {
  21. 'id': 23952,
  22. 'title': 'my grief as told by water',
  23. 'thumbnail': 're:^https?://.*\.png$',
  24. 'uploader_id': 16484,
  25. 'timestamp': 1411848286,
  26. 'description': 'For Robin and Ponkers, whom the tides of life have taken out to sea.',
  27. },
  28. 'playlist_count': 13,
  29. },
  30. {
  31. 'url': 'http://tape.ly/my-grief-as-told-by-water/1',
  32. 'md5': '79031f459fdec6530663b854cbc5715c',
  33. 'info_dict': {
  34. 'id': 258464,
  35. 'title': 'Dreaming Awake (My Brightest Diamond)',
  36. 'ext': 'm4a',
  37. },
  38. },
  39. {
  40. 'url': 'https://tapely.com/my-grief-as-told-by-water',
  41. 'only_matching': True,
  42. },
  43. ]
  44. def _real_extract(self, url):
  45. mobj = re.match(self._VALID_URL, url)
  46. display_id = mobj.group('id')
  47. playlist_url = self._API_URL.format(display_id)
  48. request = sanitized_Request(playlist_url)
  49. request.add_header('X-Requested-With', 'XMLHttpRequest')
  50. request.add_header('Accept', 'application/json')
  51. request.add_header('Referer', url)
  52. playlist = self._download_json(request, display_id)
  53. tape = playlist['tape']
  54. entries = []
  55. for s in tape['songs']:
  56. song = s['song']
  57. entry = {
  58. 'id': song['id'],
  59. 'duration': float_or_none(song.get('songduration'), 1000),
  60. 'title': song['title'],
  61. }
  62. if song['source'] == 'S3':
  63. entry.update({
  64. 'url': self._S3_SONG_URL.format(song['filename']),
  65. })
  66. entries.append(entry)
  67. elif song['source'] == 'YT':
  68. self.to_screen('YouTube video detected')
  69. yt_id = song['filename'].replace('/youtube/', '')
  70. entry.update(self.url_result(yt_id, 'Youtube', video_id=yt_id))
  71. entries.append(entry)
  72. elif song['source'] == 'SC':
  73. self.to_screen('SoundCloud song detected')
  74. sc_url = self._SOUNDCLOUD_SONG_URL.format(song['filename'])
  75. entry.update(self.url_result(sc_url, 'Soundcloud'))
  76. entries.append(entry)
  77. else:
  78. self.report_warning('Unknown song source: %s' % song['source'])
  79. if mobj.group('songnr'):
  80. songnr = int(mobj.group('songnr')) - 1
  81. try:
  82. return entries[songnr]
  83. except IndexError:
  84. raise ExtractorError(
  85. 'No song with index: %s' % mobj.group('songnr'),
  86. expected=True)
  87. return {
  88. '_type': 'playlist',
  89. 'id': tape['id'],
  90. 'display_id': display_id,
  91. 'title': tape['name'],
  92. 'entries': entries,
  93. 'thumbnail': tape.get('image_url'),
  94. 'description': clean_html(tape.get('subtext')),
  95. 'like_count': tape.get('likescount'),
  96. 'uploader_id': tape.get('user_id'),
  97. 'timestamp': parse_iso8601(tape.get('published_at')),
  98. }