logo

youtube-dl

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

filemoon.py (1251B)


  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. decode_packed_codes,
  7. js_to_json,
  8. )
  9. class FileMoonIE(InfoExtractor):
  10. _VALID_URL = r'https?://(?:www\.)?filemoon\.sx/./(?P<id>\w+)'
  11. _TEST = {
  12. 'url': 'https://filemoon.sx/e/dw40rxrzruqz',
  13. 'md5': '5a713742f57ac4aef29b74733e8dda01',
  14. 'info_dict': {
  15. 'id': 'dw40rxrzruqz',
  16. 'title': 'dw40rxrzruqz',
  17. 'ext': 'mp4'
  18. }
  19. }
  20. def _real_extract(self, url):
  21. video_id = self._match_id(url)
  22. webpage = self._download_webpage(url, video_id)
  23. matches = re.findall(r'(?s)(eval.*?)</script>', webpage)
  24. packed = matches[-1]
  25. unpacked = decode_packed_codes(packed)
  26. jwplayer_sources = self._parse_json(
  27. self._search_regex(
  28. r'(?s)player\s*\.\s*setup\s*\(\s*\{\s*sources\s*:\s*(.*?])', unpacked, 'jwplayer sources'),
  29. video_id, transform_source=js_to_json)
  30. formats = self._parse_jwplayer_formats(jwplayer_sources, video_id)
  31. return {
  32. 'id': video_id,
  33. 'title': self._generic_title(url) or video_id,
  34. 'formats': formats
  35. }