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.

98 lines
3.2 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..compat import compat_chr
  5. from ..utils import (
  6. determine_ext,
  7. ExtractorError,
  8. )
  9. class OpenloadIE(InfoExtractor):
  10. _VALID_URL = r'https?://(?:openload\.(?:co|io)|oload\.tv)/(?:f|embed)/(?P<id>[a-zA-Z0-9-_]+)'
  11. _TESTS = [{
  12. 'url': 'https://openload.co/f/kUEfGclsU9o',
  13. 'md5': 'bf1c059b004ebc7a256f89408e65c36e',
  14. 'info_dict': {
  15. 'id': 'kUEfGclsU9o',
  16. 'ext': 'mp4',
  17. 'title': 'skyrim_no-audio_1080.mp4',
  18. 'thumbnail': r're:^https?://.*\.jpg$',
  19. },
  20. }, {
  21. 'url': 'https://openload.co/embed/rjC09fkPLYs',
  22. 'info_dict': {
  23. 'id': 'rjC09fkPLYs',
  24. 'ext': 'mp4',
  25. 'title': 'movie.mp4',
  26. 'thumbnail': r're:^https?://.*\.jpg$',
  27. 'subtitles': {
  28. 'en': [{
  29. 'ext': 'vtt',
  30. }],
  31. },
  32. },
  33. 'params': {
  34. 'skip_download': True, # test subtitles only
  35. },
  36. }, {
  37. 'url': 'https://openload.co/embed/kUEfGclsU9o/skyrim_no-audio_1080.mp4',
  38. 'only_matching': True,
  39. }, {
  40. 'url': 'https://openload.io/f/ZAn6oz-VZGE/',
  41. 'only_matching': True,
  42. }, {
  43. 'url': 'https://openload.co/f/_-ztPaZtMhM/',
  44. 'only_matching': True,
  45. }, {
  46. # unavailable via https://openload.co/f/Sxz5sADo82g/, different layout
  47. # for title and ext
  48. 'url': 'https://openload.co/embed/Sxz5sADo82g/',
  49. 'only_matching': True,
  50. }, {
  51. 'url': 'https://oload.tv/embed/KnG-kKZdcfY/',
  52. 'only_matching': True,
  53. }]
  54. def _real_extract(self, url):
  55. video_id = self._match_id(url)
  56. webpage = self._download_webpage('https://openload.co/embed/%s/' % video_id, video_id)
  57. if 'File not found' in webpage or 'deleted by the owner' in webpage:
  58. raise ExtractorError('File not found', expected=True)
  59. ol_id = self._search_regex(
  60. '<span[^>]+id="[a-zA-Z0-9]+x"[^>]*>([0-9]+)</span>',
  61. webpage, 'openload ID')
  62. first_two_chars = int(float(ol_id[0:][:2]))
  63. urlcode = ''
  64. num = 2
  65. while num < len(ol_id):
  66. urlcode += compat_chr(int(float(ol_id[num:][:3])) -
  67. first_two_chars * int(float(ol_id[num + 3:][:2])))
  68. num += 5
  69. video_url = 'https://openload.co/stream/' + urlcode
  70. title = self._og_search_title(webpage, default=None) or self._search_regex(
  71. r'<span[^>]+class=["\']title["\'][^>]*>([^<]+)', webpage,
  72. 'title', default=None) or self._html_search_meta(
  73. 'description', webpage, 'title', fatal=True)
  74. entries = self._parse_html5_media_entries(url, webpage, video_id)
  75. subtitles = entries[0]['subtitles'] if entries else None
  76. info_dict = {
  77. 'id': video_id,
  78. 'title': title,
  79. 'thumbnail': self._og_search_thumbnail(webpage, default=None),
  80. 'url': video_url,
  81. # Seems all videos have extensions in their titles
  82. 'ext': determine_ext(title),
  83. 'subtitles': subtitles,
  84. }
  85. return info_dict