]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/kinopoisk.py
   2 from __future__ 
import unicode_literals
 
   4 from .common 
import InfoExtractor
 
  11 class KinoPoiskIE(InfoExtractor
): 
  12     _GEO_COUNTRIES 
= ['RU'] 
  13     _VALID_URL 
= r
'https?://(?:www\.)?kinopoisk\.ru/film/(?P<id>\d+)' 
  15         'url': 'https://www.kinopoisk.ru/film/81041/watch/', 
  16         'md5': '4f71c80baea10dfa54a837a46111d326', 
  20             'title': 'Алеша попович и тугарин змей', 
  21             'description': 'md5:43787e673d68b805d0aa1df5a5aea701', 
  22             'thumbnail': r
're:^https?://.*', 
  27             'format': 'bestvideo', 
  30         'url': 'https://www.kinopoisk.ru/film/81041', 
  31         'only_matching': True, 
  34     def _real_extract(self
, url
): 
  35         video_id 
= self
._match
_id
(url
) 
  37         webpage 
= self
._download
_webpage
( 
  38             'https://ott-widget.kinopoisk.ru/v1/kp/', video_id
, 
  39             query
={'kpId': video_id
}) 
  41         data 
= self
._parse
_json
( 
  43                 r
'(?s)<script[^>]+\btype=["\']application
/json
[^
>]+>(.+?
)<', 
  47         film = data['filmStatus
'] 
  48         title = film.get('title
') or film['originalTitle
'] 
  50         formats = self._extract_m3u8_formats( 
  51             data['playlistEntity
']['uri
'], video_id, 'mp4
', 
  52             entry_protocol='m3u8_native
', m3u8_id='hls
') 
  53         self._sort_formats(formats) 
  55         description = dict_get( 
  56             film, ('descriptscription
', 'description
', 
  57                    'shortDescriptscription
', 'shortDescription
')) 
  58         thumbnail = film.get('coverUrl
') or film.get('posterUrl
') 
  59         duration = int_or_none(film.get('duration
')) 
  60         age_limit = int_or_none(film.get('restrictionAge
')) 
  65             'description
': description, 
  66             'thumbnail
': thumbnail, 
  68             'age_limit
': age_limit,