2007-02-03, 02:06
I'm trying to modify the Kaleidascrape script to work for some new trivia slides I got. I know almost nothing about python, I basically just tried to figure it out by looking through the script and seeing what was doing what. Anyway, part of the script starts a slideshow, and some slides are supposed to be grouped together, in groups of two for the original script, because with the trivia questions, there's a question, and then an answer. In a new trivia slide pack I got, there is still a question and answer, but also a CLUE inbetween. So, I'm trying to make it so it will group these new ones together as well. The old slides use an A, B system, where like 101a.jpg would be the question and 101b.jpg would be the answer, a would show first and then b. I want to continue to use this, but also add the ability to do the three slide thing. The way the 3 slide groups are labels is q for question, c for clue, and r for response, so it would go, for example, 101q.jpg, then 101c.jpg, then 101r.jpg (the 101 is just filling the place for any arbitrary file name, by the way). Anyway, below you can see my efforts to achieve this, however it doesn't like it. I get a "TypeError: an integer is required" message for the line that says randInfo3 = re.sub(r'([^-]+)q.jpg', r'\1r.jpg', r'\1c.jpg', str(randInfo3))
I'm sure its a simple fix, but if somebody could help me out it would be great. By the way, I made all the lines I added bold, so, this is probably where you should check for problems haha. Also, in the actual script, I have the proper spacing, I believe, just when you copy and paste into here it removes all the tabs and stuff.
#Function to grab Trivia#
trivialist = index(triviaDir);
count = (len(trivialist))
queuecount = 0
mytrivia = Trivia()
xbmc.Player().play(mlist)
time.sleep(1)
mytrivia.show()
while queuecount < trivia_num:
randtriv = random.randint(1, count)
randInfo = trivialist[randtriv]
randInfo1 = trivialist[randtriv]
randInfo2 = trivialist[randtriv]
randInfo3 = trivialist[randtriv]
randInfo4 = trivialist[randtriv]
randInfo5 = trivialist[randtriv]
randInfo1 = re.sub(r'([^-]+)b.jpg', r'\1a.jpg', str(randInfo1))
randInfo2 = re.sub(r'([^-]+)a.jpg', r'\1b.jpg', str(randInfo2))
randInfo3 = re.sub(r'([^-]+)q.jpg', r'\1r.jpg', r'\1c.jpg', str(randInfo3))
randInfo4 = re.sub(r'([^-]+)r.jpg', r'\1q.jpg', r'\1c.jpg', str(randInfo4))
randInfo5 = re.sub(r'([^-]+)c.jpg', r'\1q.jpg', r'\1r.jpg', str(randInfo5))
match = re.match('.*?b.jpg', randInfo)
match2 = re.match('.*?a.jpg', randInfo)
match3 = re.match('.*?q.jpg', randInfo)
match4 = re.match('.*?r.jpg', randInfo)
match5 = re.match('.*?c.jpg', randInfo)
if match:
mytrivia.display(randInfo1)
mytrivia.display(randInfo2)
elif match2:
mytrivia.display(randInfo1)
mytrivia.display(randInfo2)
elif match3:
mytrivia.display(randInfo3)
mytrivia.display(randInfo4)
mytrivia.display(randInfo5)
elif match4:
mytrivia.display(randInfo3)
mytrivia.display(randInfo4)
mytrivia.display(randInfo5)
elif match5:
mytrivia.display(randInfo3)
mytrivia.display(randInfo4)
mytrivia.display(randInfo5)
else:
mytrivia.display(randInfo1)
queuecount = queuecount + 1
mytrivia.close()
xbmc.Player().stop(mlist)
del mytrivia
I'm sure its a simple fix, but if somebody could help me out it would be great. By the way, I made all the lines I added bold, so, this is probably where you should check for problems haha. Also, in the actual script, I have the proper spacing, I believe, just when you copy and paste into here it removes all the tabs and stuff.
#Function to grab Trivia#
trivialist = index(triviaDir);
count = (len(trivialist))
queuecount = 0
mytrivia = Trivia()
xbmc.Player().play(mlist)
time.sleep(1)
mytrivia.show()
while queuecount < trivia_num:
randtriv = random.randint(1, count)
randInfo = trivialist[randtriv]
randInfo1 = trivialist[randtriv]
randInfo2 = trivialist[randtriv]
randInfo3 = trivialist[randtriv]
randInfo4 = trivialist[randtriv]
randInfo5 = trivialist[randtriv]
randInfo1 = re.sub(r'([^-]+)b.jpg', r'\1a.jpg', str(randInfo1))
randInfo2 = re.sub(r'([^-]+)a.jpg', r'\1b.jpg', str(randInfo2))
randInfo3 = re.sub(r'([^-]+)q.jpg', r'\1r.jpg', r'\1c.jpg', str(randInfo3))
randInfo4 = re.sub(r'([^-]+)r.jpg', r'\1q.jpg', r'\1c.jpg', str(randInfo4))
randInfo5 = re.sub(r'([^-]+)c.jpg', r'\1q.jpg', r'\1r.jpg', str(randInfo5))
match = re.match('.*?b.jpg', randInfo)
match2 = re.match('.*?a.jpg', randInfo)
match3 = re.match('.*?q.jpg', randInfo)
match4 = re.match('.*?r.jpg', randInfo)
match5 = re.match('.*?c.jpg', randInfo)
if match:
mytrivia.display(randInfo1)
mytrivia.display(randInfo2)
elif match2:
mytrivia.display(randInfo1)
mytrivia.display(randInfo2)
elif match3:
mytrivia.display(randInfo3)
mytrivia.display(randInfo4)
mytrivia.display(randInfo5)
elif match4:
mytrivia.display(randInfo3)
mytrivia.display(randInfo4)
mytrivia.display(randInfo5)
elif match5:
mytrivia.display(randInfo3)
mytrivia.display(randInfo4)
mytrivia.display(randInfo5)
else:
mytrivia.display(randInfo1)
queuecount = queuecount + 1
mytrivia.close()
xbmc.Player().stop(mlist)
del mytrivia