correct the extractor name and id and remove unnecessary request

This commit is contained in:
remitamine 2015-09-03 16:59:10 +01:00
parent 9f4921bfa0
commit b477da2094
2 changed files with 19 additions and 11 deletions

View File

@ -121,7 +121,7 @@ from .dbtv import DBTVIE
from .dcn import ( from .dcn import (
DCNGeneralIE, DCNGeneralIE,
DCNVideoIE, DCNVideoIE,
DCNShowIE, DCNSeasonIE,
) )
from .dctp import DctpTvIE from .dctp import DctpTvIE
from .deezer import DeezerPlaylistIE from .deezer import DeezerPlaylistIE

View File

@ -11,6 +11,8 @@ from ..compat import (
from ..utils import ( from ..utils import (
int_or_none, int_or_none,
parse_iso8601, parse_iso8601,
smuggle_url,
unsmuggle_url,
) )
@ -25,9 +27,9 @@ class DCNGeneralIE(InfoExtractor):
url = 'http://www.dcndigital.ae/#/media/%s' % video_id url = 'http://www.dcndigital.ae/#/media/%s' % video_id
ie_key = 'DCNVideo' ie_key = 'DCNVideo'
else: else:
ie_key = 'DCNShow' ie_key = 'DCNSeason'
if season_id and int(season_id) > 0: if season_id and int(season_id) > 0:
url = 'http://www.dcndigital.ae/#/program/season/%s' % season_id url = smuggle_url('http://www.dcndigital.ae/#/program/season/%s' % season_id, {'show_id': show_id})
else: else:
url = 'http://www.dcndigital.ae/#/program/%s' % show_id url = 'http://www.dcndigital.ae/#/program/%s' % show_id
return { return {
@ -38,6 +40,7 @@ class DCNGeneralIE(InfoExtractor):
class DCNVideoIE(InfoExtractor): class DCNVideoIE(InfoExtractor):
IE_NAME = 'dcn:video'
_VALID_URL = r'https?://(?:www\.)?dcndigital\.ae/(?:#/)?(?:video/[^/]+|media)/(?P<id>\d+)' _VALID_URL = r'https?://(?:www\.)?dcndigital\.ae/(?:#/)?(?:video/[^/]+|media)/(?P<id>\d+)'
_TEST = { _TEST = {
'url': 'http://www.dcndigital.ae/#/video/%D8%B1%D8%AD%D9%84%D8%A9-%D8%A7%D9%84%D8%B9%D9%85%D8%B1-%D8%A7%D9%84%D8%AD%D9%84%D9%82%D8%A9-1/17375', 'url': 'http://www.dcndigital.ae/#/video/%D8%B1%D8%AD%D9%84%D8%A9-%D8%A7%D9%84%D8%B9%D9%85%D8%B1-%D8%A7%D9%84%D8%AD%D9%84%D9%82%D8%A9-1/17375',
@ -109,13 +112,14 @@ class DCNVideoIE(InfoExtractor):
} }
class DCNShowIE(InfoExtractor): class DCNSeasonIE(InfoExtractor):
IE_NAME = 'dcn:season'
_VALID_URL = r'https?://(?:www\.)?dcndigital\.ae/(?:#/)?program/(?:(?P<show_id>\d+)|season/(?P<season_id>\d+))' _VALID_URL = r'https?://(?:www\.)?dcndigital\.ae/(?:#/)?program/(?:(?P<show_id>\d+)|season/(?P<season_id>\d+))'
_TEST = { _TEST = {
'url': 'http://dcndigital.ae/#/program/205024/%D9%85%D8%AD%D8%A7%D8%B6%D8%B1%D8%A7%D8%AA-%D8%A7%D9%84%D8%B4%D9%8A%D8%AE-%D8%A7%D9%84%D8%B4%D8%B9%D8%B1%D8%A7%D9%88%D9%8A', 'url': 'http://dcndigital.ae/#/program/205024/%D9%85%D8%AD%D8%A7%D8%B6%D8%B1%D8%A7%D8%AA-%D8%A7%D9%84%D8%B4%D9%8A%D8%AE-%D8%A7%D9%84%D8%B4%D8%B9%D8%B1%D8%A7%D9%88%D9%8A',
'info_dict': 'info_dict':
{ {
'id': '205024', 'id': '7910',
'title': 'محاضرات الشيخ الشعراوي', 'title': 'محاضرات الشيخ الشعراوي',
'description': '', 'description': '',
}, },
@ -123,15 +127,18 @@ class DCNShowIE(InfoExtractor):
} }
def _real_extract(self, url): def _real_extract(self, url):
url, smuggled_data = unsmuggle_url(url, {})
show_id, season_id = re.match(self._VALID_URL, url).groups() show_id, season_id = re.match(self._VALID_URL, url).groups()
data = {} data = {}
if season_id: if season_id:
request = compat_urllib_request.Request(
'http://admin.mangomolo.com/analytics/index.php/plus/season_info?id=%s' % season_id,
headers={'Origin': 'http://www.dcndigital.ae'})
season = self._download_json(request, season_id)
show_id = season['id']
data['season'] = season_id data['season'] = season_id
show_id = smuggled_data.get('show_id')
if show_id is None:
request = compat_urllib_request.Request(
'http://admin.mangomolo.com/analytics/index.php/plus/season_info?id=%s' % season_id,
headers={'Origin': 'http://www.dcndigital.ae'})
season = self._download_json(request, season_id)
show_id = season['id']
data['show_id'] = show_id data['show_id'] = show_id
request = compat_urllib_request.Request( request = compat_urllib_request.Request(
'http://admin.mangomolo.com/analytics/index.php/plus/show', 'http://admin.mangomolo.com/analytics/index.php/plus/show',
@ -141,6 +148,7 @@ class DCNShowIE(InfoExtractor):
'Content-Type': 'application/x-www-form-urlencoded' 'Content-Type': 'application/x-www-form-urlencoded'
}) })
show = self._download_json(request, show_id) show = self._download_json(request, show_id)
season_id = season_id or show['default_season']
title = show['cat'].get('title_en') or show['cat']['title_ar'] title = show['cat'].get('title_en') or show['cat']['title_ar']
description = show['cat'].get('description_en') or show['cat'].get('description_ar') description = show['cat'].get('description_en') or show['cat'].get('description_ar')
entries = [] entries = []
@ -151,7 +159,7 @@ class DCNShowIE(InfoExtractor):
'ie_key': 'DCNVideo', 'ie_key': 'DCNVideo',
}) })
return { return {
'id': show_id, 'id': season_id,
'title': title, 'title': title,
'description': description, 'description': description,
'entries': entries, 'entries': entries,