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.

65 lines
2.1 KiB

  1. # coding: utf-8
  2. import re
  3. import time
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. compat_urllib_parse,
  7. compat_urllib_request,
  8. )
  9. class StreamcloudIE(InfoExtractor):
  10. IE_NAME = u'streamcloud.eu'
  11. _VALID_URL = r'https?://streamcloud\.eu/(?P<id>[a-zA-Z0-9_-]+)/(?P<fname>[^#?]*)\.html'
  12. _TEST = {
  13. u'url': u'http://streamcloud.eu/skp9j99s4bpz/youtube-dl_test_video_____________-BaW_jenozKc.mp4.html',
  14. u'file': u'skp9j99s4bpz.mp4',
  15. u'md5': u'6bea4c7fa5daaacc2a946b7146286686',
  16. u'info_dict': {
  17. u'title': u'youtube-dl test video \'/\\ ä ↭',
  18. u'duration': 9,
  19. },
  20. }
  21. def _real_extract(self, url):
  22. mobj = re.match(self._VALID_URL, url)
  23. video_id = mobj.group('id')
  24. orig_webpage = self._download_webpage(url, video_id)
  25. fields = re.findall(r'''(?x)<input\s+
  26. type="(?:hidden|submit)"\s+
  27. name="([^"]+)"\s+
  28. (?:id="[^"]+"\s+)?
  29. value="([^"]*)"
  30. ''', orig_webpage)
  31. post = compat_urllib_parse.urlencode(fields)
  32. self.to_screen('%s: Waiting for timeout' % video_id)
  33. time.sleep(12)
  34. headers = {
  35. b'Content-Type': b'application/x-www-form-urlencoded',
  36. }
  37. req = compat_urllib_request.Request(url, post, headers)
  38. webpage = self._download_webpage(
  39. req, video_id, note=u'Downloading video page ...')
  40. title = self._html_search_regex(
  41. r'<h1[^>]*>([^<]+)<', webpage, u'title')
  42. video_url = self._search_regex(
  43. r'file:\s*"([^"]+)"', webpage, u'video URL')
  44. duration_str = self._search_regex(
  45. r'duration:\s*"?([0-9]+)"?', webpage, u'duration', fatal=False)
  46. duration = None if duration_str is None else int(duration_str)
  47. thumbnail = self._search_regex(
  48. r'image:\s*"([^"]+)"', webpage, u'thumbnail URL', fatal=False)
  49. return {
  50. 'id': video_id,
  51. 'title': title,
  52. 'url': video_url,
  53. 'duration': duration,
  54. 'thumbnail': thumbnail,
  55. }