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.

76 lines
2.6 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. extract_attributes,
  6. int_or_none,
  7. unified_timestamp,
  8. )
  9. class PopcornTVIE(InfoExtractor):
  10. _VALID_URL = r'https?://[^/]+\.popcorntv\.it/guarda/(?P<display_id>[^/]+)/(?P<id>\d+)'
  11. _TESTS = [{
  12. 'url': 'https://animemanga.popcorntv.it/guarda/food-wars-battaglie-culinarie-episodio-01/9183',
  13. 'md5': '47d65a48d147caf692ab8562fe630b45',
  14. 'info_dict': {
  15. 'id': '9183',
  16. 'display_id': 'food-wars-battaglie-culinarie-episodio-01',
  17. 'ext': 'mp4',
  18. 'title': 'Food Wars, Battaglie Culinarie | Episodio 01',
  19. 'description': 'md5:b8bea378faae4651d3b34c6e112463d0',
  20. 'thumbnail': r're:^https?://.*\.jpg$',
  21. 'timestamp': 1497610857,
  22. 'upload_date': '20170616',
  23. 'duration': 1440,
  24. 'view_count': int,
  25. },
  26. }, {
  27. 'url': 'https://cinema.popcorntv.it/guarda/smash-cut/10433',
  28. 'only_matching': True,
  29. }]
  30. def _real_extract(self, url):
  31. mobj = re.match(self._VALID_URL, url)
  32. display_id, video_id = mobj.group('display_id', 'id')
  33. webpage = self._download_webpage(url, display_id)
  34. m3u8_url = extract_attributes(
  35. self._search_regex(
  36. r'(<link[^>]+itemprop=["\'](?:content|embed)Url[^>]*>)',
  37. webpage, 'content'
  38. ))['href']
  39. formats = self._extract_m3u8_formats(
  40. m3u8_url, display_id, 'mp4', entry_protocol='m3u8_native',
  41. m3u8_id='hls')
  42. title = self._search_regex(
  43. r'<h1[^>]+itemprop=["\']name[^>]*>([^<]+)', webpage,
  44. 'title', default=None) or self._og_search_title(webpage)
  45. description = self._html_search_regex(
  46. r'(?s)<article[^>]+itemprop=["\']description[^>]*>(.+?)</article>',
  47. webpage, 'description', fatal=False)
  48. thumbnail = self._og_search_thumbnail(webpage)
  49. timestamp = unified_timestamp(self._html_search_meta(
  50. 'uploadDate', webpage, 'timestamp'))
  51. duration = int_or_none(self._html_search_meta(
  52. 'duration', webpage), invscale=60)
  53. view_count = int_or_none(self._html_search_meta(
  54. 'interactionCount', webpage, 'view count'))
  55. return {
  56. 'id': video_id,
  57. 'display_id': display_id,
  58. 'title': title,
  59. 'description': description,
  60. 'thumbnail': thumbnail,
  61. 'timestamp': timestamp,
  62. 'duration': duration,
  63. 'view_count': view_count,
  64. 'formats': formats,
  65. }