Skip to content

Commit 85bfd81

Browse files
committed
Release mcrep/program.rss-1.4.3: Fix source regeneration
1 parent 6db98b6 commit 85bfd81

4 files changed

Lines changed: 60 additions & 92 deletions

File tree

src/addon.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2-
<addon id="program.rss" name="RSS Editor" version="1.4.2" provider-name="AMSD">
2+
<addon id="program.rss" name="RSS Editor" version="1.4.3" provider-name="AMSD">
33
<requires>
44
<import addon="xbmc.python" version="2.20.0"/>
55
<import addon="module.clue" version="1.4.1"/>

src/default.py

Lines changed: 42 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919

2020

2121
class RssEditorDialog(xbmcgui.WindowXMLDialog):
22+
_TITLE = 5000
23+
_URLIST = 5110
24+
_ADDBTN = 5230
25+
_DELBTN = 5240
26+
_OKBTN = 5210
27+
_CANCEL = 5220
2228

2329
def __init__(self, *args, **kwargs):
2430
self.setNum = 'set1'
@@ -30,29 +36,20 @@ def __init__(self, *args, **kwargs):
3036
def onInit(self):
3137
self.setControls()
3238
self.feedsList = self.parser.feedsList[self.setNum]['feedslist']
33-
if not self.feedsList:
34-
xbmcgui.Dialog().ok(commons.translate(32040) + 'RssFeeds.xml', 'RssFeeds.xml ' + commons.translate(32041), commons.translate(32042), commons.translate(32043))
35-
self.closeDialog()
3639
self.showDialog()
3740

3841

3942
def setControls(self):
40-
# ids that matters
41-
self.__TITLE_LBL = 5000
42-
self.__CH_LIST = 5110
43-
self.__ADD_BTN = 5230
44-
self.__REMOVE_BTN = 5240
45-
self.__OK_BTN = 5210
46-
self.__CANCEL_BTN = 5220
4743
# controls used for data manipulation
48-
self.ListControl = self.getControl(self.__CH_LIST)
49-
self.AddButtonControl = self.getControl(self.__ADD_BTN)
50-
self.RemoveButtonControl = self.getControl(self.__REMOVE_BTN)
51-
self.OkButtonControl = self.getControl(self.__OK_BTN)
52-
self.CancelButtonControl = self.getControl(self.__CANCEL_BTN)
44+
self.ListControl = self.getControl(self._URLIST)
45+
self.AddButtonControl = self.getControl(self._ADDBTN)
46+
self.RemoveButtonControl = self.getControl(self._DELBTN)
47+
self.OkButtonControl = self.getControl(self._OKBTN)
48+
self.CancelButtonControl = self.getControl(self._CANCEL)
49+
5350

5451
def showDialog(self):
55-
self.getControl(self.__TITLE_LBL).setLabel(commons.translate(32000))
52+
self.getControl(self._TITLE).setLabel(commons.translate(32000))
5653
self.updateFeedsList()
5754

5855

@@ -62,7 +59,7 @@ def closeDialog(self):
6259

6360
def onClick(self, controlId):
6461
# edit existing feed
65-
if controlId == self.__CH_LIST:
62+
if controlId == self._URLIST:
6663
position = self.ListControl.getSelectedPosition()
6764
oldUrl = self.feedsList[position]['url']
6865
oldUpdateInterval = self.feedsList[position]['updateinterval']
@@ -71,21 +68,21 @@ def onClick(self, controlId):
7168
self.feedsList[position] = {'url':newUrl, 'updateinterval':newUpdateInterval}
7269
self.updateFeedsList()
7370
#add new feed
74-
elif controlId == self.__ADD_BTN:
71+
elif controlId == self._ADDBTN:
7572
newUrl, newUpdateInterval = self.getNewFeed()
7673
if newUrl:
7774
self.feedsList.append({'url':newUrl, 'updateinterval':newUpdateInterval})
7875
self.updateFeedsList()
7976
#remove existing feed
80-
elif controlId == self.__REMOVE_BTN:
77+
elif controlId == self._DELBTN:
8178
self.removeFeed()
8279
self.updateFeedsList()
8380
#save xml
84-
elif controlId == self.__OK_BTN:
81+
elif controlId == self._OKBTN:
8582
self.parser.writeXmlToFile()
8683
self.closeDialog()
8784
#cancel dialog
88-
elif controlId == self.__CANCEL_BTN:
85+
elif controlId == self._CANCEL:
8986
self.closeDialog()
9087

