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.

61 lines
1.8 KiB

10 years ago
10 years ago
10 years ago
10 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. compat_urllib_parse,
  7. unified_strdate,
  8. )
  9. class UrortIE(InfoExtractor):
  10. IE_DESC = 'NRK P3 Urørt'
  11. _VALID_URL = r'https?://(?:www\.)?urort\.p3\.no/#!/Band/(?P<id>[^/]+)$'
  12. _TEST = {
  13. 'url': 'https://urort.p3.no/#!/Band/Gerilja',
  14. 'md5': '5ed31a924be8a05e47812678a86e127b',
  15. 'info_dict': {
  16. 'id': '33124-4',
  17. 'ext': 'mp3',
  18. 'title': 'The Bomb',
  19. 'thumbnail': 're:^https?://.+\.jpg',
  20. 'like_count': int,
  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. mobj = re.match(self._VALID_URL, url)
  31. playlist_id = mobj.group('id')
  32. fstr = compat_urllib_parse.quote("InternalBandUrl eq '%s'" % playlist_id)
  33. json_url = 'http://urort.p3.no/breeze/urort/TrackDtos?$filter=' + fstr
  34. songs = self._download_json(json_url, playlist_id)
  35. print(songs[0])
  36. entries = [{
  37. 'id': '%d-%s' % (s['BandId'], s['$id']),
  38. 'title': s['Title'],
  39. 'url': s['TrackUrl'],
  40. 'ext': 'mp3',
  41. 'uploader_id': playlist_id,
  42. 'uploader': s.get('BandName', playlist_id),
  43. 'like_count': s.get('LikeCount'),
  44. 'thumbnail': 'http://urort.p3.no/cloud/images/%s' % s['Image'],
  45. 'upload_date': unified_strdate(s.get('Released')),
  46. } for s in songs]
  47. return {
  48. '_type': 'playlist',
  49. 'id': playlist_id,
  50. 'title': playlist_id,
  51. 'entries': entries,
  52. }