forked from sarbes/plugin.video.wdrmaus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.py
53 lines (44 loc) · 2.12 KB
/
default.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# -*- coding: utf-8 -*-
import libwdr
import re
import requests
xml = 'http://www.wdrmaus.de/_export/videositemap.php5'
class wdrmaus(libwdr.libwdr):
def __init__(self):
libwdr.libwdr.__init__(self)
self.modes['mausListVideos'] = self.mausListVideos
def libWdrListMain(self):
response = requests.get(xml).text
categories = re.compile('<video:category>(.+?)</video:category>', re.DOTALL).findall(response)
result = {'items': [], 'name': 'root'}
names = []
for cat in categories:
if not cat in names:
result['items'].append(
{'metadata': {'name': cat}, 'params': {'mode': 'mausListVideos', 'cat': cat}, 'type': 'dir'})
names.append(cat)
return result
def mausListVideos(self):
self.params['cat'] = 'Sachgeschichten'
result = {'items': []}
response = requests.get(xml).text
videos = re.compile('<url>(.+?)</url>', re.DOTALL).findall(response)
videolist = {}
for video in videos:
if self.params['cat'] == re.compile('<video:category>(.+?)</video:category>', re.DOTALL).findall(video)[0]:
d = {'metadata': {'art': {}}, 'params': {'mode': 'libWdrPlayJs'}, 'type': 'video'}
name = re.compile('<video:title><!\[CDATA\[(.+?)\]\]></video:title>', re.DOTALL).findall(video)[0].replace(
'![CDATA[', '').replace(']]', '')
d['metadata']['name'] = name
d['metadata']['art']['thumb'] = \
re.compile('<video:thumbnail_loc>(.+?)</video:thumbnail_loc>', re.DOTALL).findall(video)[0].replace(
'<![CDATA[', '').replace(']]>', '')
d['params']['url'] = \
re.compile('<video:player_loc.+?>(.+?)</video:player_loc>', re.DOTALL).findall(video)[0].replace(
'<![CDATA[', '').replace(']]>', '')
videolist[name] = d
for i in sorted(videolist.keys()):
result['items'].append(videolist[i])
return result
o = wdrmaus()
o.action()