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.

79 lines
2.8 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. clean_html,
  7. int_or_none,
  8. )
  9. class MoeVideoIE(InfoExtractor):
  10. IE_DESC = 'LetitBit video services: moevideo.net, playreplay.net and videochart.net'
  11. _VALID_URL = r'''(?x)
  12. https?://(?P<host>(?:www\.)?
  13. (?:(?:moevideo|playreplay|videochart)\.net|thesame\.tv))/
  14. (?:video|framevideo|embed)/(?P<id>[0-9a-z]+\.[0-9A-Za-z]+)'''
  15. _API_URL = 'http://api.letitbit.net/'
  16. _API_KEY = 'tVL0gjqo5'
  17. _TESTS = [
  18. {
  19. 'url': 'http://moevideo.net/video/00297.0036103fe3d513ef27915216fd29',
  20. 'md5': '129f5ae1f6585d0e9bb4f38e774ffb3a',
  21. 'info_dict': {
  22. 'id': '00297.0036103fe3d513ef27915216fd29',
  23. 'ext': 'flv',
  24. 'title': 'Sink cut out machine',
  25. 'description': 'md5:f29ff97b663aefa760bf7ca63c8ca8a8',
  26. 'thumbnail': r're:^https?://.*\.jpg$',
  27. 'width': 540,
  28. 'height': 360,
  29. 'duration': 179,
  30. 'filesize': 17822500,
  31. },
  32. 'skip': 'Video has been removed',
  33. },
  34. {
  35. 'url': 'http://playreplay.net/video/77107.7f325710a627383d40540d8e991a',
  36. 'md5': '74f0a014d5b661f0f0e2361300d1620e',
  37. 'info_dict': {
  38. 'id': '77107.7f325710a627383d40540d8e991a',
  39. 'ext': 'flv',
  40. 'title': 'Operacion Condor.',
  41. 'description': 'md5:7e68cb2fcda66833d5081c542491a9a3',
  42. 'thumbnail': r're:^https?://.*\.jpg$',
  43. 'width': 480,
  44. 'height': 296,
  45. 'duration': 6027,
  46. 'filesize': 588257923,
  47. },
  48. 'skip': 'Video has been removed',
  49. },
  50. ]
  51. def _real_extract(self, url):
  52. host, video_id = re.match(self._VALID_URL, url).groups()
  53. webpage = self._download_webpage(
  54. 'http://%s/video/%s' % (host, video_id),
  55. video_id, 'Downloading webpage')
  56. title = self._og_search_title(webpage)
  57. embed_webpage = self._download_webpage(
  58. 'http://%s/embed/%s' % (host, video_id),
  59. video_id, 'Downloading embed webpage')
  60. video = self._parse_json(self._search_regex(
  61. r'mvplayer\("#player"\s*,\s*({.+})',
  62. embed_webpage, 'mvplayer'), video_id)['video']
  63. return {
  64. 'id': video_id,
  65. 'title': title,
  66. 'thumbnail': video.get('poster') or self._og_search_thumbnail(webpage),
  67. 'description': clean_html(self._og_search_description(webpage)),
  68. 'duration': int_or_none(self._og_search_property('video:duration', webpage)),
  69. 'url': video['ourUrl'],
  70. }