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.

70 lines
2.4 KiB

  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. parse_duration,
  5. unified_strdate,
  6. str_to_int,
  7. )
  8. class AdobeTVIE(InfoExtractor):
  9. _VALID_URL = r'https?://tv\.adobe\.com/watch/[^/]+/(?P<id>[^/]+)'
  10. _TEST = {
  11. 'url': 'http://tv.adobe.com/watch/the-complete-picture-with-julieanne-kost/quick-tip-how-to-draw-a-circle-around-an-object-in-photoshop/',
  12. 'md5': '9bc5727bcdd55251f35ad311ca74fa1e',
  13. 'info_dict': {
  14. 'id': 'quick-tip-how-to-draw-a-circle-around-an-object-in-photoshop',
  15. 'ext': 'mp4',
  16. 'title': 'Quick Tip - How to Draw a Circle Around an Object in Photoshop',
  17. 'description': 'md5:99ec318dc909d7ba2a1f2b038f7d2311',
  18. 'thumbnail': 're:https?://.*\.jpg$',
  19. 'upload_date': '20110914',
  20. 'duration': 60,
  21. 'view_count': int,
  22. },
  23. }
  24. def _real_extract(self, url):
  25. video_id = self._match_id(url)
  26. webpage = self._download_webpage(url, video_id)
  27. player = self._parse_json(
  28. self._search_regex(r'html5player:\s*({.+?})\s*\n', webpage, 'player'),
  29. video_id)
  30. title = player.get('title') or self._search_regex(
  31. r'data-title="([^"]+)"', webpage, 'title')
  32. description = self._og_search_description(webpage)
  33. thumbnail = self._og_search_thumbnail(webpage)
  34. upload_date = unified_strdate(
  35. self._html_search_meta('datepublished', webpage, 'upload date'))
  36. duration = parse_duration(
  37. self._html_search_meta('duration', webpage, 'duration')
  38. or self._search_regex(r'Runtime:\s*(\d{2}:\d{2}:\d{2})', webpage, 'duration'))
  39. view_count = str_to_int(self._search_regex(
  40. r'<div class="views">\s*Views?:\s*([\d,.]+)\s*</div>',
  41. webpage, 'view count'))
  42. formats = [{
  43. 'url': source['src'],
  44. 'format_id': source.get('quality') or source['src'].split('-')[-1].split('.')[0] or None,
  45. 'tbr': source.get('bitrate'),
  46. } for source in player['sources']]
  47. self._sort_formats(formats)
  48. return {
  49. 'id': video_id,
  50. 'title': title,
  51. 'description': description,
  52. 'thumbnail': thumbnail,
  53. 'upload_date': upload_date,
  54. 'duration': duration,
  55. 'view_count': view_count,
  56. 'formats': formats,
  57. }