9188

@@ -94,10 +91,6 @@ def onAction(self, action):
9491
self.closeDialog()
9592

9693

97-
def onFocus(self, controlId):
98-
pass
99-
100-
10194
def removeFeed(self):
10295
position = self.ListControl.getSelectedPosition()
10396
self.feedsList.remove(self.feedsList[position])
@@ -121,46 +114,41 @@ def updateFeedsList(self):
121114
self.ListControl.reset()
122115
for feed in self.feedsList:
123116
self.ListControl.addItem(feed['url'])
124-
self.list_label.setLabel(commons.translate(32014) % (''))
125117

126118

127119

128120
class XMLParser:
129121

130122
def __init__(self):
131123
self.RssFeedsPath = xbmc.translatePath('special://userdata/RssFeeds.xml').decode("utf-8")
132-
sane = self.checkRssFeedPathSanity()
124+
sane = os.path.isfile(self.RssFeedsPath) and os.path.getsize(self.RssFeedsPath)
133125
if sane:
134126
try:
135127
self.feedsTree = parse(self.RssFeedsPath)
136128
except:
137-
commons.debug('Failed to parse ' + unicodedata.normalize( 'NFKD', self.RssFeedsPath ).encode( 'ascii', 'ignore' ))
138-
regen = xbmcgui.Dialog().yesno(commons.translate(40), commons.translate(51), commons.translate(52), commons.translate(53))
139-
if regen:
140-
commons.debug('[script] RSS Editor --> Attempting to Regenerate RssFeeds.xml')
141-
xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<rssfeeds>\n\
142-
<!-- RSS feeds. To have multiple feeds, just add a feed to the set. You can also have multiple sets. !-->\n\
143-
<!-- To use different sets in your skin, each must be called from skin with a unique id. !-->\n\
144-
<set id="1">\n <feed updateinterval="30">http://feeds.feedburner.com/slashfilm</feed>\n </set>\n</rssfeeds>'
145-
f = open(self.RssFeedsPath, 'w')
146-
f.write(xml)
147-
f.close()
148-
self.__init__()
149-
else:
150-
commons.debug('User opted to not regenerate RssFeeds.xml. Script Exiting..')
151-
self.feedsTree = False
129+
commons.debug('Failed to parse %s, attempting to regenerate it..' %unicodedata.normalize('NFKD', self.RssFeedsPath).encode( 'ascii', 'ignore' ))
130+
self.regenerate()
131+
self.__init__()
152132
if self.feedsTree:
153133
self.feedsList = self.getCurrentRssFeeds()
154134
else:
155-
self.feedsTree = False
156-
self.feedsList = False
157135
commons.debug('Could not open ' + unicodedata.normalize( 'NFKD', self.RssFeedsPath ).encode( 'ascii', 'ignore' ) + '. Either the file does not exist, or its size is zero.')
136+
self.regenerate()
137+
self.__init__()
158138

159139

160-
def checkRssFeedPathSanity(self):
161-
if os.path.isfile(self.RssFeedsPath):
162-
if os.path.getsize(self.RssFeedsPath):
163-
return True
140+
def regenerate(self):
141+
xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n'
142+
xml += '<rssfeeds>\n'
143+
xml += '<!-- RSS feeds. To have multiple feeds, just add a feed to the set. You can also have multiple sets. !-->\n'
144+
xml += '<!-- To use different sets in your skin, each must be called from skin with a unique id. !-->\n'
145+
xml += '\t<set id="1">\n'
146+
xml += '\t\t<feed updateinterval="30">http://feeds.kodi.tv/xbmc</feed>\n'
147+
xml += '\t</set>\n'
148+
xml += '</rssfeeds>\n'
149+
f = open(self.RssFeedsPath, 'w')
150+
f.write(xml)
151+
f.close()
164152

