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.

82 lines
2.6 KiB

  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. int_or_none,
  7. qualities,
  8. )
  9. class WrzutaIE(InfoExtractor):
  10. IE_NAME = 'wrzuta.pl'
  11. _VALID_URL = r'https?://(?P<uploader>[0-9a-zA-Z]+)\.wrzuta\.pl/(?P<typ>film|audio)/(?P<id>[0-9a-zA-Z]+)'
  12. _TESTS = [{
  13. 'url': 'http://laboratoriumdextera.wrzuta.pl/film/aq4hIZWrkBu/nike_football_the_last_game',
  14. 'md5': '9e67e05bed7c03b82488d87233a9efe7',
  15. 'info_dict': {
  16. 'id': 'aq4hIZWrkBu',
  17. 'ext': 'mp4',
  18. 'title': 'Nike Football: The Last Game',
  19. 'duration': 307,
  20. 'uploader_id': 'laboratoriumdextera',
  21. 'description': 'md5:7fb5ef3c21c5893375fda51d9b15d9cd',
  22. },
  23. }, {
  24. 'url': 'http://jolka85.wrzuta.pl/audio/063jOPX5ue2/liber_natalia_szroeder_-_teraz_ty',
  25. 'md5': 'bc78077859bea7bcfe4295d7d7fc9025',
  26. 'info_dict': {
  27. 'id': '063jOPX5ue2',
  28. 'ext': 'ogg',
  29. 'title': 'Liber & Natalia Szroeder - Teraz Ty',
  30. 'duration': 203,
  31. 'uploader_id': 'jolka85',
  32. 'description': 'md5:2d2b6340f9188c8c4cd891580e481096',
  33. },
  34. }]
  35. def _real_extract(self, url):
  36. mobj = re.match(self._VALID_URL, url)
  37. video_id = mobj.group('id')
  38. typ = mobj.group('typ')
  39. uploader = mobj.group('uploader')
  40. webpage = self._download_webpage(url, video_id)
  41. quality = qualities(['SD', 'MQ', 'HQ', 'HD'])
  42. audio_table = {'flv': 'mp3', 'webm': 'ogg', '???': 'mp3'}
  43. embedpage = self._download_json('http://www.wrzuta.pl/npp/embed/%s/%s' % (uploader, video_id), video_id)
  44. formats = []
  45. for media in embedpage['url']:
  46. fmt = media['type'].split('@')[0]
  47. if typ == 'audio':
  48. ext = audio_table.get(fmt, fmt)
  49. else:
  50. ext = fmt
  51. formats.append({
  52. 'format_id': '%s_%s' % (ext, media['quality'].lower()),
  53. 'url': media['url'],
  54. 'ext': ext,
  55. 'quality': quality(media['quality']),
  56. })
  57. self._sort_formats(formats)
  58. return {
  59. 'id': video_id,
  60. 'title': self._og_search_title(webpage),
  61. 'thumbnail': self._og_search_thumbnail(webpage),
  62. 'formats': formats,
  63. 'duration': int_or_none(embedpage['duration']),
  64. 'uploader_id': uploader,
  65. 'description': self._og_search_description(webpage),
  66. 'age_limit': embedpage.get('minimalAge', 0),
  67. }