forked from Lunatixz/script.pseudotv.live
-
Notifications
You must be signed in to change notification settings - Fork 0
/
videowindow.py
249 lines (205 loc) · 9.43 KB
/
videowindow.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
# Copyright (C) 2013 Lunatixz
#
#
# This file is part of PseudoTV Live.
#
# PseudoTV is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# PseudoTV is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with PseudoTV Live. If not, see <http://www.gnu.org/licenses/>.
import os, sys, re, fileinput
import xbmc, xbmcgui, xbmcaddon, xbmcvfs
from resources.lib.Globals import *
def replaceAll(file,searchExp,replaceExp):
xbmc.log('script.pseudotv.live-videowindow: replaceAll')
for line in fileinput.input(file, inplace=1):
if searchExp in line:
line = line.replace(searchExp,replaceExp)
sys.stdout.write(line)
def videowindow():
xbmc.log('script.pseudotv.live-videowindow: videowindow')
REAL_SETTINGS.setSetting("videowindow","false")
PTVL_SKIN_SELECT_FLE = xbmc.translatePath(os.path.join(PTVL_SKIN_SELECT, 'script.pseudotv.live.EPG.xml'))
xbmc.log('script.pseudotv.live-VideoWindow: Patcher Started')
xbmc.log('script.pseudotv.live-VideoWindow: ADDON_PATH = ' + ADDON_PATH)
xbmc.log('script.pseudotv.live-VideoWindow: PTVL_SKIN_SELECT = ' + PTVL_SKIN_SELECT)
xbmc.log('script.pseudotv.live-VideoWindow: PTVL_SKIN_SELECT_FLE = ' + PTVL_SKIN_SELECT_FLE)
xbmc.log('script.pseudotv.live-VideoWindow: XBMC_SKIN_LOC = ' + XBMC_SKIN_LOC)
a = '<!-- PATCH START -->'
b = '<!-- PATCH START --> <!--'
c = '<!-- PATCH END -->'
d = '--> <!-- PATCH END -->'
v = ' '
w = '<visible>Window.IsActive(fullscreenvideo) + !Window.IsActive(script.pseudotv.TVOverlay.xml) + !Window.IsActive(script.pseudotv.live.TVOverlay.xml)</visible>'
y = '</defaultcontrol>'
z = '</defaultcontrol>\n <visible>Window.IsActive(fullscreenvideo) + !Window.IsActive(script.pseudotv.TVOverlay.xml) + !Window.IsActive(script.pseudotv.live.TVOverlay.xml)</visible>'
Installed = False
Patched = False
MSG = ''
Path = (os.path.join(ADDON_PATH, 'resources', 'skins', 'Default', '720p')) #Path to Default PTVL skin, location of mod file.
fle = 'custom_script.pseudotv.live_9506.xml' #mod file, copy to xbmc skin folder
VWPath = (os.path.join(XBMC_SKIN_LOC, fle))
flePath = (os.path.join(Path, fle))
fle1 = 'dialogseekbar.xml' #xbmc skin file, needs patch
DSPath = xbmc.translatePath(os.path.join(XBMC_SKIN_LOC, fle1))
Error = False
Uninstall = False
UnPatch = False
Patch = False
Install = False
# Delete Old VideoWindow Patch
if xbmcvfs.exists(VWPath):
if dlg.yesno("PseudoTV Live", "VideoWindow Patch Found!\nRemove Patch?"):
try:
xbmcvfs.delete(VWPath)
Uninstall = True
xbmc.log('script.pseudotv.live-VideoWindow: Uninstall')
except Exception,e:
xbmc.log('script.pseudotv.live-VideoWindow: Delete Patch Failed' + str(e))
Error = True
pass
try:
#unpatch videowindow
f = open(PTVL_SKIN_SELECT_FLE, "r")
linesLST = f.readlines()
f.close()
for i in range(len(set(linesLST))):
lines = linesLST[i]
if a in lines:
replaceAll(PTVL_SKIN_SELECT_FLE,a,b)
elif c in lines:
replaceAll(PTVL_SKIN_SELECT_FLE,c,d)
#unpatch seek
f = open(DSPath, "r")
lineLST = f.readlines()
f.close()
for i in range(len(set(lineLST))):
line = lineLST[i]
if w in line:
replaceAll(DSPath,w,v)
UnPatch = True
xbmc.log('script.pseudotv.live-VideoWindow: UnPatch')
except Exception,e:
xbmc.log('script.pseudotv.live-VideoWindow: Remove Patch Failed' + str(e))
Error = True
pass
else:
if dlg.yesno("PseudoTV Live", "VideoWindow Patch Found!\n Reapply Patch?"):
Patch = True
else:
MSG = "VideoWindow Unchanged"
else:
Install = True
# Copy VideoWindow Patch
if Install:
try:
xbmcvfs.copy(flePath, VWPath)
if xbmcvfs.exists(VWPath):
Installed = True
Patch = True
xbmc.log('script.pseudotv.live-VideoWindow: Installed')
except Exception,e:
xbmc.log('script.pseudotv.live-VideoWindow: Intall Failed' + str(e))
Error = True
pass
if Patch:
try:
f = open(PTVL_SKIN_SELECT_FLE, "r")
linesLST = f.readlines()
f.close()
for i in range(len(set(linesLST))):
lines = linesLST[i]
if b in lines:
replaceAll(PTVL_SKIN_SELECT_FLE,b,a)
elif d in lines:
replaceAll(PTVL_SKIN_SELECT_FLE,d,c)
xbmc.log('script.pseudotv.live-VideoWindow: script.pseudotv.live.EPG.xml Patched')
try:
f = open(DSPath, "r")
lineLST = f.readlines()
f.close()
for i in range(len(set(lineLST))):
line = lineLST[i]
if y in line:
replaceAll(DSPath,y,z)
xbmc.log('script.pseudotv.live-VideoWindow: DialogSeekBar Patched')
except:
pass
Patched = True
except Exception,e:
xbmc.log('script.pseudotv.live-VideoWindow: script.pseudotv.live.EPG.xml Patch Failed' + str(e))
Error = True
pass
if (Installed and Patched) or Patched:
MSG = "VideoWindow Patched!"
REAL_SETTINGS.setSetting("videowindow","true")
xbmc.executebuiltin("ReloadSkin()")
if Uninstall or UnPatch:
MSG = "VideoWindow Patch Removed!"
REAL_SETTINGS.setSetting("videowindow","false")
xbmc.executebuiltin("ReloadSkin()")
if Error:
MSG = "VideoWindow Patch Error!"
xbmc.executebuiltin("Notification( %s, %s, %d, %s)" % ("PseudoTV Live", MSG, 1000, THUMB) )
REAL_SETTINGS.openSettings()
def autopatch():
xbmc.log('script.pseudotv.live-videowindow: autopatch')
REAL_SETTINGS.setSetting("videowindow","false")
PTVL_SKIN_SELECT_FLE = xbmc.translatePath(os.path.join(PTVL_SKIN_SELECT, 'script.pseudotv.live.EPG.xml'))
a = '<!-- PATCH START -->'
b = '<!-- PATCH START --> <!--'
c = '<!-- PATCH END -->'
d = '--> <!-- PATCH END -->'
v = ' '
w = ' <visible>Window.IsActive(fullscreenvideo) + !Window.IsActive(script.pseudotv.TVOverlay.xml) + !Window.IsActive(script.pseudotv.live.TVOverlay.xml)</visible>'
y = '</defaultcontrol>'
z = '</defaultcontrol>\n <visible>Window.IsActive(fullscreenvideo) + !Window.IsActive(script.pseudotv.TVOverlay.xml) + !Window.IsActive(script.pseudotv.live.TVOverlay.xml)</visible>'
MSG = ''
fle = 'custom_script.pseudotv.live_9506.xml' #mod file, copy to xbmc skin folder
VWPath = (os.path.join(XBMC_SKIN_LOC, fle))
flePath = (os.path.join(Path, fle))
fle1 = 'dialogseekbar.xml' #xbmc skin file, needs patch
DSPath = xbmc.translatePath(os.path.join(XBMC_SKIN_LOC, fle1))
if xbmcvfs.exists(VWPath):
try:
#videowindow
f = open(PTVL_SKIN_SELECT_FLE, "r")
linesLST = f.readlines()
f.close()
for i in range(len(set(linesLST))):
lines = linesLST[i]
if b in lines:
replaceAll(PTVL_SKIN_SELECT_FLE,b,a)
elif d in lines:
replaceAll(PTVL_SKIN_SELECT_FLE,d,c)
xbmc.log('script.pseudotv.live-VideoWindow: autopatch script.pseudotv.live.EPG.xml Patched')
MSG = "VideoWindow Patched"
#seek
f = open(DSPath, "r")
lineLST = f.readlines()
f.close()
for i in range(len(set(lineLST))):
line = lineLST[i]
if y in line:
replaceAll(DSPath,y,z)
xbmc.log('script.pseudotv.live-VideoWindow: DialogSeekBar Patched')
REAL_SETTINGS.setSetting("videowindow","true")
except Exception,e:
xbmc.log('script.pseudotv.live-VideoWindow: autopatch script.pseudotv.live.EPG.xml Patch Failed' + str(e))
MSG = "VideoWindow Patch Error!"
pass
xbmc.executebuiltin("Notification( %s, %s, %d, %s)" % ("PseudoTV Live", MSG, 4000, THUMB) )
else:
xbmc.log('script.pseudotv.live-videowindow: autopatch fle not found')
if sys.argv[1] == '-autopatch':
autopatch()
elif sys.argv[1] == '-videowindow':
videowindow()