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.

71 lines
2.5 KiB

9 years ago
  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') or
  38. self._search_regex(
  39. r'Runtime:\s*(\d{2}:\d{2}:\d{2})',
  40. webpage, 'duration', fatal=False))
  41. view_count = str_to_int(self._search_regex(
  42. r'<div class="views">\s*Views?:\s*([\d,.]+)\s*</div>',
  43. webpage, 'view count'))
  44. formats = [{
  45. 'url': source['src'],
  46. 'format_id': source.get('quality') or source['src'].split('-')[-1].split('.')[0] or None,
  47. 'tbr': source.get('bitrate'),
  48. } for source in player['sources']]
  49. self._sort_formats(formats)
  50. return {
  51. 'id': video_id,
  52. 'title': title,
  53. 'description': description,
  54. 'thumbnail': thumbnail,
  55. 'upload_date': upload_date,
  56. 'duration': duration,
  57. 'view_count': view_count,
  58. 'formats': formats,
  59. }