-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdmnapiinst.py
executable file
·336 lines (311 loc) · 10.5 KB
/
dmnapiinst.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
#!/usr/bin/python
# DMnapi for Dreambox-Enigma2
# Version: 23.03.04
# Coded by areq (c) 2010-2015
# Support: http://dvhk.pl/
# http://areq.eu.org/
import sys, re, os.path
DM_patch = { "FileBrowser": [[[
"""
self.SetGB(_("Play"))
self.SetRB(_("Information"))
""",
"""
self.SetGB(_("Play"))
self.SetRB(_("Get Subtitle")) #dmnapi
"""],[
"""
elif sel[B_FILTER] & (FILTER_PICS | FILTER_MOVIES | FILTER_SOUND):
from searchMediaInfo import BrowserFileInfos
self.session.open(BrowserFileInfos, sel)
""",
"""
elif sel[B_FILTER] & (FILTER_PICS | FILTER_SOUND):
from searchMediaInfo import BrowserFileInfos
self.session.open(BrowserFileInfos, sel)
elif sel[B_FILTER] & FILTER_MOVIES:
from Plugins.Extensions.DMnapi.DMnapi import DMnapi
self.session.openWithCallback(self.__movie_Callback, DMnapi, sel[B_FULL])
"""]],[[ # druga werja
"""
elif sel[3][B_FILTER] & FILTER_MOVIES:
self.SetGB(_("Play"))
if pathExists(sel[3][B_CFILE] + ".txt"):
self.SetRB(_("Information"))
""",
"""
elif sel[3][B_FILTER] & FILTER_MOVIES:
self.SetGB(_("Play"))
self.SetRB(_("Get Subtitle")) #dmnapi
"""],[
"""
elif sel[B_FILTER] & FILTER_MOVIES:
from confFileBrowser import BrowserFileInfos
self.session.open(BrowserFileInfos, sel)
""",
"""
elif sel[B_FILTER] & FILTER_MOVIES:
from Plugins.Extensions.DMnapi.DMnapi import DMnapi
self.session.openWithCallback(self.__movie_Callback, DMnapi, sel[B_FULL])
"""]],[[ # trzecia werja
"""
self.SetGB(_("Show"))
elif sel[3][B_FILTER] & FILTER_MOVIES:
self.SetGB(_("Play"))
elif sel[3][B_FILTER] & FILTER_TS:
self.SetGB(_("Play"))
self.SetRB(_("Information"))
""",
"""
self.SetGB(_("Show"))
elif sel[3][B_FILTER] & FILTER_MOVIES:
self.SetGB(_("Play"))
self.SetRB(_("Get Subtitle")) #dmnapi
elif sel[3][B_FILTER] & FILTER_TS:
self.SetGB(_("Play"))
self.SetRB(_("Information"))
"""],[
"""
from Plugins.Extensions.PicturePlayer.plugin import Pic_Exif
self.session.open(Pic_Exif, picload.getInfo(sel[B_FULL]))
del picload
except:
pass
#----------------------------Gelb-Favo
def KeyBlue(self):
if self.filter == FILTER_NONE:
""",
"""
from Plugins.Extensions.PicturePlayer.plugin import Pic_Exif
self.session.open(Pic_Exif, picload.getInfo(sel[B_FULL]))
del picload
elif sel[B_FILTER] & FILTER_MOVIES: #dmnapi
from Plugins.Extensions.DMnapi.DMnapi import DMnapi #dmnapi
self.session.openWithCallback(self.__napiCallback, DMnapi, sel[B_FULL]) #dmnapi
except:
pass
def __napiCallback(self, val = False): #dmnapi
self.__fillListe() #dmnapi
#----------------------------Gelb-Favo
def KeyBlue(self):
if self.filter == FILTER_NONE:
"""]], [[ # czwarta werja od Gemini3.2 v0.73
"""
menu = []
if not val[3][B_FILTER] & FILTER_GOUP and self.filter == FILTER_NONE:
""",
"""
menu = []
if val[3][B_FILTER] & FILTER_MOVIES:
menu.append((_("Get Subtitle"), "dmnapi", val[3]))
if not val[3][B_FILTER] & FILTER_GOUP and self.filter == FILTER_NONE:
"""],[
"""
elif what[1] == "delete":
""",
"""
elif what[1] == "dmnapi":
from Plugins.Extensions.DMnapi.DMnapi import DMnapi
self.session.openWithCallback(self.__callbackMoviePlayer, DMnapi, path[B_FULL])
elif what[1] == "delete":
"""]]],
"BPBrowser": [[[
"""
self["key_green"].setText(_("Show"))
elif sel[3][B_FILTER] & Cbputils.FILTER_MOVIES:
self["key_green"].setText(_("Play"))
elif sel[3][B_FILTER] & Cbputils.FILTER_TS:
self["key_green"].setText(_("Play"))
self["key_red"].setText(_("Info"))
""",
"""
self["key_green"].setText(_("Show"))
elif sel[3][B_FILTER] & Cbputils.FILTER_MOVIES:
self["key_green"].setText(_("Play"))
self["key_red"].setText(_("Get Subtitle")) #dmnapi
elif sel[3][B_FILTER] & Cbputils.FILTER_TS:
self["key_green"].setText(_("Play"))
self["key_red"].setText(_("Info"))
"""],[
"""
from Plugins.Extensions.PicturePlayer.plugin import Pic_Exif
self.session.open(Pic_Exif, picload.getInfo(sel[B_FULL]))
del picload
#----------------------------Gelb-Favo
def KeyYellow(self):
""",
"""
from Plugins.Extensions.PicturePlayer.plugin import Pic_Exif
self.session.open(Pic_Exif, picload.getInfo(sel[B_FULL]))
del picload
elif sel[B_FILTER] & Cbputils.FILTER_MOVIES: #dmnapi
from Plugins.Extensions.DMnapi.DMnapi import DMnapi #dmnapi
self.session.openWithCallback(self.__napiCallback, DMnapi, sel[B_FULL]) #dmnapi
def __napiCallback(self, val = False): #dmnapi
self.fill_liste() #dmnapi
#----------------------------Gelb-Favo
def KeyYellow(self):
"""]]],
"plugin": [[[
"""
"showMovies": self.CloseAndPlay
}, -1)
self.onLayoutFinish.append(self.byLayoutEnd)
def ok(self):
global DVDPlayerAviable
""",
"""
"showMovies": self.CloseAndPlay,
"dmnapi": self.DMnapi #dmnapi
}, -1)
self.onLayoutFinish.append(self.byLayoutEnd)
def DMnapi(self): #dmnapi
if not self["filelist"].canDescent(): #dmnapi
curSelFile = self["filelist"].getCurrentDirectory() + self["filelist"].getFilename() #dmnapi
from Plugins.Extensions.DMnapi.DMnapi import DMnapi #dmnapi
self.session.openWithCallback(self.dmnapiCallback, DMnapi, curSelFile) #dmnapi
def dmnapiCallback(self, answer=False): #dmnapi
self["filelist"].refresh() #dmnapi
def ok(self):
global DVDPlayerAviable
"""]
]],
"MovieSelection": [[[
"""
menu = [(_("delete : %s") % name, self.delete)]
""",
"""
if self.service.getPath()[-3:].lower() in ['mkv', 'mp4', 'avi']:
menu = [(_("DMnapi: pobierz napisy do filmu"), self.dmnapi), (_("delete : %s") % name, self.delete)]
else:
menu = [(_("delete : %s") % name, self.delete)]
"""],[
"""
def delete(self):
""",
"""
def dmnapi(self):
print "CB dmnapi"
dm_file = self.service.getPath()
print dm_file
from Plugins.Extensions.DMnapi.DMnapi import DMnapi
self.session.openWithCallback(self.close, DMnapi, dm_file)
def delete(self):
"""]]],
"kolejny": [[[
"""co""",
"""nco"""],[
"""co""",
"""naco"""]]]
}
def saveDEkeymap():
q="""<keymap>
<map context="ColorActions">
<key id="KEY_TEXT" mapto="dmnapi" flags="m" />
</map>
</keymap>
"""
open("/usr/lib/enigma2/python/Plugins/Extensions/DreamExplorer/keymap.xml", 'w').write(q)
def dmnapi_chceck():
if FB.find('#dmnapi') > 0:
return "Instaled"
else:
return "NOT Instaled"
def patch(fn, FB):
fn = fn.split('/')[-1].split('.')[0]
for sub in DM_patch.get(fn,[]):
for s,r in sub:
if FB.find(s) < 0:
break
else:
for s,r in sub:
FB = FB.replace(s, r)
return FB
def DreamExplorer():
de = '/usr/lib/enigma2/python/Plugins/Extensions/DreamExplorer/'
insDE = True
for i in ['plugin.pyo', 'plugin.pyc', 'plugin.py']:
f = de + i
if os.path.isfile(f):
if open(f).read().find('dmnapi20150328') > 0:
insDE = False
else:
if f[-1] != 'y':
os.remove(f)
if insDE:
print 'DMnapi, brak DreamExplorer, instaluje...'
try:
import zipfile, urllib2
from StringIO import StringIO
os.system('rm -fr /usr/lib/enigma2/python/Plugins/Extensions/DreamExplorer/')
z = zipfile.ZipFile(StringIO(urllib2.urlopen('http://areq.eu.org/dmnapi/DreamExplorer.zip').read() ))
z.extractall('/usr/lib/enigma2/python/Plugins/Extensions/')
print "DMnapi, DreamExplorer zainstalowany"
except:
print "DMnapi, brak DreamExplorer, problem"
import traceback
traceback.print_exc()
if __name__ == "__main__":
print "DMnapi installer by areq.\n"
for d, f, v, reg in [ \
('Gemini3 FileBrowser', '/usr/lib/enigma2/python/Plugins/Bp/geminimain/FileBrowser.py','/usr/lib/enigma2/python/Plugins/Bp/geminimain/gVersion.py', "gVersion = '(.*)'"),\
('Gemini2 BPBrowser','/usr/lib/enigma2/python/Bp/BPBrowser.py','/etc/issue.net', "OpenDreambox (.*) %h"),\
('VU+ VTI Movie Selection','/usr/lib/enigma2/python/Screens/MovieSelection.py','/etc/vtiversion.info', " v.(.*)"),\
('DreamExplorer','/usr/lib/enigma2/python/Plugins/Extensions/DreamExplorer/plugin.py','/usr/lib/enigma2/python/Plugins/Extensions/DreamExplorer/plugin.py', "Version: (.*)") ]:
if os.path.exists(f) and os.path.exists(v):
q = open(v).read()
try:
ver = re.search(reg , q).group(1)
except:
ver = 'unknown'
print d,"\n\tVersion:", ver,
FB = open(f).read()
if FB.find("Plugins.Extensions.DMnapi.plugin") > 0:
FBp = FB.replace("Plugins.Extensions.DMnapi.plugin", "Plugins.Extensions.DMnapi.DMnapi")
try:
os.rename(f, f + '.backup')
open(f, 'w').write(FBp)
print " DMnapi reenabled - fixed old code."
except:
print " but problem with writting ;("
elif FB.find("DMnapi") > 0:
print "- skipped - DMnapi support already installed."
else:
FBp = patch(f, FB)
if FBp != FB:
print "- patched successfully -",
try:
os.rename(f, f + '.backup')
open(f, 'w').write(FBp)
print " DMnapi enabled."
except:
print " but problem with writting ;("
if d == 'DreamExplorer':
saveDEkeymap()
print "\t keymap.xml saved."
else:
print d, "\n\tnot found."
print
try:
for f in ("/usr/lib/enigma2/python/Plugins/Extensions/DMnapi/dmnapi", "/usr/lib/enigma2/python/Plugins/Extensions/DMnapi/dmnapiinst.py"):
if not os.access(f, os.X_OK):
print "DMNapi: fix permission"
os.chmod(f, 0555)
except:
print "DMnapi Error: chmod problem"
pass
if not os.path.exists('/var/grun/grcstype'):
DreamExplorer()
else:
print "GOS detected. Please install enigma2-plugin-dreamexplorer package"
# porzadki po starej wersji
for f in ['N24.py', 'dmnapi.py']:
for e in ['', 'o', 'c']:
d = "/usr/lib/enigma2/python/Plugins/Extensions/DMnapi/" + f + e
if os.path.exists(d):
print "Kasuje:", f
try:
os.remove(d)
except:
pass
print "Finished."