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.

69 lines
2.6 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. compat_urllib_request,
  6. ExtractorError,
  7. )
  8. class EveryonesMixtapeIE(InfoExtractor):
  9. _VALID_URL = r'https?://(?:www\.)?everyonesmixtape\.com/#/mix/(?P<id>[0-9a-zA-Z]+)(?:/(?P<songnr>[0-9]))?$'
  10. _TEST = {
  11. 'url': 'http://everyonesmixtape.com/#/mix/m7m0jJAbMQi/5',
  12. 'file': '5bfseWNmlds.mp4',
  13. "info_dict": {
  14. "title": "Passion Pit - \"Sleepyhead\" (Official Music Video)",
  15. "uploader": "FKR.TV",
  16. "uploader_id": "frenchkissrecords",
  17. "description": "Music video for \"Sleepyhead\" from Passion Pit's debut EP Chunk Of Change.\nBuy on iTunes: https://itunes.apple.com/us/album/chunk-of-change-ep/id300087641\n\nDirected by The Wilderness.\n\nhttp://www.passionpitmusic.com\nhttp://www.frenchkissrecords.com",
  18. "upload_date": "20081015"
  19. },
  20. 'params': {
  21. 'skip_download': True, # This is simply YouTube
  22. }
  23. }
  24. def _real_extract(self, url):
  25. mobj = re.match(self._VALID_URL, url)
  26. playlist_id = mobj.group('id')
  27. pllist_url = 'http://everyonesmixtape.com/mixtape.php?a=getMixes&u=-1&linked=%s&explore=' % playlist_id
  28. pllist_req = compat_urllib_request.Request(pllist_url)
  29. pllist_req.add_header('X-Requested-With', 'XMLHttpRequest')
  30. playlist_list = self._download_json(
  31. pllist_req, playlist_id, note='Downloading playlist metadata')
  32. try:
  33. playlist_no = next(playlist['id']
  34. for playlist in playlist_list
  35. if playlist['code'] == playlist_id)
  36. except StopIteration:
  37. raise ExtractorError('Playlist id not found')
  38. pl_url = 'http://everyonesmixtape.com/mixtape.php?a=getMix&id=%s&userId=null&code=' % playlist_no
  39. pl_req = compat_urllib_request.Request(pl_url)
  40. pl_req.add_header('X-Requested-With', 'XMLHttpRequest')
  41. playlist = self._download_json(
  42. pl_req, playlist_id, note='Downloading playlist info')
  43. entries = [{
  44. '_type': 'url',
  45. 'url': t['url'],
  46. 'title': t['title'],
  47. } for t in playlist['tracks']]
  48. if mobj.group('songnr'):
  49. songnr = int(mobj.group('songnr')) - 1
  50. return entries[songnr]
  51. playlist_title = playlist['mixData']['name']
  52. return {
  53. '_type': 'playlist',
  54. 'id': playlist_id,
  55. 'title': playlist_title,
  56. 'entries': entries,
  57. }