]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/newstube.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..utils
import ExtractorError
10 class NewstubeIE(InfoExtractor
):
11 _VALID_URL
= r
'https?://(?:www\.)?newstube\.ru/media/(?P<id>.+)'
13 'url': 'http://www.newstube.ru/media/telekanal-cnn-peremestil-gorod-slavyansk-v-krym',
15 'id': '728e0ef2-e187-4012-bac0-5a081fdcb1f6',
17 'title': 'Телеканал CNN переместил город Славянск в Крым',
18 'description': 'md5:419a8c9f03442bc0b0a794d689360335',
23 'skip_download': True,
27 def _real_extract(self
, url
):
28 mobj
= re
.match(self
._VALID
_URL
, url
)
29 video_id
= mobj
.group('id')
31 page
= self
._download
_webpage
(url
, video_id
, 'Downloading page')
33 video_guid
= self
._html
_search
_regex
(
34 r
'<meta property="og:video" content="https?://(?:www\.)?newstube\.ru/freshplayer\.swf\?guid=(?P<guid>[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12})',
37 player
= self
._download
_xml
(
38 'http://p.newstube.ru/v2/player.asmx/GetAutoPlayInfo6?state=&url=%s&sessionId=&id=%s&placement=profile&location=n2' % (url
, video_guid
),
39 video_guid
, 'Downloading player XML')
42 return s
.replace('/', '/%(ns)s') % {'ns': '{http://app1.newstube.ru/N2SiteWS/player.asmx}'}
44 error_message
= player
.find(ns('./ErrorMessage'))
45 if error_message
is not None:
46 raise ExtractorError('%s returned error: %s' % (self
.IE_NAME
, error_message
.text
), expected
=True)
48 session_id
= player
.find(ns('./SessionId')).text
49 media_info
= player
.find(ns('./Medias/MediaInfo'))
50 title
= media_info
.find(ns('./Name')).text
51 description
= self
._og
_search
_description
(page
)
52 thumbnail
= media_info
.find(ns('./KeyFrame')).text
53 duration
= int(media_info
.find(ns('./Duration')).text
) / 1000.0
57 for stream_info
in media_info
.findall(ns('./Streams/StreamInfo')):
58 media_location
= stream_info
.find(ns('./MediaLocation'))
59 if media_location
is None:
62 server
= media_location
.find(ns('./Server')).text
63 app
= media_location
.find(ns('./App')).text
64 media_id
= stream_info
.find(ns('./Id')).text
65 quality_id
= stream_info
.find(ns('./QualityId')).text
66 name
= stream_info
.find(ns('./Name')).text
67 width
= int(stream_info
.find(ns('./Width')).text
)
68 height
= int(stream_info
.find(ns('./Height')).text
)
71 'url': 'rtmp://%s/%s' % (server
, app
),
73 'play_path': '01/%s' % video_guid
.upper(),
74 'rtmp_conn': ['S:%s' % session_id
, 'S:%s' % media_id
, 'S:n2'],
77 'format_id': quality_id
,
83 self
._sort
_formats
(formats
)
88 'description': description
,
89 'thumbnail': thumbnail
,