zaq1.py 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. unified_strdate,
  6. int_or_none
  7. )
  8. class Zaq1IE(InfoExtractor):
  9. _VALID_URL = r'http://(?:www\.)?zaq1\.pl/video/(?P<id>[^/?#&]+)'
  10. _TESTS = [{
  11. 'url': 'http://zaq1.pl/video/xev0e',
  12. 'md5': '24a5eb3f052e604ae597c4d0d19b351e',
  13. 'info_dict': {
  14. 'id': 'xev0e',
  15. 'title': 'DJ NA WESELE. TANIEC Z FIGURAMI.węgrów/sokołów podlaski/siedlce/mińsk mazowiecki/warszawa',
  16. 'ext': 'mp4',
  17. 'duration': 511,
  18. 'uploader': 'Anonim',
  19. 'upload_date': '20170330',
  20. }
  21. }, {
  22. 'url': 'http://zaq1.pl/video/x80nc',
  23. 'md5': '1245973520adc78139928a820959d9c5',
  24. 'info_dict': {
  25. 'id': 'x80nc',
  26. 'title': 'DIY Inspiration Challenge #86 | koraliki | gwiazdka na choinkę z koralików i drutu',
  27. 'ext': 'mp4',
  28. 'duration': 438,
  29. 'uploader': 'Anonim',
  30. 'upload_date': '20170404',
  31. }
  32. }]
  33. def _real_extract(self, url):
  34. video_id = self._match_id(url)
  35. webpage = self._download_webpage(url, video_id)
  36. title = self._html_search_regex(
  37. r'(?s)<h1>\s*<span.+class="watch-title".+title="([^"]+)">\1\s*</span>\s*</h1>', webpage, 'title')
  38. div = self._search_regex(r'(?s)(?P<div><div.+id=(["\'])video_player\2.+</div>)', webpage, 'video url', group='div')
  39. video_url = self._search_regex(r'data-video-url="(http[^"]+)"', div, 'video url')
  40. ext = self._search_regex(r'data-file-extension="([^"]+)"', div, 'ext', None, False)
  41. duration = int_or_none(self._search_regex(r'data-duration="([^"]+)"', div, 'duration', None, False))
  42. thumbnail = self._search_regex(r'data-photo-url="([^"]+)"', div, 'thumbnail', None, False)
  43. upload_date = unified_strdate(self._search_regex(r'<strong\s+class="watch-time-text">\s*Opublikowany\s+([0-9]{4}-[0-9]{2}-[0-9]{2})', webpage, 'upload date'))
  44. uploader = self._search_regex(r'<div\s+id="watch7-user-header">.*Wideo dodał:\s*<a[^>]*>\s*([^<]+)\s*</a>', webpage, 'uploader')
  45. return {
  46. 'id': video_id,
  47. 'title': title,
  48. 'formats': [{
  49. 'url': video_url,
  50. 'ext': ext,
  51. 'http_headers': {'Referer': url},
  52. }],
  53. 'thumbnail': thumbnail,
  54. 'uploader': uploader,
  55. 'upload_date': upload_date,
  56. 'duration': duration,
  57. }