[0aeb5a]: plugin.video.raiclick / raiclicklib.py  Maximize  Restore  History

Download this file

86 lines (68 with data), 2.8 kB

 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
from string import *
import urllib, re
'''
RaiClick for XBMC 1.1.1
Copyright (C) 2005-2011 Angelo Conforti <angeloxx@angeloxx.it>
http://www.angeloxx.it
Lo script e' un semplice browser del sito rai.tv, tutti i diritti
sono di proprieta' della RAI
'''
urlBase = "http://www.rai.tv/%s"
urlBaseThemes = "http://www.rai.tv/dl/RaiTV/cerca_tematiche.html?%s"
urlListItems = "http://www.rai.tv/dl/RaiTV/programmi/liste/%s-V-%s.html"
'''
There are three level of contents:
Themes (Musica,Spettacoli) -> listThemes\urlBaseThemes
ThemeItems (Sanremo,XFactor) -> listThemeItems\urlBaseThemes?Theme
ListItems (Extra,Sintesi Giornalierei) -> listSubItems\urlBase + ThemeItem
VideoList (Videos) -> listItems\urlListItems + SubItem + ? + ?
'''
''' Return a list with <description> (and GET argument) of each theme '''
def listThemes():
items = []
data = urllib.urlopen(urlBaseThemes % ("Nope")).read()
result = re.findall("<a title=\".*?\" href=\"\?(.*?)\">.*</a>", data)
for item in result:
items.append(item)
return items
''' Return a list with <url> and <description> of each section '''
def listThemeItems(theme):
items = []
print("listThemeItems: Theme %s" % (theme))
data = urllib.urlopen(urlBaseThemes % theme).read()
''' Remove newline char and simplify the regexp'''
data = data.replace("\n","")
result = re.findall("<a href=\"(\/dl.*?)\">.*?<div class=\"internal\">(.*?)</div>", data)
for item in result:
items.append(item)
return items
''' Return a list with <list-url> and <description> of each sub-section '''
def listSubItems(startURL):
items = []
startURL = startURL.replace(".html","-page.html?LOAD_CONTENTS")
print("listSubItems: startURL %s" % (startURL))
data = urllib.urlopen(urlBase % startURL).read()
result = re.findall("<a target=\"_top\" href=\"#\" id=\"(ContentSet.*?)\">(.*?)</a>", data)
for item in result:
items.append(item)
return items
''' Return a list with <url> and <description> of each video '''
def listItems(startURL):
items = []
print("listItems: startURL %s" % (startURL))
page = 0
while(True):
data = urllib.urlopen(urlListItems % (startURL,page)).read()
if data.find("404 Not Found") > 0:
print("listItems: startURL %s stopped at page %s" % (startURL,page))
return items
data = data.replace("\n","")
result = re.findall("<a .*?href=\"(/dl/RaiTV/programmi/media/ContentItem.*?)\".*?><h2>(.*?)</h2>", data)
for item in result:
items.append(item)
page += 1
def openMovie(url):
print("openMovie: URL " + url)
data = urllib.urlopen(url).read()
result = re.findall("videoURL = \"(.*?)\"", data, re.DOTALL)
return result[0]