This commit is contained in:
Bezleputh 2014-08-26 15:51:25 +02:00
commit 30f814ec65
2 changed files with 61 additions and 5 deletions

View file

@ -122,6 +122,7 @@ class ArteBackend(BaseBackend, CapVideo, CapCollection):
if collection.path_level == 0:
yield Collection([u'arte-latest'], u'Latest Arte videos')
yield Collection([u'arte-live'], u'Arte Web Live videos')
yield Collection([u'arte-program'], u'Arte Programs')
if collection.path_level == 1:
if collection.split_path == [u'arte-latest']:
for video in self.browser.latest_videos():
@ -129,18 +130,40 @@ class ArteBackend(BaseBackend, CapVideo, CapCollection):
if collection.split_path == [u'arte-live']:
for categorie in self.browser.get_arte_live_categories():
yield categorie
if collection.split_path == [u'arte-program']:
for item in self.browser.get_arte_programs():
lang = self.TRANSLATION[self.config['lang'].get()]
if lang == 'F':
title = 'titleFR'
elif lang == 'D':
title = 'titleDE'
else:
title = 'name'
name = item['clusterId']
if title in item.keys():
name = item[title]
yield Collection([u'arte-program', item['clusterId']], u'%s' % name)
if collection.path_level == 2:
if collection.split_path[0] == u'arte-live':
for video in self.browser.live_videos(collection.basename):
yield video
if collection.split_path[0] == u'arte-program':
for video in self.browser.program_videos(collection.split_path[1]):
yield video
def validate_collection(self, objs, collection):
if collection.path_level == 0:
return
if BaseVideo in objs and (collection.split_path == [u'arte-latest'] or collection.split_path == [u'arte-live']):
if BaseVideo in objs and (collection.split_path == [u'arte-latest'] or
collection.split_path == [u'arte-live'] or
collection.split_path == [u'arte-program']):
return
if BaseVideo in objs and collection.path_level == 2 and collection.split_path[0] == u'arte-live':
if BaseVideo in objs and collection.path_level == 2 and (collection.split_path[0] == u'arte-live' or
collection.split_path[0] == u'arte-program'):
return
raise CollectionNotFound(collection.split_path)
OBJECTS = {ArteVideo: fill_video, ArteLiveVideo: fill_video }
OBJECTS = {ArteVideo: fill_video, ArteLiveVideo: fill_video}

View file

@ -144,8 +144,9 @@ class ArteBrowser(BaseBrowser):
response = self.openurl(url)
result = simplejson.loads(response.read(), self.ENCODING)
video = self.create_video(result['abstractProgram']['VDO'])
return self.get_video(video.id, video)
if 'VDO' in result['abstractProgram'].keys():
video = self.create_video(result['abstractProgram']['VDO'])
return self.get_video(video.id, video)
def search_videos(self, pattern):
class_name = 'videos/plus7'
@ -211,6 +212,38 @@ class ArteBrowser(BaseBrowser):
return url
def get_arte_programs(self):
class_name = 'epg'
method_name = 'clusters'
url = self.API_URL \
+ '/' + class_name \
+ '/' + method_name \
+ '/' + self.lang \
+ '/0/ALL.json'
response = self.openurl(url)
result = simplejson.loads(response.read(), self.ENCODING)
return result['configClusterList']
def program_videos(self, program):
class_name = 'epg'
method_name = 'cluster'
url = self.API_URL \
+ '/' + class_name \
+ '/' + method_name \
+ '/' + self.lang \
+ '/' + program \
+ '.json'
response = self.openurl(url)
result = simplejson.loads(response.read(), self.ENCODING)
for item in result['clusterWrapper']['broadcasts']:
if 'VDS' in item.keys() and len(item['VDS']) > 0:
video = self.get_video_from_program_id(item['programId'])
if video:
yield video
def latest_videos(self):
class_name = 'videos'
method_name = 'plus7'