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.

62 lines
1.9 KiB

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