]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/nationalgeographic.py
Fix extraction from youtube.
[youtubedl] / youtube_dl / extractor / nationalgeographic.py
1 from __future__ import unicode_literals
2
3 from .common import InfoExtractor
4 from ..utils import (
5 smuggle_url,
6 url_basename,
7 )
8
9
10 class NationalGeographicVideoIE(InfoExtractor):
11 IE_NAME = 'natgeo:video'
12 _VALID_URL = r'https?://video\.nationalgeographic\.com/.*?'
13
14 _TESTS = [
15 {
16 'url': 'http://video.nationalgeographic.com/video/news/150210-news-crab-mating-vin?source=featuredvideo',
17 'md5': '730855d559abbad6b42c2be1fa584917',
18 'info_dict': {
19 'id': '0000014b-70a1-dd8c-af7f-f7b559330001',
20 'ext': 'mp4',
21 'title': 'Mating Crabs Busted by Sharks',
22 'description': 'md5:16f25aeffdeba55aaa8ec37e093ad8b3',
23 'timestamp': 1423523799,
24 'upload_date': '20150209',
25 'uploader': 'NAGS',
26 },
27 'add_ie': ['ThePlatform'],
28 },
29 {
30 'url': 'http://video.nationalgeographic.com/wild/when-sharks-attack/the-real-jaws',
31 'md5': '6a3105eb448c070503b3105fb9b320b5',
32 'info_dict': {
33 'id': 'ngc-I0IauNSWznb_UV008GxSbwY35BZvgi2e',
34 'ext': 'mp4',
35 'title': 'The Real Jaws',
36 'description': 'md5:8d3e09d9d53a85cd397b4b21b2c77be6',
37 'timestamp': 1433772632,
38 'upload_date': '20150608',
39 'uploader': 'NAGS',
40 },
41 'add_ie': ['ThePlatform'],
42 },
43 ]
44
45 def _real_extract(self, url):
46 name = url_basename(url)
47
48 webpage = self._download_webpage(url, name)
49 guid = self._search_regex(
50 r'id="(?:videoPlayer|player-container)"[^>]+data-guid="([^"]+)"',
51 webpage, 'guid')
52
53 return {
54 '_type': 'url_transparent',
55 'ie_key': 'ThePlatform',
56 'url': smuggle_url(
57 'http://link.theplatform.com/s/ngs/media/guid/2423130747/%s?mbr=true' % guid,
58 {'force_smil_url': True}),
59 'id': guid,
60 }