165153

166154
def getCurrentRssFeeds(self):
@@ -169,18 +157,18 @@ def getCurrentRssFeeds(self):
169157
for s in sets:
170158
setName = 'set'+s.attributes["id"].value
171159
feedsList[setName] = {'feedslist':list(), 'attrs':dict()}
172-
#get attrs
160+
# get attrs
173161
for attrib in s.attributes.keys():
174162
feedsList[setName]['attrs'][attrib] = s.attributes[attrib].value
175-
#get feedslist
163+
# get feedslist
176164
feeds = s.getElementsByTagName('feed')
177165
for feed in feeds:
178166
feedsList[setName]['feedslist'].append({'url':feed.firstChild.toxml(), 'updateinterval':feed.attributes['updateinterval'].value})
179167
return feedsList
180168

181169

182-
def formXml(self):
183-
"""Form the XML to be written to RssFeeds.xml"""
170+
def writeXmlToFile(self):
171+
commons.debug('Writing to %s' % (unicodedata.normalize( 'NFKD', self.RssFeedsPath ).encode( 'ascii', 'ignore' )))
184172
# create the document
185173
doc = Document()
186174
# create root element
@@ -207,12 +195,7 @@ def formXml(self):
207195
feedUrl = doc.createTextNode(feed['url'])
208196
feedTag.appendChild(feedUrl)
209197
setTag.appendChild(feedTag)
210-
return doc.toprettyxml(indent = ' ', encoding = 'UTF-8')
211-
212-
213-
def writeXmlToFile(self):
214-
commons.debug('Writing to %s' % (unicodedata.normalize( 'NFKD', self.RssFeedsPath ).encode( 'ascii', 'ignore' )))
215-
xml = self.formXml()
198+
xml = doc.toprettyxml(indent = ' ', encoding = 'UTF-8')
216199
# hack for standalone attribute, minidom doesn't support DOM3
217200
xmlHeaderEnd = xml.find('?>')
218201
xml = xml[:xmlHeaderEnd]+' standalone="yes"'+xml[xmlHeaderEnd:]
@@ -226,9 +209,7 @@ def writeXmlToFile(self):
226209

227210

228211
def refreshFeed(self):
229-
"""
230-
Refresh MCPi's rss feed so changes can be seen immediately
231-
"""
212+
"""Refresh MCPi's rss feed so changes can be seen immediately"""
232213
xbmc.executebuiltin('refreshrss()')
233214

234215

src/resources/language/English/strings.po

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,4 @@ msgctxt "#32014"
2727
msgid "Enter the paths of your RSS feeds %s"
2828
msgstr ""
2929

30-
msgctxt "#32040"
31-
msgid "Error:"
32-
msgstr ""
33-
34-
msgctxt "#32041"
35-
msgid "was either not found in the system,"
36-
msgstr ""
3730

38-
msgctxt "#32042"
39-
msgid "or does not contain parsable XML."
40-
msgstr ""
41-
42-
msgctxt "#32043"
43-
msgid "Try deleting it from your userdata folder and restarting XBMC."
44-
msgstr ""

