3 from .common
import InfoExtractor
4 from ..utils
import int_or_none
7 class PyvideoIE(InfoExtractor
):
8 _VALID_URL
= r
'https?://(?:www\.)?pyvideo\.org/(?P<category>[^/]+)/(?P<id>[^/?#&.]+)'
11 'url': 'http://pyvideo.org/pycon-us-2013/become-a-logging-expert-in-30-minutes.html',
13 'id': 'become-a-logging-expert-in-30-minutes',
17 'url': 'http://pyvideo.org/pygotham-2012/gloriajw-spotifywitherikbernhardsson182m4v.html',
18 'md5': '5fe1c7e0a8aa5570330784c847ff6d12',
22 'title': 'Gloriajw-SpotifyWithErikBernhardsson182.m4v',
26 def _real_extract(self
, url
):
27 mobj
= self
._match
_valid
_url
(url
)
28 category
= mobj
.group('category')
29 video_id
= mobj
.group('id')
33 data
= self
._download
_json
(
34 f
'https://raw.githubusercontent.com/pyvideo/data/master/{category}/videos/{video_id}.json',
35 video_id
, fatal
=False)
38 for video
in data
['videos']:
39 video_url
= video
.get('url')
41 if video
.get('type') == 'youtube':
42 entries
.append(self
.url_result(video_url
, 'Youtube'))
45 'id': str(data
.get('id') or video_id
),
47 'title': data
['title'],
48 'description': data
.get('description') or data
.get('summary'),
49 'thumbnail': data
.get('thumbnail_url'),
50 'duration': int_or_none(data
.get('duration')),
53 webpage
= self
._download
_webpage
(url
, video_id
)
54 title
= self
._og
_search
_title
(webpage
)
55 media_urls
= self
._search
_regex
(
56 r
'(?s)Media URL:(.+?)</li>', webpage
, 'media urls')
58 r
'<a[^>]+href=(["\'])(?P
<url
>http
.+?
)\
1', media_urls):
59 media_url = m.group('url
')
60 if re.match(r'https?
://www\
.youtube\
.com
/watch
\?v
=.*', media_url):
61 entries.append(self.url_result(media_url, 'Youtube
'))
69 return self.playlist_result(entries, video_id)