]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/liveleak.py
26671753c429401fc9085b69e5a0aae10d495e6f
1 from __future__
import unicode_literals
5 from . common
import InfoExtractor
6 from .. utils
import int_or_none
9 class LiveLeakIE ( InfoExtractor
):
10 _VALID_URL
= r
'https?://(?:\w+\.)?liveleak\.com/view\?.*?\b[it]=(?P<id>[\w_]+)'
12 'url' : 'http://www.liveleak.com/view?i=757_1364311680' ,
13 'md5' : '0813c2430bea7a46bf13acf3406992f4' ,
15 'id' : '757_1364311680' ,
17 'description' : 'extremely bad day for this guy..!' ,
18 'uploader' : 'ljfriel2' ,
19 'title' : 'Most unlucky car accident' ,
20 'thumbnail' : r
're:^https?://.*\.jpg$'
23 'url' : 'http://www.liveleak.com/view?i=f93_1390833151' ,
24 'md5' : 'd3f1367d14cc3c15bf24fbfbe04b9abf' ,
26 'id' : 'f93_1390833151' ,
28 'description' : 'German Television Channel NDR does an exclusive interview with Edward Snowden. \r\n Uploaded on LiveLeak cause German Television thinks the rest of the world isn \' t intereseted in Edward Snowden.' ,
29 'uploader' : 'ARD_Stinkt' ,
30 'title' : 'German Television does first Edward Snowden Interview (ENGLISH)' ,
31 'thumbnail' : r
're:^https?://.*\.jpg$'
35 'url' : 'http://www.liveleak.com/view?i=4f7_1392687779' ,
36 'md5' : '42c6d97d54f1db107958760788c5f48f' ,
38 'id' : '4f7_1392687779' ,
40 'description' : "The guy with the cigarette seems amazingly nonchalant about the whole thing... I really hope my friends' reactions would be a bit stronger. \r\n\r\n Action-go to 0:55." ,
41 'uploader' : 'CapObveus' ,
42 'title' : 'Man is Fatally Struck by Reckless Car While Packing up a Moving Truck' ,
45 'skip' : 'Video is dead' ,
47 # Covers https://github.com/rg3/youtube-dl/pull/5983
48 # Multiple resolutions
49 'url' : 'http://www.liveleak.com/view?i=801_1409392012' ,
50 'md5' : 'c3a449dbaca5c0d1825caecd52a57d7b' ,
52 'id' : '801_1409392012' ,
54 'description' : 'Happened on 27.7.2014. \r\n At 0:53 you can see people still swimming at near beach.' ,
55 'uploader' : 'bony333' ,
56 'title' : 'Crazy Hungarian tourist films close call waterspout in Croatia' ,
57 'thumbnail' : r
're:^https?://.*\.jpg$'
60 # Covers https://github.com/rg3/youtube-dl/pull/10664#issuecomment-247439521
61 'url' : 'http://m.liveleak.com/view?i=763_1473349649' ,
62 'add_ie' : [ 'Youtube' ],
64 'id' : '763_1473349649' ,
66 'title' : 'Reporters and public officials ignore epidemic of black on asian violence in Sacramento | Colin Flaherty' ,
67 'description' : 'Colin being the warrior he is and showing the injustice Asians in Sacramento are being subjected to.' ,
69 'upload_date' : '20160908' ,
70 'uploader_id' : 'UCEbta5E_jqlZmEJsriTEtnw'
73 'skip_download' : True ,
76 'url' : 'https://www.liveleak.com/view?i=677_1439397581' ,
78 'id' : '677_1439397581' ,
79 'title' : 'Fuel Depot in China Explosion caught on video' ,
83 'url' : 'https://www.liveleak.com/view?t=HvHi_1523016227' ,
84 'only_matching' : True ,
88 def _extract_urls ( webpage
):
90 r
'<iframe[^>]+src="(https?://(?:\w+\.)?liveleak\.com/ll_embed\?[^"]*[if]=[\w_]+[^"]+)"' ,
93 def _real_extract ( self
, url
):
94 video_id
= self
._ match
_ id
( url
)
95 webpage
= self
._ download
_ webpage
( url
, video_id
)
97 video_title
= self
._ og
_ search
_ title
( webpage
). replace ( 'LiveLeak.com -' , '' ). strip ()
98 video_description
= self
._ og
_ search
_ description
( webpage
)
99 video_uploader
= self
._ html
_ search
_ regex
(
100 r
'By:.*?(\w+)</a>' , webpage
, 'uploader' , fatal
= False )
101 age_limit
= int_or_none ( self
._ search
_ regex
(
102 r
'you confirm that you are ([0-9]+) years and over.' ,
103 webpage
, 'age limit' , default
= None ))
104 video_thumbnail
= self
._ og
_ search
_ thumbnail
( webpage
)
106 entries
= self
._ parse
_ html
5_ media
_ entries
( url
, webpage
, video_id
)
109 embed_url
= self
._ search
_ regex
(
110 r
'<iframe[^>]+src="((?:https?:)?//(?:www\.)?(?:prochan|youtube)\.com/embed[^"]+)"' ,
111 webpage
, 'embed URL' )
113 '_type' : 'url_transparent' ,
116 'title' : video_title
,
117 'description' : video_description
,
118 'uploader' : video_uploader
,
119 'age_limit' : age_limit
,
122 for idx
, info_dict
in enumerate ( entries
):
123 for a_format
in info_dict
[ 'formats' ]:
124 if not a_format
. get ( 'height' ):
125 a_format
[ 'height' ] = int_or_none ( self
._ search
_ regex
(
126 r
'([0-9]+)p\.mp4' , a_format
[ 'url' ], 'height label' ,
129 self
._ sort
_ formats
( info_dict
[ 'formats' ])
131 # Don't append entry ID for one-video pages to keep backward compatibility
133 info_dict
[ 'id' ] = ' %s _ %s ' % ( video_id
, idx
+ 1 )
135 info_dict
[ 'id' ] = video_id
138 'title' : video_title
,
139 'description' : video_description
,
140 'uploader' : video_uploader
,
141 'age_limit' : age_limit
,
142 'thumbnail' : video_thumbnail
,
145 return self
. playlist_result ( entries
, video_id
, video_title
)
148 class LiveLeakEmbedIE ( InfoExtractor
):
149 _VALID_URL
= r
'https?://(?:www\.)?liveleak\.com/ll_embed\?.*?\b(?P<kind>[if])=(?P<id>[\w_]+)'
151 # See generic.py for actual test cases
153 'url' : 'https://www.liveleak.com/ll_embed?i=874_1459135191' ,
154 'only_matching' : True ,
156 'url' : 'https://www.liveleak.com/ll_embed?f=ab065df993c1' ,
157 'only_matching' : True ,
160 def _real_extract ( self
, url
):
161 mobj
= re
. match ( self
._ VALID
_U RL
, url
)
162 kind
, video_id
= mobj
. group ( 'kind' , 'id' )
165 webpage
= self
._ download
_ webpage
( url
, video_id
)
166 liveleak_url
= self
._ search
_ regex
(
167 r
'logourl\s*:\s*(?P<q1>[\' "])(?P<url> %s )(?P=q1)' % LiveLeakIE._VALID_URL,
168 webpage, 'LiveLeak URL', group='url')
170 liveleak_url = 'http://www.liveleak.com/view?i= %s ' % video_id
172 return self.url_result(liveleak_url, ie=LiveLeakIE.ie_key())