]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/ninegag.py
1 from __future__
import unicode_literals
6 from . common
import InfoExtractor
9 class NineGagIE ( InfoExtractor
):
11 _VALID_URL
= r
'^https?://(?:www\.)?9gag\.tv/v/(?P<id>[0-9]+)'
14 "url" : "http://9gag.tv/v/1912" ,
17 "description" : "This 3-minute video will make you smile and then make you feel untalented and insignificant. Anyway, you should share this awesomeness. (Thanks, Dino!)" ,
18 "title" : " \" People Are Awesome 2013 \" Is Absolutely Awesome"
23 def _real_extract ( self
, url
):
24 mobj
= re
. match ( self
._ VALID
_U RL
, url
)
25 video_id
= mobj
. group ( 'id' )
27 webpage
= self
._ download
_ webpage
( url
, video_id
)
28 data_json
= self
._ html
_ search
_ regex
( r
'''(?x)
29 <div\s*id="tv-video"\s*data-video-source="youtube"\s*
30 data-video-meta="([^"]+)"''' , webpage
, 'video metadata' )
32 data
= json
. loads ( data_json
)
35 '_type' : 'url_transparent' ,
36 'url' : data
[ 'youtubeVideoId' ],
39 'title' : data
[ 'title' ],
40 'description' : data
[ 'description' ],
41 'view_count' : int ( data
[ 'view_count' ]),
42 'like_count' : int ( data
[ 'statistic' ][ 'like' ]),
43 'dislike_count' : int ( data
[ 'statistic' ][ 'dislike' ]),
44 'thumbnail' : data
[ 'thumbnail_url' ],