/
default.py
147 lines (112 loc) · 5.34 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
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import util, urllib2
import xbmc
def playVideo(params):
link = WEB_PAGE_BASE + params['link']
response = urllib2.urlopen(link)
if response and response.getcode() == 200:
content = response.read()
videoLink = util.extract(content, "source src='", "'")
util.playMedia(params['title'], params['image'], videoLink, 'Video')
else:
util.showError(ADDON_ID, 'Could not open URL %s to get video information' % (params['video']))
'''def buildMenu():
util.addMenuItem('LiveTV', util.makeLinkMenu('/livetv/'), util.makeThumbnail('tv-live.png'), util.makeThumbnail('tv-live.png'), True)
util.logAddon('debug1')
util.addMenuItem('ShowTV', util.makeLinkMenu('/the-loai/tvshow'), util.makeThumbnail('tv-show.png'), util.makeThumbnail('tv-show.png'), True)
util.logAddon('debug2')
util.addMenuItem('Sport Video', util.makeLinkMenu('/the-loai/sport'), util.makeThumbnail('tv-sport.png'), util.makeThumbnail('tv-sport.png'), True)
util.logAddon('debug3')
util.addMenuItem('Music Video', util.makeLinkMenu('/the-loai/music'), util.makeThumbnail('tv-music.png'), util.makeThumbnail('tv-music.png'), True)
util.logAddon('debug4')
util.addMenuItem('Collection Video',util.makeLinkMenu('/the-loai/general'), util.makeThumbnail('tv-video.png'), util.makeThumbnail('tv-video.png'), True)
util.logAddon('debug5')
util.endListing()
util.logAddon('debug6')'''
def buildMenu():
url = 'http://play.fpt.vn/'
response = urllib2.urlopen(url)
if response and response.getcode() == 200:
content = response.read()
makeLinks = util.extract(content, '"nav navbar-nav menu"', '</ul>')
links = util.extractAll(makeLinks,'<li >','a>')
for link in links:
params = {'key':'makeMenu'}
params['link'] = util.extract(link,'href="','\"')
params['title'] = util.extract(link,'\">','</')
link = util.makeLink(params)
util.addMenuItem(params['title'], link, 'DefaultVideo.png', 'DefaultVideo.png', True)
util.endListing()
xbmc.executebuiltin("Container.SetViewMode(500)")
else:
util.showError(ADDON_ID, 'Could not open URL CATEGORIES %s to create menu' %(url))
def buildCategories(inputParams):
url = WEB_PAGE_BASE + inputParams['link']
response = urllib2.urlopen(url)
if response and response.getcode() == 200:
content = response.read()
links = util.extractAll(content, 'idscroll="', '<ul class="thumn">')
for link in links:
if 'tvshow' in inputParams['link']:
params = {'key':'makeCategoriesTV'}
else:
params = {'key':'makeCategories'}
params['link'] = util.extract(link,'href="','\"')
params['title'] = util.extract(link,'/1">','</a>')
link = util.makeLink(params)
util.addMenuItem(params['title'], link, 'DefaultVideo.png', 'DefaultVideo.png', True)
util.endListing()
xbmc.executebuiltin("Container.SetViewMode(500)")
else:
util.showError(ADDON_ID, 'Could not open URL CATEGORIES %s to create menu' %(url))
def buildShow(inputParams):
url = WEB_PAGE_BASE + inputParams['link']
response = urllib2.urlopen(url)
if response and response.getcode() == 200:
content = response.read()
links = util.extractAll(content, '<div class="col">', '</span>')
for link in links:
if 'makeCategoriesTV' in inputParams['key']:
params = {'key':'makeShows'}
else:
params = {'key':'makePlay'}
util.logAddon('MakePlay')
params['title'] = util.extract(link,'data-original-title="','\"')
params['link'] = util.extract(link,'href="','\"')
params['image'] = util.extract(link,'img src="','"')
link = util.makeLink(params)
util.addMenuItem(params['title'], link, params['image'], params['image'], True)
util.endListing()
xbmc.executebuiltin("Container.SetViewMode(500)")
else:
util.showError(ADDON_ID, 'Could not open URL SHOW %s to create menu' %(url))
def buildPlay(inputParams):
url = WEB_PAGE_BASE + inputParams['link']
response = urllib2.urlopen(url)
if response and response.getcode() == 200:
content = response.read()
links = util.extract(content, 'a href="#">«', 'href="#">»')
extractLinks = util.extractAll(links,'a href="','"')
for link in extractLinks:
params = {'key':'makePlaymakePlay'}
params['title'] = util.extractTitle(link)
params['link'] = link
params['image'] = inputParams['image']
link = util.makeLink(params)
util.addMenuItem(params['title'], link, params['image'], params['image'], False)
util.endListing()
xbmc.executebuiltin("Container.SetViewMode(500)")
else:
util.showError(ADDON_ID, 'Could not open URL PLAY %s to create menu' %(url))
WEB_PAGE_BASE = 'http://play.fpt.vn'
ADDON_ID = 'plugin.video.bit.play'
parameters = util.parseParameters()
if 'makePlay' in parameters:
playVideo(parameters)
elif 'makeShows' in parameters:
buildPlay(parameters)
elif 'makeCategories' in parameters and 'makeCategoriesTV' in parameters:
buildShow(parameters)
elif 'makeMenu' in parameters:
buildCategories(parameters)
else:
buildMenu()