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.

64 lines
1.9 KiB

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