logo

youtube-dl

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

urort.py (2249B)


  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..compat import (
  5. compat_urllib_parse,
  6. )
  7. from ..utils import (
  8. unified_strdate,
  9. )
  10. class UrortIE(InfoExtractor):
  11. IE_DESC = 'NRK P3 Urørt'
  12. _VALID_URL = r'https?://(?:www\.)?urort\.p3\.no/#!/Band/(?P<id>[^/]+)$'
  13. _TEST = {
  14. 'url': 'https://urort.p3.no/#!/Band/Gerilja',
  15. 'md5': '5ed31a924be8a05e47812678a86e127b',
  16. 'info_dict': {
  17. 'id': '33124-24',
  18. 'ext': 'mp3',
  19. 'title': 'The Bomb',
  20. 'thumbnail': r're:^https?://.+\.jpg',
  21. 'uploader': 'Gerilja',
  22. 'uploader_id': 'Gerilja',
  23. 'upload_date': '20100323',
  24. },
  25. 'params': {
  26. 'matchtitle': '^The Bomb$', # To test, we want just one video
  27. }
  28. }
  29. def _real_extract(self, url):
  30. playlist_id = self._match_id(url)
  31. fstr = compat_urllib_parse.quote("InternalBandUrl eq '%s'" % playlist_id)
  32. json_url = 'http://urort.p3.no/breeze/urort/TrackDTOViews?$filter=%s&$orderby=Released%%20desc&$expand=Tags%%2CFiles' % fstr
  33. songs = self._download_json(json_url, playlist_id)
  34. entries = []
  35. for s in songs:
  36. formats = [{
  37. 'tbr': f.get('Quality'),
  38. 'ext': f['FileType'],
  39. 'format_id': '%s-%s' % (f['FileType'], f.get('Quality', '')),
  40. 'url': 'http://p3urort.blob.core.windows.net/tracks/%s' % f['FileRef'],
  41. 'preference': 3 if f['FileType'] == 'mp3' else 2,
  42. } for f in s['Files']]
  43. self._sort_formats(formats)
  44. e = {
  45. 'id': '%d-%s' % (s['BandId'], s['$id']),
  46. 'title': s['Title'],
  47. 'uploader_id': playlist_id,
  48. 'uploader': s.get('BandName', playlist_id),
  49. 'thumbnail': 'http://urort.p3.no/cloud/images/%s' % s['Image'],
  50. 'upload_date': unified_strdate(s.get('Released')),
  51. 'formats': formats,
  52. }
  53. entries.append(e)
  54. return {
  55. '_type': 'playlist',
  56. 'id': playlist_id,
  57. 'title': playlist_id,
  58. 'entries': entries,
  59. }