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.

222 lines
7.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. int_or_none,
  7. xpath_element,
  8. xpath_text,
  9. )
  10. class VideomoreIE(InfoExtractor):
  11. IE_NAME = 'videomore'
  12. _VALID_URL = r'videomore:(?P<sid>\d+)$|https?://videomore\.ru/(?:(?:embed|[^/]+/[^/]+)/|[^/]+\?.*\btrack_id=)(?P<id>\d+)(?:[/?#&]|\.(?:xml|json)|$)'
  13. _TESTS = [{
  14. 'url': 'http://videomore.ru/kino_v_detalayah/5_sezon/367617',
  15. 'md5': '44455a346edc0d509ac5b5a5b531dc35',
  16. 'info_dict': {
  17. 'id': '367617',
  18. 'ext': 'flv',
  19. 'title': 'Кино в деталях 5 сезон В гостях Алексей Чумаков и Юлия Ковальчук',
  20. 'series': 'Кино в деталях',
  21. 'episode': 'В гостях Алексей Чумаков и Юлия Ковальчук',
  22. 'thumbnail': 're:^https?://.*\.jpg',
  23. 'duration': 2910,
  24. 'view_count': int,
  25. 'comment_count': int,
  26. 'age_limit': 16,
  27. },
  28. }, {
  29. 'url': 'http://videomore.ru/embed/259974',
  30. 'info_dict': {
  31. 'id': '259974',
  32. 'ext': 'flv',
  33. 'title': 'Молодежка 2 сезон 40 серия',
  34. 'series': 'Молодежка',
  35. 'episode': '40 серия',
  36. 'thumbnail': 're:^https?://.*\.jpg',
  37. 'duration': 2809,
  38. 'view_count': int,
  39. 'comment_count': int,
  40. 'age_limit': 16,
  41. },
  42. 'params': {
  43. 'skip_download': True,
  44. },
  45. }, {
  46. 'url': 'http://videomore.ru/molodezhka/sezon_promo/341073',
  47. 'info_dict': {
  48. 'id': '341073',
  49. 'ext': 'flv',
  50. 'title': 'Промо Команда проиграла из-за Бакина?',
  51. 'episode': 'Команда проиграла из-за Бакина?',
  52. 'thumbnail': 're:^https?://.*\.jpg',
  53. 'duration': 29,
  54. 'age_limit': 16,
  55. 'view_count': int,
  56. },
  57. 'params': {
  58. 'skip_download': True,
  59. },
  60. }, {
  61. 'url': 'http://videomore.ru/elki_3?track_id=364623',
  62. 'only_matching': True,
  63. }, {
  64. 'url': 'http://videomore.ru/embed/364623',
  65. 'only_matching': True,
  66. }, {
  67. 'url': 'http://videomore.ru/video/tracks/364623.xml',
  68. 'only_matching': True,
  69. }, {
  70. 'url': 'http://videomore.ru/video/tracks/364623.json',
  71. 'only_matching': True,
  72. }, {
  73. 'url': 'http://videomore.ru/video/tracks/158031/quotes/33248',
  74. 'only_matching': True,
  75. }, {
  76. 'url': 'videomore:367617',
  77. 'only_matching': True,
  78. }]
  79. @staticmethod
  80. def _extract_url(webpage):
  81. mobj = re.search(
  82. r'<object[^>]+data=(["\'])https?://videomore\.ru/player\.swf\?.*config=(?P<url>https?://videomore\.ru/(?:[^/]+/)+\d+\.xml).*\1',
  83. webpage)
  84. if mobj:
  85. return mobj.group('url')
  86. def _real_extract(self, url):
  87. mobj = re.match(self._VALID_URL, url)
  88. video_id = mobj.group('sid') or mobj.group('id')
  89. video = self._download_xml(
  90. 'http://videomore.ru/video/tracks/%s.xml' % video_id,
  91. video_id, 'Downloading video XML')
  92. item = xpath_element(video, './/playlist/item', fatal=True)
  93. title = xpath_text(
  94. item, ('./title', './episode_name'), 'title', fatal=True)
  95. video_url = xpath_text(item, './video_url', 'video url', fatal=True)
  96. formats = self._extract_f4m_formats(video_url, video_id, f4m_id='hds')
  97. self._sort_formats(formats)
  98. thumbnail = xpath_text(item, './thumbnail_url')
  99. duration = int_or_none(xpath_text(item, './duration'))
  100. view_count = int_or_none(xpath_text(item, './views'))
  101. comment_count = int_or_none(xpath_text(item, './count_comments'))
  102. age_limit = int_or_none(xpath_text(item, './min_age'))
  103. series = xpath_text(item, './project_name')
  104. episode = xpath_text(item, './episode_name')
  105. return {
  106. 'id': video_id,
  107. 'title': title,
  108. 'series': series,
  109. 'episode': episode,
  110. 'thumbnail': thumbnail,
  111. 'duration': duration,
  112. 'view_count': view_count,
  113. 'comment_count': comment_count,
  114. 'age_limit': age_limit,
  115. 'formats': formats,
  116. }
  117. class VideomoreVideoIE(InfoExtractor):
  118. IE_NAME = 'videomore:video'
  119. _VALID_URL = r'https?://videomore\.ru/(?:(?:[^/]+/){2})?(?P<id>[^/?#&]+)[/?#&]*$'
  120. _TESTS = [{
  121. # single video with og:video:iframe
  122. 'url': 'http://videomore.ru/elki_3',
  123. 'info_dict': {
  124. 'id': '364623',
  125. 'ext': 'flv',
  126. 'title': 'Ёлки 3',
  127. 'description': '',
  128. 'thumbnail': 're:^https?://.*\.jpg',
  129. 'duration': 5579,
  130. 'age_limit': 6,
  131. 'view_count': int,
  132. },
  133. 'params': {
  134. 'skip_download': True,
  135. },
  136. }, {
  137. # season single series with og:video:iframe
  138. 'url': 'http://videomore.ru/poslednii_ment/1_sezon/14_seriya',
  139. 'only_matching': True,
  140. }, {
  141. 'url': 'http://videomore.ru/sejchas_v_seti/serii_221-240/226_vypusk',
  142. 'only_matching': True,
  143. }, {
  144. # single video without og:video:iframe
  145. 'url': 'http://videomore.ru/marin_i_ego_druzya',
  146. 'info_dict': {
  147. 'id': '359073',
  148. 'ext': 'flv',
  149. 'title': '1 серия. Здравствуй, Аквавилль!',
  150. 'description': 'md5:c6003179538b5d353e7bcd5b1372b2d7',
  151. 'thumbnail': 're:^https?://.*\.jpg',
  152. 'duration': 754,
  153. 'age_limit': 6,
  154. 'view_count': int,
  155. },
  156. 'params': {
  157. 'skip_download': True,
  158. },
  159. }]
  160. @classmethod
  161. def suitable(cls, url):
  162. return False if VideomoreIE.suitable(url) else super(VideomoreVideoIE, cls).suitable(url)
  163. def _real_extract(self, url):
  164. display_id = self._match_id(url)
  165. webpage = self._download_webpage(url, display_id)
  166. video_url = self._og_search_property(
  167. 'video:iframe', webpage, 'video url', default=None)
  168. if not video_url:
  169. video_id = self._search_regex(
  170. (r'config\s*:\s*["\']https?://videomore\.ru/video/tracks/(\d+)\.xml',
  171. r'track-id=["\'](\d+)',
  172. r'xcnt_product_id\s*=\s*(\d+)'), webpage, 'video id')
  173. video_url = 'videomore:%s' % video_id
  174. return self.url_result(video_url, VideomoreIE.ie_key())
  175. class VideomoreSeasonIE(InfoExtractor):
  176. IE_NAME = 'videomore:season'
  177. _VALID_URL = r'https?://videomore\.ru/(?!embed)(?P<id>[^/]+/[^/?#&]+)[/?#&]*$'
  178. _TESTS = [{
  179. 'url': 'http://videomore.ru/molodezhka/sezon_promo',
  180. 'info_dict': {
  181. 'id': 'molodezhka/sezon_promo',
  182. 'title': 'Молодежка Промо',
  183. },
  184. 'playlist_mincount': 12,
  185. }]
  186. def _real_extract(self, url):
  187. display_id = self._match_id(url)
  188. webpage = self._download_webpage(url, display_id)
  189. title = self._og_search_title(webpage)
  190. entries = [
  191. self.url_result(item) for item in re.findall(
  192. r'<a[^>]+href="((?:https?:)?//videomore\.ru/%s/[^/]+)"[^>]+class="widget-item-desc"'
  193. % display_id, webpage)]
  194. return self.playlist_result(entries, display_id, title)