logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

everyonesmixtape.py (2819B)


  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. ExtractorError,
  6. sanitized_Request,
  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. _TESTS = [{
  11. 'url': 'http://everyonesmixtape.com/#/mix/m7m0jJAbMQi/5',
  12. 'info_dict': {
  13. 'id': '5bfseWNmlds',
  14. 'ext': 'mp4',
  15. 'title': "Passion Pit - \"Sleepyhead\" (Official Music Video)",
  16. 'uploader': 'FKR.TV',
  17. 'uploader_id': 'frenchkissrecords',
  18. '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",
  19. 'upload_date': '20081015'
  20. },
  21. 'params': {
  22. 'skip_download': True, # This is simply YouTube
  23. }
  24. }, {
  25. 'url': 'http://everyonesmixtape.com/#/mix/m7m0jJAbMQi',
  26. 'info_dict': {
  27. 'id': 'm7m0jJAbMQi',
  28. 'title': 'Driving',
  29. },
  30. 'playlist_count': 24
  31. }]
  32. def _real_extract(self, url):
  33. mobj = re.match(self._VALID_URL, url)
  34. playlist_id = mobj.group('id')
  35. pllist_url = 'http://everyonesmixtape.com/mixtape.php?a=getMixes&u=-1&linked=%s&explore=' % playlist_id
  36. pllist_req = sanitized_Request(pllist_url)
  37. pllist_req.add_header('X-Requested-With', 'XMLHttpRequest')
  38. playlist_list = self._download_json(
  39. pllist_req, playlist_id, note='Downloading playlist metadata')
  40. try:
  41. playlist_no = next(playlist['id']
  42. for playlist in playlist_list
  43. if playlist['code'] == playlist_id)
  44. except StopIteration:
  45. raise ExtractorError('Playlist id not found')
  46. pl_url = 'http://everyonesmixtape.com/mixtape.php?a=getMix&id=%s&userId=null&code=' % playlist_no
  47. pl_req = sanitized_Request(pl_url)
  48. pl_req.add_header('X-Requested-With', 'XMLHttpRequest')
  49. playlist = self._download_json(
  50. pl_req, playlist_id, note='Downloading playlist info')
  51. entries = [{
  52. '_type': 'url',
  53. 'url': t['url'],
  54. 'title': t['title'],
  55. } for t in playlist['tracks']]
  56. if mobj.group('songnr'):
  57. songnr = int(mobj.group('songnr')) - 1
  58. return entries[songnr]
  59. playlist_title = playlist['mixData']['name']
  60. return {
  61. '_type': 'playlist',
  62. 'id': playlist_id,
  63. 'title': playlist_title,
  64. 'entries': entries,
  65. }