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.

69 lines
2.1 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. if not video_url:
  31. continue
  32. height = self._search_regex(
  33. r'^(\d+)[pP]$', format_id, 'height', default=None)
  34. if not height:
  35. continue
  36. formats.append({
  37. 'url': self._proto_relative_url(video_url.replace('{DATA_MARKERS}', ''), 'http:'),
  38. 'format_id': format_id,
  39. 'height': int(height),
  40. })
  41. self._sort_formats(formats)
  42. title = video['title']
  43. video_id = video.get('id') or video_id
  44. display_id = video.get('code')
  45. description = video.get('desc')
  46. timestamp = parse_iso8601(video.get('date'), ' ')
  47. duration = int_or_none(video.get('duration'))
  48. tags = [tag.strip() for tag in video['tags'].split(',')] if video.get('tags') else None
  49. return {
  50. 'id': video_id,
  51. 'display_id': display_id,
  52. 'title': title,
  53. 'description': description,
  54. 'timestamp': timestamp,
  55. 'duration': duration,
  56. 'tags': tags,
  57. 'formats': formats,
  58. 'age_limit': 18,
  59. }