]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/ninegag.py
[youtube] Correct subtitle URL (Fixes #2120)
[yt-dlp.git] / youtube_dl / extractor / ninegag.py
CommitLineData
7fc3fa05
PH
1import json
2import re
3
4from .common import InfoExtractor
5
6
7class NineGagIE(InfoExtractor):
8 IE_NAME = '9gag'
9 _VALID_URL = r'^https?://(?:www\.)?9gag\.tv/v/(?P<id>[0-9]+)'
10
11 _TEST = {
12 u"url": u"http://9gag.tv/v/1912",
13 u"file": u"1912.mp4",
14 u"info_dict": {
15 u"description": u"This 3-minute video will make you smile and then make you feel untalented and insignificant. Anyway, you should share this awesomeness. (Thanks, Dino!)",
16 u"title": u"\"People Are Awesome 2013\" Is Absolutely Awesome"
17 },
18 u'add_ie': [u'Youtube']
19 }
20
21 def _real_extract(self, url):
22 mobj = re.match(self._VALID_URL, url)
23 video_id = mobj.group('id')
24
25 webpage = self._download_webpage(url, video_id)
26 data_json = self._html_search_regex(r'''(?x)
27 <div\s*id="tv-video"\s*data-video-source="youtube"\s*
28 data-video-meta="([^"]+)"''', webpage, u'video metadata')
29
30 data = json.loads(data_json)
31
32 return {
33 '_type': 'url_transparent',
34 'url': data['youtubeVideoId'],
35 'ie_key': 'Youtube',
36 'id': video_id,
37 'title': data['title'],
38 'description': data['description'],
39 'view_count': int(data['view_count']),
19e3dfc9
PH
40 'like_count': int(data['statistic']['like']),
41 'dislike_count': int(data['statistic']['dislike']),
7fc3fa05
PH
42 'thumbnail': data['thumbnail_url'],
43 }