]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/veoh.py
01e258e32218c227c5de3caf60588baab56e9045
1 from __future__
import unicode_literals
6 from . common
import InfoExtractor
16 class VeohIE ( InfoExtractor
):
17 _VALID_URL
= r
'http://(?:www\.)?veoh\.com/(?:watch|iphone/#_Watch)/(?P<id>(?:v|yapi-)[\da-zA-Z]+)'
21 'url' : 'http://www.veoh.com/watch/v56314296nk7Zdmz3' ,
22 'md5' : '620e68e6a3cff80086df3348426c9ca3' ,
26 'title' : 'Straight Backs Are Stronger' ,
27 'uploader' : 'LUMOback' ,
28 'description' : 'At LUMOback, we believe straight backs are stronger. The LUMOback Posture & Movement Sensor: It gently vibrates when you slouch, inspiring improved posture and mobility. Use the app to track your data and improve your posture over time. ' ,
32 'url' : 'http://www.veoh.com/watch/v27701988pbTc4wzN?h1=Chile+workers+cover+up+to+avoid+skin+damage' ,
33 'md5' : '4a6ff84b87d536a6a71e6aa6c0ad07fa' ,
37 'title' : 'Chile workers cover up to avoid skin damage' ,
38 'description' : 'md5:2bd151625a60a32822873efc246ba20d' ,
39 'uploader' : 'afp-news' ,
44 'url' : 'http://www.veoh.com/watch/v69525809F6Nc4frX' ,
45 'md5' : '4fde7b9e33577bab2f2f8f260e30e979' ,
46 'note' : 'Embedded ooyala video' ,
50 'title' : 'Doctors Alter Plan For Preteen \' s Weight Loss Surgery' ,
51 'description' : 'md5:f5a11c51f8fb51d2315bca0937526891' ,
52 'uploader' : 'newsy-videos' ,
54 'skip' : 'This video has been deleted.' ,
58 def _extract_formats ( self
, source
):
60 link
= source
. get ( 'aowPermalink' )
67 link
= source
. get ( 'fullPreviewHashLowPath' )
73 link
= source
. get ( 'fullPreviewHashHighPath' )
81 def _extract_video ( self
, source
):
83 'id' : source
. get ( 'videoId' ),
84 'title' : source
. get ( 'title' ),
85 'description' : source
. get ( 'description' ),
86 'thumbnail' : source
. get ( 'highResImage' ) or source
. get ( 'medResImage' ),
87 'uploader' : source
. get ( 'username' ),
88 'duration' : int_or_none ( source
. get ( 'length' )),
89 'view_count' : int_or_none ( source
. get ( 'views' )),
90 'age_limit' : 18 if source
. get ( 'isMature' ) == 'true' or source
. get ( 'isSexy' ) == 'true' else 0 ,
91 'formats' : self
._ extract
_ formats
( source
),
94 def _real_extract ( self
, url
):
95 mobj
= re
. match ( self
._ VALID
_U RL
, url
)
96 video_id
= mobj
. group ( 'id' )
98 if video_id
. startswith ( 'v' ):
99 rsp
= self
._ download
_ xml
(
100 r
'http://www.veoh.com/api/findByPermalink?permalink= %s ' % video_id
, video_id
, 'Downloading video XML' )
101 stat
= rsp
. get ( 'stat' )
103 return self
._ extract
_ video
( rsp
. find ( './videoList/video' ))
105 raise ExtractorError (
106 ' %s said: %s ' % ( self
. IE_NAME
, rsp
. find ( './errorList/error' ). get ( 'errorMessage' )), expected
= True )
108 webpage
= self
._ download
_ webpage
( url
, video_id
)
110 if 'class="adultwarning-container"' in webpage
:
111 self
. report_age_confirmation ()
113 request
= compat_urllib_request
. Request ( url
)
114 request
. add_header ( 'Cookie' , 'confirmedAdult=true' )
115 webpage
= self
._ download
_ webpage
( request
, video_id
)
117 m_youtube
= re
. search ( r
'http://www\.youtube\.com/v/(.*?)(\&|"|\?)' , webpage
)
118 if m_youtube
is not None :
119 youtube_id
= m_youtube
. group ( 1 )
120 self
. to_screen ( ' %s : detected Youtube video.' % video_id
)
121 return self
. url_result ( youtube_id
, 'Youtube' )
124 self
._ search
_ regex
( r
'videoDetailsJSON = \' ({.* ?
}) \' ; ', webpage, ' info
').replace(' \\\' ', ' \' '))
126 video = self._extract_video(info)
127 video[' age_limit
'] = age_limit