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.

87 lines
3.1 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. int_or_none,
  6. parse_duration,
  7. unified_strdate,
  8. )
  9. class CamWithHerIE(InfoExtractor):
  10. _VALID_URL = r'https?://(?:www\.)?camwithher\.tv/view_video\.php\?.*\bviewkey=(?P<id>\w+)'
  11. _TESTS = [{
  12. 'url': 'http://camwithher.tv/view_video.php?viewkey=6e9a24e2c0e842e1f177&page=&viewtype=&category=',
  13. 'info_dict': {
  14. 'id': '5644',
  15. 'ext': 'flv',
  16. 'title': 'Periscope Tease',
  17. 'description': 'In the clouds teasing on periscope to my favorite song',
  18. 'duration': 240,
  19. 'view_count': int,
  20. 'comment_count': int,
  21. 'uploader': 'MileenaK',
  22. 'upload_date': '20160322',
  23. },
  24. 'params': {
  25. 'skip_download': True,
  26. }
  27. }, {
  28. 'url': 'http://camwithher.tv/view_video.php?viewkey=6dfd8b7c97531a459937',
  29. 'only_matching': True,
  30. }, {
  31. 'url': 'http://camwithher.tv/view_video.php?page=&viewkey=6e9a24e2c0e842e1f177&viewtype=&category=',
  32. 'only_matching': True,
  33. }, {
  34. 'url': 'http://camwithher.tv/view_video.php?viewkey=b6c3b5bea9515d1a1fc4&page=&viewtype=&category=mv',
  35. 'only_matching': True,
  36. }]
  37. def _real_extract(self, url):
  38. video_id = self._match_id(url)
  39. webpage = self._download_webpage(url, video_id)
  40. flv_id = self._html_search_regex(
  41. r'<a[^>]+href=["\']/download/\?v=(\d+)', webpage, 'video id')
  42. # Video URL construction algorithm is reverse-engineered from cwhplayer.swf
  43. rtmp_url = 'rtmp://camwithher.tv/clipshare/%s' % (
  44. ('mp4:%s.mp4' % flv_id) if int(flv_id) > 2010 else flv_id)
  45. title = self._html_search_regex(
  46. r'<div[^>]+style="float:left"[^>]*>\s*<h2>(.+?)</h2>', webpage, 'title')
  47. description = self._html_search_regex(
  48. r'>Description:</span>(.+?)</div>', webpage, 'description', default=None)
  49. runtime = self._search_regex(
  50. r'Runtime\s*:\s*(.+?) \|', webpage, 'duration', default=None)
  51. if runtime:
  52. runtime = re.sub(r'[\s-]', '', runtime)
  53. duration = parse_duration(runtime)
  54. view_count = int_or_none(self._search_regex(
  55. r'Views\s*:\s*(\d+)', webpage, 'view count', default=None))
  56. comment_count = int_or_none(self._search_regex(
  57. r'Comments\s*:\s*(\d+)', webpage, 'comment count', default=None))
  58. uploader = self._search_regex(
  59. r'Added by\s*:\s*<a[^>]+>([^<]+)</a>', webpage, 'uploader', default=None)
  60. upload_date = unified_strdate(self._search_regex(
  61. r'Added on\s*:\s*([\d-]+)', webpage, 'upload date', default=None))
  62. return {
  63. 'id': flv_id,
  64. 'url': rtmp_url,
  65. 'ext': 'flv',
  66. 'no_resume': True,
  67. 'title': title,
  68. 'description': description,
  69. 'duration': duration,
  70. 'view_count': view_count,
  71. 'comment_count': comment_count,
  72. 'uploader': uploader,
  73. 'upload_date': upload_date,
  74. }