[ndtv] Fix title extraction and modernize
This commit is contained in:
parent
9706f3f802
commit
3141feb73b
1 changed files with 28 additions and 18 deletions
|
@ -1,22 +1,28 @@
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import month_by_name
|
from ..utils import (
|
||||||
|
month_by_name,
|
||||||
|
int_or_none,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class NDTVIE(InfoExtractor):
|
class NDTVIE(InfoExtractor):
|
||||||
_VALID_URL = r'^https?://(?:www\.)?ndtv\.com/video/player/[^/]*/[^/]*/(?P<id>[a-z0-9]+)'
|
_VALID_URL = r'^https?://(?:www\.)?ndtv\.com/video/player/[^/]*/[^/]*/(?P<id>[a-z0-9]+)'
|
||||||
|
|
||||||
_TEST = {
|
_TEST = {
|
||||||
u"url": u"http://www.ndtv.com/video/player/news/ndtv-exclusive-don-t-need-character-certificate-from-rahul-gandhi-says-arvind-kejriwal/300710",
|
'url': 'http://www.ndtv.com/video/player/news/ndtv-exclusive-don-t-need-character-certificate-from-rahul-gandhi-says-arvind-kejriwal/300710',
|
||||||
u"file": u"300710.mp4",
|
'md5': '39f992dbe5fb531c395d8bbedb1e5e88',
|
||||||
u"md5": u"39f992dbe5fb531c395d8bbedb1e5e88",
|
'info_dict': {
|
||||||
u"info_dict": {
|
'id': '300710',
|
||||||
u"title": u"NDTV exclusive: Don't need character certificate from Rahul Gandhi, says Arvind Kejriwal",
|
'ext': 'mp4',
|
||||||
u"description": u"In an exclusive interview to NDTV, Aam Aadmi Party's Arvind Kejriwal says it makes no difference to him that Rahul Gandhi said the Congress needs to learn from his party.",
|
'title': "NDTV exclusive: Don't need character certificate from Rahul Gandhi, says Arvind Kejriwal",
|
||||||
u"upload_date": u"20131208",
|
'description': 'md5:ab2d4b4a6056c5cb4caa6d729deabf02',
|
||||||
u"duration": 1327,
|
'upload_date': '20131208',
|
||||||
u"thumbnail": u"http://i.ndtvimg.com/video/images/vod/medium/2013-12/big_300710_1386518307.jpg",
|
'duration': 1327,
|
||||||
|
'thumbnail': 'http://i.ndtvimg.com/video/images/vod/medium/2013-12/big_300710_1386518307.jpg',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,13 +33,12 @@ class NDTVIE(InfoExtractor):
|
||||||
webpage = self._download_webpage(url, video_id)
|
webpage = self._download_webpage(url, video_id)
|
||||||
|
|
||||||
filename = self._search_regex(
|
filename = self._search_regex(
|
||||||
r"__filename='([^']+)'", webpage, u'video filename')
|
r"__filename='([^']+)'", webpage, 'video filename')
|
||||||
video_url = (u'http://bitcast-b.bitgravity.com/ndtvod/23372/ndtv/%s' %
|
video_url = ('http://bitcast-b.bitgravity.com/ndtvod/23372/ndtv/%s' %
|
||||||
filename)
|
filename)
|
||||||
|
|
||||||
duration_str = filename = self._search_regex(
|
duration = int_or_none(self._search_regex(
|
||||||
r"__duration='([^']+)'", webpage, u'duration', fatal=False)
|
r"__duration='([^']+)'", webpage, 'duration', fatal=False))
|
||||||
duration = None if duration_str is None else int(duration_str)
|
|
||||||
|
|
||||||
date_m = re.search(r'''(?x)
|
date_m = re.search(r'''(?x)
|
||||||
<p\s+class="vod_dateline">\s*
|
<p\s+class="vod_dateline">\s*
|
||||||
|
@ -41,7 +46,7 @@ class NDTVIE(InfoExtractor):
|
||||||
(?P<monthname>[A-Za-z]+)\s+(?P<day>[0-9]+),\s*(?P<year>[0-9]+)
|
(?P<monthname>[A-Za-z]+)\s+(?P<day>[0-9]+),\s*(?P<year>[0-9]+)
|
||||||
''', webpage)
|
''', webpage)
|
||||||
upload_date = None
|
upload_date = None
|
||||||
assert date_m
|
|
||||||
if date_m is not None:
|
if date_m is not None:
|
||||||
month = month_by_name(date_m.group('monthname'))
|
month = month_by_name(date_m.group('monthname'))
|
||||||
if month is not None:
|
if month is not None:
|
||||||
|
@ -49,14 +54,19 @@ class NDTVIE(InfoExtractor):
|
||||||
date_m.group('year'), month, int(date_m.group('day')))
|
date_m.group('year'), month, int(date_m.group('day')))
|
||||||
|
|
||||||
description = self._og_search_description(webpage)
|
description = self._og_search_description(webpage)
|
||||||
READ_MORE = u' (Read more)'
|
READ_MORE = ' (Read more)'
|
||||||
if description.endswith(READ_MORE):
|
if description.endswith(READ_MORE):
|
||||||
description = description[:-len(READ_MORE)]
|
description = description[:-len(READ_MORE)]
|
||||||
|
|
||||||
|
title = self._og_search_title(webpage)
|
||||||
|
TITLE_SUFFIX = ' - NDTV'
|
||||||
|
if title.endswith(TITLE_SUFFIX):
|
||||||
|
title = title[:-len(TITLE_SUFFIX)]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'url': video_url,
|
'url': video_url,
|
||||||
'title': self._og_search_title(webpage),
|
'title': title,
|
||||||
'description': description,
|
'description': description,
|
||||||
'thumbnail': self._og_search_thumbnail(webpage),
|
'thumbnail': self._og_search_thumbnail(webpage),
|
||||||
'duration': duration,
|
'duration': duration,
|
||||||
|
|
Loading…
Reference in a new issue