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.

67 lines
2.0 KiB

10 years ago
  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. int_or_none,
  5. parse_iso8601,
  6. )
  7. class BeegIE(InfoExtractor):
  8. _VALID_URL = r'https?://(?:www\.)?beeg\.com/(?P<id>\d+)'
  9. _TEST = {
  10. 'url': 'http://beeg.com/5416503',
  11. 'md5': '46c384def73b33dbc581262e5ee67cef',
  12. 'info_dict': {
  13. 'id': '5416503',
  14. 'ext': 'mp4',
  15. 'title': 'Sultry Striptease',
  16. 'description': 'md5:d22219c09da287c14bed3d6c37ce4bc2',
  17. 'timestamp': 1391813355,
  18. 'upload_date': '20140207',
  19. 'duration': 383,
  20. 'tags': list,
  21. 'age_limit': 18,
  22. }
  23. }
  24. def _real_extract(self, url):
  25. video_id = self._match_id(url)
  26. video = self._download_json(
  27. 'http://beeg.com/api/v1/video/%s' % video_id, video_id)
  28. formats = []
  29. for format_id, video_url in video.items():
  30. height = self._search_regex(
  31. r'^(\d+)[pP]$', format_id, 'height', default=None)
  32. if not height:
  33. continue
  34. formats.append({
  35. 'url': self._proto_relative_url(video_url.replace('{DATA_MARKERS}', ''), 'http:'),
  36. 'format_id': format_id,
  37. 'height': int(height),
  38. })
  39. self._sort_formats(formats)
  40. title = video['title']
  41. video_id = video.get('id') or video_id
  42. display_id = video.get('code')
  43. description = video.get('desc')
  44. timestamp = parse_iso8601(video.get('date'), ' ')
  45. duration = int_or_none(video.get('duration'))
  46. tags = [tag.strip() for tag in video['tags'].split(',')] if video.get('tags') else None
  47. return {
  48. 'id': video_id,
  49. 'display_id': display_id,
  50. 'title': title,
  51. 'description': description,
  52. 'timestamp': timestamp,
  53. 'duration': duration,
  54. 'tags': tags,
  55. 'formats': formats,
  56. 'age_limit': 18,
  57. }