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.

102 lines
3.7 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from .nexx import NexxIE
  6. from ..utils import int_or_none
  7. class FunkBaseIE(InfoExtractor):
  8. def _make_url_result(self, video):
  9. return {
  10. '_type': 'url_transparent',
  11. 'url': 'nexx:741:%s' % video['sourceId'],
  12. 'ie_key': NexxIE.ie_key(),
  13. 'id': video['sourceId'],
  14. 'title': video.get('title'),
  15. 'description': video.get('description'),
  16. 'duration': int_or_none(video.get('duration')),
  17. 'season_number': int_or_none(video.get('seasonNr')),
  18. 'episode_number': int_or_none(video.get('episodeNr')),
  19. }
  20. class FunkMixIE(FunkBaseIE):
  21. _VALID_URL = r'https?://(?:www\.)?funk\.net/mix/(?P<id>[^/]+)/(?P<alias>[^/?#&]+)'
  22. _TESTS = [{
  23. 'url': 'https://www.funk.net/mix/59d65d935f8b160001828b5b/die-realste-kifferdoku-aller-zeiten',
  24. 'md5': '8edf617c2f2b7c9847dfda313f199009',
  25. 'info_dict': {
  26. 'id': '123748',
  27. 'ext': 'mp4',
  28. 'title': '"Die realste Kifferdoku aller Zeiten"',
  29. 'description': 'md5:c97160f5bafa8d47ec8e2e461012aa9d',
  30. 'timestamp': 1490274721,
  31. 'upload_date': '20170323',
  32. },
  33. }]
  34. def _real_extract(self, url):
  35. mobj = re.match(self._VALID_URL, url)
  36. mix_id = mobj.group('id')
  37. alias = mobj.group('alias')
  38. lists = self._download_json(
  39. 'https://www.funk.net/api/v3.1/curation/curatedLists/',
  40. mix_id, headers={
  41. 'authorization': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnROYW1lIjoiY3VyYXRpb24tdG9vbC12Mi4wIiwic2NvcGUiOiJzdGF0aWMtY29udGVudC1hcGksY3VyYXRpb24tc2VydmljZSxzZWFyY2gtYXBpIn0.SGCC1IXHLtZYoo8PvRKlU2gXH1su8YSu47sB3S4iXBI',
  42. 'Referer': url,
  43. }, query={
  44. 'size': 100,
  45. })['result']['lists']
  46. metas = next(
  47. l for l in lists
  48. if mix_id in (l.get('entityId'), l.get('alias')))['videoMetas']
  49. video = next(
  50. meta['videoDataDelegate']
  51. for meta in metas if meta.get('alias') == alias)
  52. return self._make_url_result(video)
  53. class FunkChannelIE(FunkBaseIE):
  54. _VALID_URL = r'https?://(?:www\.)?funk\.net/channel/(?P<id>[^/]+)/(?P<alias>[^/?#&]+)'
  55. _TESTS = [{
  56. 'url': 'https://www.funk.net/channel/ba/die-lustigsten-instrumente-aus-dem-internet-teil-2',
  57. 'info_dict': {
  58. 'id': '1155821',
  59. 'ext': 'mp4',
  60. 'title': 'Die LUSTIGSTEN INSTRUMENTE aus dem Internet - Teil 2',
  61. 'description': 'md5:a691d0413ef4835588c5b03ded670c1f',
  62. 'timestamp': 1514507395,
  63. 'upload_date': '20171229',
  64. },
  65. 'params': {
  66. 'skip_download': True,
  67. },
  68. }, {
  69. 'url': 'https://www.funk.net/channel/59d5149841dca100012511e3/mein-erster-job-lovemilla-folge-1/lovemilla/',
  70. 'only_matching': True,
  71. }]
  72. def _real_extract(self, url):
  73. mobj = re.match(self._VALID_URL, url)
  74. channel_id = mobj.group('id')
  75. alias = mobj.group('alias')
  76. results = self._download_json(
  77. 'https://www.funk.net/api/v3.0/content/videos/filter', channel_id,
  78. headers={
  79. 'authorization': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnROYW1lIjoiY3VyYXRpb24tdG9vbCIsInNjb3BlIjoic3RhdGljLWNvbnRlbnQtYXBpLGN1cmF0aW9uLWFwaSxzZWFyY2gtYXBpIn0.q4Y2xZG8PFHai24-4Pjx2gym9RmJejtmK6lMXP5wAgc',
  80. 'Referer': url,
  81. }, query={
  82. 'channelId': channel_id,
  83. 'size': 100,
  84. })['result']
  85. video = next(r for r in results if r.get('alias') == alias)
  86. return self._make_url_result(video)