]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/cnn.py 
   1  from  __future__ 
import  unicode_literals
   5  from  . common 
import  InfoExtractor
   6  from  . turner 
import  TurnerBaseIE
   7  from  .. utils 
import  url_basename
  10  class  CNNIE ( TurnerBaseIE
):   11      _VALID_URL 
=  r
'''(?x)https?://(?:(?P<sub_domain>edition|www|money)\.)?cnn\.com/(?:video/(?:data/.+?|\?)/)?videos?/   12          (?P<path>.+?/(?P<title>[^/]+?)(?:\.(?:[a-z\-]+)|(?=&)))'''   15          'url' :  'http://edition.cnn.com/video/?/video/sports/2013/06/09/nadal-1-on-1.cnn' ,   16          'md5' :  '3e6121ea48df7e2259fe73a0628605c4' ,   18              'id' :  'sports/2013/06/09/nadal-1-on-1.cnn' ,   20              'title' :  'Nadal wins 8th French Open title' ,   21              'description' :  'World Sport \' s Amanda Davies chats with 2013 French Open champion Rafael Nadal.' ,   23              'upload_date' :  '20130609' ,   25          'expected_warnings' : [ 'Failed to download m3u8 information' ],   27          'url' :  'http://edition.cnn.com/video/?/video/us/2013/08/21/sot-student-gives-epic-speech.georgia-institute-of-technology&utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+rss%2Fcnn_topstories+%28RSS%3A+Top+Stories%29' ,   28          'md5' :  'b5cc60c60a3477d185af8f19a2a26f4e' ,   30              'id' :  'us/2013/08/21/sot-student-gives-epic-speech.georgia-institute-of-technology' ,   32              'title' :  "Student's epic speech stuns new freshmen" ,   33              'description' :  "A Georgia Tech student welcomes the incoming freshmen with an epic speech backed by music from  \" 2001: A Space Odyssey. \" " ,   34              'upload_date' :  '20130821' ,   36          'expected_warnings' : [ 'Failed to download m3u8 information' ],   38          'url' :  'http://www.cnn.com/video/data/2.0/video/living/2014/12/22/growing-america-nashville-salemtown-board-episode-1.hln.html' ,   39          'md5' :  'f14d02ebd264df951feb2400e2c25a1b' ,   41              'id' :  'living/2014/12/22/growing-america-nashville-salemtown-board-episode-1.hln' ,   43              'title' :  'Nashville Ep. 1: Hand crafted skateboards' ,   44              'description' :  'md5:e7223a503315c9f150acac52e76de086' ,   45              'upload_date' :  '20141222' ,   47          'expected_warnings' : [ 'Failed to download m3u8 information' ],   49          'url' :  'http://money.cnn.com/video/news/2016/08/19/netflix-stunning-stats.cnnmoney/index.html' ,   50          'md5' :  '52a515dc1b0f001cd82e4ceda32be9d1' ,   52              'id' :  '/video/news/2016/08/19/netflix-stunning-stats.cnnmoney' ,   54              'title' :  '5 stunning stats about Netflix' ,   55              'description' :  'Did you know that Netflix has more than 80 million members? Here are five facts about the online video distributor that you probably didn \' t know.' ,   56              'upload_date' :  '20160819' ,   60              'skip_download' :  True ,   63          'url' :  'http://cnn.com/video/?/video/politics/2015/03/27/pkg-arizona-senator-church-attendance-mandatory.ktvk' ,   64          'only_matching' :  True ,   66          'url' :  'http://cnn.com/video/?/video/us/2015/04/06/dnt-baker-refuses-anti-gay-order.wkmg' ,   67          'only_matching' :  True ,   69          'url' :  'http://edition.cnn.com/videos/arts/2016/04/21/olympic-games-cultural-a-z-brazil.cnn' ,   70          'only_matching' :  True ,   74          # http://edition.cnn.com/.element/apps/cvp/3.0/cfg/spider/cnn/expansion/config.xml   76              'data_src' :  'http://edition.cnn.com/video/data/3.0/video/ %s /index.xml' ,   77              'media_src' :  'http://pmd.cdn.turner.com/cnn/big' ,   79          # http://money.cnn.com/.element/apps/cvp2/cfg/config.xml   81              'data_src' :  'http://money.cnn.com/video/data/4.0/video/ %s .xml' ,   82              'media_src' :  'http://ht3.cdn.turner.com/money/big' ,   86      def  _extract_timestamp ( self
,  video_data
):   87          # TODO: fix timestamp extraction   90      def  _real_extract ( self
,  url
):   91          sub_domain
,  path
,  page_title 
=  re
. match ( self
._ VALID
_U RL
,  url
). groups ()   92          if  sub_domain 
not in  ( 'money' ,  'edition' ):   93              sub_domain 
=  'edition'   94          config 
=  self
._ CONFIG
[ sub_domain
]   95          return  self
._ extract
_ cvp
_ info
(   96              config
[ 'data_src' ] %  path
,  page_title
, {   98                      'media_src' :  config
[ 'media_src' ],  103  class  CNNBlogsIE ( InfoExtractor
):  104      _VALID_URL 
=  r
'https?://[^\.]+\.blogs\.cnn\.com/.+'  106          'url' :  'http://reliablesources.blogs.cnn.com/2014/02/09/criminalizing-journalism/' ,  107          'md5' :  '3e56f97b0b6ffb4b79f4ea0749551084' ,  109              'id' :  'bestoftv/2014/02/09/criminalizing-journalism.cnn' ,  111              'title' :  'Criminalizing journalism?' ,  112              'description' :  'Glenn Greenwald responds to comments made this week on Capitol Hill that journalists could be criminal accessories.' ,  113              'upload_date' :  '20140209' ,  115          'expected_warnings' : [ 'Failed to download m3u8 information' ],  119      def  _real_extract ( self
,  url
):  120          webpage 
=  self
._ download
_ webpage
( url
,  url_basename ( url
))  121          cnn_url 
=  self
._ html
_ search
_ regex
( r
'data-url="(.+?)"' ,  webpage
,  'cnn url' )  122          return  self
. url_result ( cnn_url
,  CNNIE
. ie_key ())  125  class  CNNArticleIE ( InfoExtractor
):  126      _VALID_URL 
=  r
'https?://(?:(?:edition|www)\.)?cnn\.com/(?!videos?/)'  128          'url' :  'http://www.cnn.com/2014/12/21/politics/obama-north-koreas-hack-not-war-but-cyber-vandalism/' ,  129          'md5' :  '689034c2a3d9c6dc4aa72d65a81efd01' ,  131              'id' :  'bestoftv/2014/12/21/ip-north-korea-obama.cnn' ,  133              'title' :  'Obama: Cyberattack not an act of war' ,  134              'description' :  'md5:0a802a40d2376f60e6b04c8d5bcebc4b' ,  135              'upload_date' :  '20141221' ,  137          'expected_warnings' : [ 'Failed to download m3u8 information' ],  141      def  _real_extract ( self
,  url
):  142          webpage 
=  self
._ download
_ webpage
( url
,  url_basename ( url
))  143          cnn_url 
=  self
._ html
_ search
_ regex
( r
"video:\s*'([^']+)'" ,  webpage
,  'cnn url' )  144          return  self
. url_result ( 'http://cnn.com/video/?/video/'  +  cnn_url
,  CNNIE
. ie_key ())