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.

75 lines
2.4 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. ExtractorError,
  7. urlencode_postdata,
  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. _TESTS = [{
  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. 'url': 'http://streamcloud.eu/ua8cmfh1nbe6/NSHIP-148--KUC-NG--H264-.mp4.html',
  23. 'only_matching': True,
  24. }]
  25. def _real_extract(self, url):
  26. video_id = self._match_id(url)
  27. url = 'http://streamcloud.eu/%s' % video_id
  28. orig_webpage = self._download_webpage(url, video_id)
  29. if '>File Not Found<' in orig_webpage:
  30. raise ExtractorError(
  31. 'Video %s does not exist' % video_id, expected=True)
  32. fields = re.findall(r'''(?x)<input\s+
  33. type="(?:hidden|submit)"\s+
  34. name="([^"]+)"\s+
  35. (?:id="[^"]+"\s+)?
  36. value="([^"]*)"
  37. ''', orig_webpage)
  38. self._sleep(12, video_id)
  39. webpage = self._download_webpage(
  40. url, video_id, data=urlencode_postdata(fields), headers={
  41. b'Content-Type': b'application/x-www-form-urlencoded',
  42. })
  43. try:
  44. title = self._html_search_regex(
  45. r'<h1[^>]*>([^<]+)<', webpage, 'title')
  46. video_url = self._search_regex(
  47. r'file:\s*"([^"]+)"', webpage, 'video URL')
  48. except ExtractorError:
  49. message = self._html_search_regex(
  50. r'(?s)<div[^>]+class=(["\']).*?msgboxinfo.*?\1[^>]*>(?P<message>.+?)</div>',
  51. webpage, 'message', default=None, group='message')
  52. if message:
  53. raise ExtractorError('%s said: %s' % (self.IE_NAME, message), expected=True)
  54. raise
  55. thumbnail = self._search_regex(
  56. r'image:\s*"([^"]+)"', webpage, 'thumbnail URL', fatal=False)
  57. return {
  58. 'id': video_id,
  59. 'title': title,
  60. 'url': video_url,
  61. 'thumbnail': thumbnail,
  62. }