logo

youtube-dl

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

chirbit.py (2946B)


  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..compat import compat_b64decode
  6. from ..utils import parse_duration
  7. class ChirbitIE(InfoExtractor):
  8. IE_NAME = 'chirbit'
  9. _VALID_URL = r'https?://(?:www\.)?chirb\.it/(?:(?:wp|pl)/|fb_chirbit_player\.swf\?key=)?(?P<id>[\da-zA-Z]+)'
  10. _TESTS = [{
  11. 'url': 'http://chirb.it/be2abG',
  12. 'info_dict': {
  13. 'id': 'be2abG',
  14. 'ext': 'mp3',
  15. 'title': 'md5:f542ea253f5255240be4da375c6a5d7e',
  16. 'description': 'md5:f24a4e22a71763e32da5fed59e47c770',
  17. 'duration': 306,
  18. 'uploader': 'Gerryaudio',
  19. },
  20. 'params': {
  21. 'skip_download': True,
  22. }
  23. }, {
  24. 'url': 'https://chirb.it/fb_chirbit_player.swf?key=PrIPv5',
  25. 'only_matching': True,
  26. }, {
  27. 'url': 'https://chirb.it/wp/MN58c2',
  28. 'only_matching': True,
  29. }]
  30. def _real_extract(self, url):
  31. audio_id = self._match_id(url)
  32. webpage = self._download_webpage(
  33. 'http://chirb.it/%s' % audio_id, audio_id)
  34. data_fd = self._search_regex(
  35. r'data-fd=(["\'])(?P<url>(?:(?!\1).)+)\1',
  36. webpage, 'data fd', group='url')
  37. # Reverse engineered from https://chirb.it/js/chirbit.player.js (look
  38. # for soundURL)
  39. audio_url = compat_b64decode(data_fd[::-1]).decode('utf-8')
  40. title = self._search_regex(
  41. r'class=["\']chirbit-title["\'][^>]*>([^<]+)', webpage, 'title')
  42. description = self._search_regex(
  43. r'<h3>Description</h3>\s*<pre[^>]*>([^<]+)</pre>',
  44. webpage, 'description', default=None)
  45. duration = parse_duration(self._search_regex(
  46. r'class=["\']c-length["\'][^>]*>([^<]+)',
  47. webpage, 'duration', fatal=False))
  48. uploader = self._search_regex(
  49. r'id=["\']chirbit-username["\'][^>]*>([^<]+)',
  50. webpage, 'uploader', fatal=False)
  51. return {
  52. 'id': audio_id,
  53. 'url': audio_url,
  54. 'title': title,
  55. 'description': description,
  56. 'duration': duration,
  57. 'uploader': uploader,
  58. }
  59. class ChirbitProfileIE(InfoExtractor):
  60. IE_NAME = 'chirbit:profile'
  61. _VALID_URL = r'https?://(?:www\.)?chirbit\.com/(?:rss/)?(?P<id>[^/]+)'
  62. _TEST = {
  63. 'url': 'http://chirbit.com/ScarletBeauty',
  64. 'info_dict': {
  65. 'id': 'ScarletBeauty',
  66. },
  67. 'playlist_mincount': 3,
  68. }
  69. def _real_extract(self, url):
  70. profile_id = self._match_id(url)
  71. webpage = self._download_webpage(url, profile_id)
  72. entries = [
  73. self.url_result(self._proto_relative_url('//chirb.it/' + video_id))
  74. for _, video_id in re.findall(r'<input[^>]+id=([\'"])copy-btn-(?P<id>[0-9a-zA-Z]+)\1', webpage)]
  75. return self.playlist_result(entries, profile_id)