logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

camwithher.py (3229B)


  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. 'age_limit': 18,
  24. },
  25. 'params': {
  26. 'skip_download': True,
  27. }
  28. }, {
  29. 'url': 'http://camwithher.tv/view_video.php?viewkey=6dfd8b7c97531a459937',
  30. 'only_matching': True,
  31. }, {
  32. 'url': 'http://camwithher.tv/view_video.php?page=&viewkey=6e9a24e2c0e842e1f177&viewtype=&category=',
  33. 'only_matching': True,
  34. }, {
  35. 'url': 'http://camwithher.tv/view_video.php?viewkey=b6c3b5bea9515d1a1fc4&page=&viewtype=&category=mv',
  36. 'only_matching': True,
  37. }]
  38. def _real_extract(self, url):
  39. video_id = self._match_id(url)
  40. webpage = self._download_webpage(url, video_id)
  41. flv_id = self._html_search_regex(
  42. r'<a[^>]+href=["\']/download/\?v=(\d+)', webpage, 'video id')
  43. # Video URL construction algorithm is reverse-engineered from cwhplayer.swf
  44. rtmp_url = 'rtmp://camwithher.tv/clipshare/%s' % (
  45. ('mp4:%s.mp4' % flv_id) if int(flv_id) > 2010 else flv_id)
  46. title = self._html_search_regex(
  47. r'<div[^>]+style="float:left"[^>]*>\s*<h2>(.+?)</h2>', webpage, 'title')
  48. description = self._html_search_regex(
  49. r'>Description:</span>(.+?)</div>', webpage, 'description', default=None)
  50. runtime = self._search_regex(
  51. r'Runtime\s*:\s*(.+?) \|', webpage, 'duration', default=None)
  52. if runtime:
  53. runtime = re.sub(r'[\s-]', '', runtime)
  54. duration = parse_duration(runtime)
  55. view_count = int_or_none(self._search_regex(
  56. r'Views\s*:\s*(\d+)', webpage, 'view count', default=None))
  57. comment_count = int_or_none(self._search_regex(
  58. r'Comments\s*:\s*(\d+)', webpage, 'comment count', default=None))
  59. uploader = self._search_regex(
  60. r'Added by\s*:\s*<a[^>]+>([^<]+)</a>', webpage, 'uploader', default=None)
  61. upload_date = unified_strdate(self._search_regex(
  62. r'Added on\s*:\s*([\d-]+)', webpage, 'upload date', default=None))
  63. return {
  64. 'id': flv_id,
  65. 'url': rtmp_url,
  66. 'ext': 'flv',
  67. 'no_resume': True,
  68. 'title': title,
  69. 'description': description,
  70. 'duration': duration,
  71. 'view_count': view_count,
  72. 'comment_count': comment_count,
  73. 'uploader': uploader,
  74. 'upload_date': upload_date,
  75. 'age_limit': 18
  76. }