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.

227 lines
7.6 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': r'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': r'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': r'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 not mobj:
  85. mobj = re.search(
  86. r'<iframe[^>]+src=([\'"])(?P<url>https?://videomore\.ru/embed/\d+)',
  87. webpage)
  88. if mobj:
  89. return mobj.group('url')
  90. def _real_extract(self, url):
  91. mobj = re.match(self._VALID_URL, url)
  92. video_id = mobj.group('sid') or mobj.group('id')
  93. video = self._download_xml(
  94. 'http://videomore.ru/video/tracks/%s.xml' % video_id,
  95. video_id, 'Downloading video XML')
  96. item = xpath_element(video, './/playlist/item', fatal=True)
  97. title = xpath_text(
  98. item, ('./title', './episode_name'), 'title', fatal=True)
  99. video_url = xpath_text(item, './video_url', 'video url', fatal=True)
  100. formats = self._extract_f4m_formats(video_url, video_id, f4m_id='hds')
  101. self._sort_formats(formats)
  102. thumbnail = xpath_text(item, './thumbnail_url')
  103. duration = int_or_none(xpath_text(item, './duration'))
  104. view_count = int_or_none(xpath_text(item, './views'))
  105. comment_count = int_or_none(xpath_text(item, './count_comments'))
  106. age_limit = int_or_none(xpath_text(item, './min_age'))
  107. series = xpath_text(item, './project_name')
  108. episode = xpath_text(item, './episode_name')
  109. return {
  110. 'id': video_id,
  111. 'title': title,
  112. 'series': series,
  113. 'episode': episode,
  114. 'thumbnail': thumbnail,
  115. 'duration': duration,
  116. 'view_count': view_count,
  117. 'comment_count': comment_count,
  118. 'age_limit': age_limit,
  119. 'formats': formats,
  120. }
  121. class VideomoreVideoIE(InfoExtractor):
  122. IE_NAME = 'videomore:video'
  123. _VALID_URL = r'https?://videomore\.ru/(?:(?:[^/]+/){2})?(?P<id>[^/?#&]+)[/?#&]*$'
  124. _TESTS = [{
  125. # single video with og:video:iframe
  126. 'url': 'http://videomore.ru/elki_3',
  127. 'info_dict': {
  128. 'id': '364623',
  129. 'ext': 'flv',
  130. 'title': 'Ёлки 3',
  131. 'description': '',
  132. 'thumbnail': r're:^https?://.*\.jpg',
  133. 'duration': 5579,
  134. 'age_limit': 6,
  135. 'view_count': int,
  136. },
  137. 'params': {
  138. 'skip_download': True,
  139. },
  140. }, {
  141. # season single series with og:video:iframe
  142. 'url': 'http://videomore.ru/poslednii_ment/1_sezon/14_seriya',
  143. 'only_matching': True,
  144. }, {
  145. 'url': 'http://videomore.ru/sejchas_v_seti/serii_221-240/226_vypusk',
  146. 'only_matching': True,
  147. }, {
  148. # single video without og:video:iframe
  149. 'url': 'http://videomore.ru/marin_i_ego_druzya',
  150. 'info_dict': {
  151. 'id': '359073',
  152. 'ext': 'flv',
  153. 'title': '1 серия. Здравствуй, Аквавилль!',
  154. 'description': 'md5:c6003179538b5d353e7bcd5b1372b2d7',
  155. 'thumbnail': r're:^https?://.*\.jpg',
  156. 'duration': 754,
  157. 'age_limit': 6,
  158. 'view_count': int,
  159. },
  160. 'params': {
  161. 'skip_download': True,
  162. },
  163. }]
  164. @classmethod
  165. def suitable(cls, url):
  166. return False if VideomoreIE.suitable(url) else super(VideomoreVideoIE, cls).suitable(url)
  167. def _real_extract(self, url):
  168. display_id = self._match_id(url)
  169. webpage = self._download_webpage(url, display_id)
  170. video_url = self._og_search_property(
  171. 'video:iframe', webpage, 'video url', default=None)
  172. if not video_url:
  173. video_id = self._search_regex(
  174. (r'config\s*:\s*["\']https?://videomore\.ru/video/tracks/(\d+)\.xml',
  175. r'track-id=["\'](\d+)',
  176. r'xcnt_product_id\s*=\s*(\d+)'), webpage, 'video id')
  177. video_url = 'videomore:%s' % video_id
  178. return self.url_result(video_url, VideomoreIE.ie_key())
  179. class VideomoreSeasonIE(InfoExtractor):
  180. IE_NAME = 'videomore:season'
  181. _VALID_URL = r'https?://videomore\.ru/(?!embed)(?P<id>[^/]+/[^/?#&]+)[/?#&]*$'
  182. _TESTS = [{
  183. 'url': 'http://videomore.ru/molodezhka/sezon_promo',
  184. 'info_dict': {
  185. 'id': 'molodezhka/sezon_promo',
  186. 'title': 'Молодежка Промо',
  187. },
  188. 'playlist_mincount': 12,
  189. }]
  190. def _real_extract(self, url):
  191. display_id = self._match_id(url)
  192. webpage = self._download_webpage(url, display_id)
  193. title = self._og_search_title(webpage)
  194. entries = [
  195. self.url_result(item) for item in re.findall(
  196. r'<a[^>]+href="((?:https?:)?//videomore\.ru/%s/[^/]+)"[^>]+class="widget-item-desc"'
  197. % display_id, webpage)]
  198. return self.playlist_result(entries, display_id, title)