]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/breakcom.py
1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
6 from .youtube
import YoutubeIE
13 class BreakIE(InfoExtractor
):
14 _VALID_URL
= r
'https?://(?:www\.)?break\.com/video/(?P<display_id>[^/]+?)(?:-(?P<id>\d+))?(?:[/?#&]|$)'
16 'url': 'http://www.break.com/video/when-girls-act-like-guys-2468056',
20 'title': 'When Girls Act Like D-Bags',
25 'url': 'http://www.break.com/video/someone-forgot-boat-brakes-work',
29 'title': 'Whale Watching Boat Crashing Into San Diego Dock',
30 'description': 'md5:afc1b2772f0a8468be51dd80eb021069',
31 'upload_date': '20160331',
32 'uploader': 'Steve Holden',
33 'uploader_id': 'sdholden07',
36 'skip_download': True,
39 'url': 'http://www.break.com/video/ugc/baby-flex-2773063',
40 'only_matching': True,
43 def _real_extract(self
, url
):
44 display_id
, video_id
= re
.match(self
._VALID
_URL
, url
).groups()
46 webpage
= self
._download
_webpage
(url
, display_id
)
48 youtube_url
= YoutubeIE
._extract
_url
(webpage
)
50 return self
.url_result(youtube_url
, ie
=YoutubeIE
.ie_key())
52 content
= self
._parse
_json
(
54 r
'(?s)content["\']\s
*:\s
*(\
[.+?\
])\s
*[,\n]', webpage,
60 video_url = url_or_none(video.get('url
'))
63 bitrate = int_or_none(self._search_regex(
64 r'(\d
+)_kbps
', video_url, 'tbr
', default=None))
67 'format_id
': 'http
-%d' % bitrate if bitrate else 'http
',
70 self._sort_formats(formats)
72 title = self._search_regex(
73 (r'title
["\']\s*:\s*(["\'])(?P
<value
>(?
:(?
!\
1).)+)\
1',
74 r'<h1
[^
>]*>(?P
<value
>[^
<]+)'), webpage, 'title
', group='value
')
77 return int_or_none(self._search_regex(
78 r'%s["\']\s*:\s*["\'](\d
+)' % key, webpage, name,
81 age_limit = get('ratings
', 'age limit
')
82 video_id = video_id or get('pid
', 'video
id') or display_id
86 'display_id
': display_id,
88 'thumbnail
': self._og_search_thumbnail(webpage),
89 'age_limit
': age_limit,