src/resources/skins/skin.clue/1080i/RSSEditorDialog.xml

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,18 @@
4949
<posy>44</posy>
5050
<width>4-col</width>
5151
<font>pageTitle</font>
52-
<label>RSS Editor</label>
52+
<label>32000</label>
5353
<textcolor>black</textcolor>
5454
<shadowcolor>-</shadowcolor>
5555
</control>
56-
56+
<!--Window Content - List-->
5757
<control type="group" id="5001">
5858
<posx>0</posx>
5959
<posy>3-row</posy>
6060
<control type="image">
6161
<posx>0</posx>
6262
<posy>0</posy>
63-
<width>9-col</width>
63+
<width>12-col</width>
6464
<height>5-row</height>
6565
<aspectratio>stretch</aspectratio>
6666
<texture>masks/inactive.png</texture>
@@ -69,7 +69,7 @@
6969
<control type="list" id="5110">
7070
<posx>0</posx>
7171
<posy>0</posy>
72-
<width>9-col</width>
72+
<width>12-col</width>
7373
<height>5-row</height>
7474
<onright>5002</onright>
7575
<pagecontrol>-</pagecontrol>
@@ -78,7 +78,7 @@
7878
<control type="image">
7979
<posx>0</posx>
8080
<posy>0</posy>
81-
<width>9-col</width>
81+
<width>12-col</width>
8282
<height>36</height>
8383
</control>
8484
<control type="label">
@@ -88,6 +88,7 @@
8888
<height>35</height>
8989
<aligny>center</aligny>
9090
<align>left</align>
91+
<textcolor>white</textcolor>
9192
<font>itemTitleSmall</font>
9293
<info>ListItem.Label</info>
9394
</control>
@@ -103,7 +104,7 @@
103104
<control type="image">
104105
<posx>0</posx>
105106
<posy>0</posy>
106-
<width>9-col</width>
107+
<width>12-col</width>
107108
<height>36</height>
108109
<texture>masks/selected.png</texture>
109110
<visible>Control.hasfocus(5240)|Control.hasfocus(5110)</visible>
@@ -115,16 +116,16 @@
115116
<height>35</height>
116117
<aligny>center</aligny>
117118
<align>left</align>
119+
<textcolor>selected</textcolor>
118120
<font>itemTitleSmall</font>
119121
<info>ListItem.Label</info>
120122
</control>
121123
</focusedlayout>
122124
</control>
123125
</control>
124-
125126
<!--Window Content - Dialog Buttons-->
126127
<control type="group" id="5002">
127-
<posx>10-col</posx>
128+
<posx>13-col</posx>
128129
<posy>3-row</posy>
129130
<control type="button" id="5210">
130131
<description>Ok Button</description>
@@ -136,10 +137,10 @@
136137
<align>center</align>
137138
<aligny>center</aligny>
138139
<font>menuTitle</font>
139-
<textcolor>selected</textcolor>
140-
<focusedcolor>black</focusedcolor>
140+
<textcolor>white</textcolor>
141+
<focusedcolor>selected</focusedcolor>
141142
<texturefocus>masks/selected.png</texturefocus>
142-
<texturenofocus>masks/black.png</texturenofocus>
143+
<texturenofocus>masks/offblack.png</texturenofocus>
143144
<onup>5240</onup>
144145
<onleft>5001</onleft>
145146
<ondown>5220</ondown>
@@ -154,10 +155,10 @@
154155
<align>center</align>
155156
<aligny>center</aligny>
156157
<font>menuTitle</font>
157-
<textcolor>selected</textcolor>
158-
<focusedcolor>black</focusedcolor>
158+
<textcolor>white</textcolor>
159+
<focusedcolor>selected</focusedcolor>
159160
<texturefocus>masks/selected.png</texturefocus>
160-
<texturenofocus>masks/black.png</texturenofocus>
161+
<texturenofocus>masks/offblack.png</texturenofocus>
161162
<onup>5210</onup>
162163
<onleft>5001</onleft>
163164
<ondown>5230</ondown>
@@ -172,7 +173,7 @@
172173
<align>center</align>
173174
<aligny>center</aligny>
174175
<font>menuTitle</font>
175-
<textcolor>selected</textcolor>
176+
<textcolor>white</textcolor>
176177
<focusedcolor>black</focusedcolor>
177178
<texturefocus>masks/selected.png</texturefocus>
178179
<texturenofocus>masks/offblack.png</texturenofocus>
@@ -190,7 +191,7 @@
190191
<align>center</align>
191192
<aligny>center</aligny>
192193
<font>menuTitle</font>
193-
<textcolor>selected</textcolor>
194+
<textcolor>white</textcolor>
194195
<focusedcolor>black</focusedcolor>
195196
<texturefocus>masks/selected.png</texturefocus>
196197
<texturenofocus>masks/offblack.png</texturenofocus>

0 commit comments

Comments
 (0)