[dcn] add show extraction and support for other types of urls

This commit is contained in:
remitamine 2015-09-03 00:29:53 +01:00
parent e8dcfa3d69
commit 9f4921bfa0
2 changed files with 83 additions and 4 deletions

View File

@ -118,7 +118,11 @@
)
from .daum import DaumIE
from .dbtv import DBTVIE
from .dcn import DCNIE
from .dcn import (
DCNGeneralIE,
DCNVideoIE,
DCNShowIE,
)
from .dctp import DctpTvIE
from .deezer import DeezerPlaylistIE
from .dfb import DFBIE

View File

@ -1,6 +1,8 @@
# coding: utf-8
from __future__ import unicode_literals
import re
from .common import InfoExtractor
from ..compat import (
compat_urllib_parse,
@ -12,10 +14,33 @@
)
class DCNIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?dcndigital\.ae/(?:#/)?(?:video/.+|show/\d+/.+?)/(?P<id>\d+)'
class DCNGeneralIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?dcndigital\.ae/(?:#/)?show/(?P<show_id>\d+)/[^/]+(?:/(?P<video_id>\d+)/(?P<season_id>\d+))?'
def _real_extract(self, url):
show_id, video_id, season_id = re.match(self._VALID_URL, url).groups()
url = ''
ie_key = ''
if video_id and int(video_id) > 0:
url = 'http://www.dcndigital.ae/#/media/%s' % video_id
ie_key = 'DCNVideo'
else:
ie_key = 'DCNShow'
if season_id and int(season_id) > 0:
url = 'http://www.dcndigital.ae/#/program/season/%s' % season_id
else:
url = 'http://www.dcndigital.ae/#/program/%s' % show_id
return {
'url': url,
'_type': 'url',
'ie_key': ie_key
}
class DCNVideoIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?dcndigital\.ae/(?:#/)?(?:video/[^/]+|media)/(?P<id>\d+)'
_TEST = {
'url': 'http://www.dcndigital.ae/#/show/199074/%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/6887',
'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',
'info_dict':
{
'id': '17375',
@ -82,3 +107,53 @@ def _real_extract(self, url):
'timestamp': timestamp,
'formats': formats,
}
class DCNShowIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?dcndigital\.ae/(?:#/)?program/(?:(?P<show_id>\d+)|season/(?P<season_id>\d+))'
_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',
'info_dict':
{
'id': '205024',
'title': 'محاضرات الشيخ الشعراوي',
'description': '',
},
'playlist_mincount': 27,
}
def _real_extract(self, url):
show_id, season_id = re.match(self._VALID_URL, url).groups()
data = {}
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['show_id'] = show_id
request = compat_urllib_request.Request(
'http://admin.mangomolo.com/analytics/index.php/plus/show',
compat_urllib_parse.urlencode(data),
{
'Origin': 'http://www.dcndigital.ae',
'Content-Type': 'application/x-www-form-urlencoded'
})
show = self._download_json(request, show_id)
title = show['cat'].get('title_en') or show['cat']['title_ar']
description = show['cat'].get('description_en') or show['cat'].get('description_ar')
entries = []
for video in show['videos']:
entries.append({
'url': 'http://www.dcndigital.ae/#/media/%s' % video['id'],
'_type': 'url',
'ie_key': 'DCNVideo',
})
return {
'id': show_id,
'title': title,
'description': description,
'entries': entries,
'_type': 'playlist',
}