Hi,
I'm still newish to xpath and seem to be having a problem with a for loop. The loop is supposed to grab ID nums and show titles. I'm able to grab each ID num more or less fine, but for some reason the first show title found repeats for each iteration through the loop. If anyone has insight into why this is happening, I would love to hear it!
Here is my code:
@route(PREFIX + '/showprograms')
def ShowPrograms(title):
oc = ObjectContainer(title2=title)
pass_url = 'http://ww3.tvo.org/video?quicktabs_3=0'
pageElement = HTML.ElementFromURL(pass_url)
for item in pageElement.xpath('//div[@class="form-item"]'):
testid = item.xpath('./input')[0].get('value')
testtitle = item.xpath('//label')[0].text
#using hardcoded data until error is resolved
showIDFull = '120075'
showTitle = 'A Touch of Frost'
showID = showIDFull.replace('','')
showURL = 'http://ww3.tvo.org/program/'+showID+'/'
Log ('show id:' + testid)
Log ('show title:' + testtitle)
oc.add(DirectoryObject(key=Callback(ShowEpisodes, title=showTitle, pass_url=showURL), title=showTitle, summary='Add summary'))
return oc
And here is a snippet from the log:
2014-03-22 01:34:41,328 (16c) : INFO (core:598) - Started plug-in 2014-03-22 01:34:41,328 (16c) : DEBUG (socketinterface:160) - Starting socket server 2014-03-22 01:34:41,372 (16c) : DEBUG (runtime:1111) - Created a thread named 'start' 2014-03-22 01:34:41,374 (16c) : INFO (socketinterface:184) - Socket server started on port 50384 2014-03-22 01:34:41,374 (16c) : INFO (pipeinterface:25) - Entering run loop 2014-03-22 01:34:41,375 (16c) : DEBUG (runtime:717) - Handling request GET /:/prefixes 2014-03-22 01:34:41,381 (16c) : DEBUG (runtime:814) - Found route matching /:/prefixes 2014-03-22 01:34:41,470 (1244) : DEBUG (services:362) - Loaded services 2014-03-22 01:34:41,473 (16c) : DEBUG (runtime:918) - Response: [200] MediaContainer, 418 bytes 2014-03-22 01:34:41,476 (1338) : DEBUG (services:438) - No shared code to load 2014-03-22 01:34:46,331 (27c4) : DEBUG (runtime:717) - Handling request GET /video/tvo 2014-03-22 01:34:46,338 (27c4) : DEBUG (runtime:814) - Found route matching /video/tvo 2014-03-22 01:34:46,338 (27c4) : DEBUG (base:123) - Checking if com.plexapp.plugins.tvo is broken 2014-03-22 01:34:46,339 (27c4) : DEBUG (networking:172) - Requesting 'http://127.0.0.1:32400/:/plugins/com.plexapp.system/messaging/function/X1N0b3JlU2VydmljZTpJc0NoYW5uZWxCcm9rZW4_/Y2VyZWFsMQoxCmxpc3QKMApyMAo_/Y2VyZWFsMQoxCmRpY3QKMQpzMjMKY29tLnBsZXhhcHAucGx1Z2lucy50dm9zMTAKaWRlbnRpZmllcnIwCg__' 2014-03-22 01:34:46,344 (267c) : DEBUG (runtime:717) - Handling request GET /video/tvo/showprograms?title=Programs 2014-03-22 01:34:46,345 (267c) : DEBUG (runtime:814) - Found route matching /video/tvo/showprograms 2014-03-22 01:34:46,345 (267c) : DEBUG (networking:172) - Requesting 'http://ww3.tvo.org/video?quicktabs_3=0' 2014-03-22 01:34:46,369 (27c4) : DEBUG (runtime:918) - Response: [200] MediaContainer, 829 bytes 2014-03-22 01:34:47,203 (267c) : INFO (logkit:16) - show id:Search TVO... 2014-03-22 01:34:47,203 (267c) : INFO (logkit:16) - show title: All 2014-03-22 01:34:47,204 (267c) : INFO (logkit:16) - show id:Search All Videos 2014-03-22 01:34:47,206 (267c) : INFO (logkit:16) - show title: All 2014-03-22 01:34:47,206 (267c) : INFO (logkit:16) - show id:All 2014-03-22 01:34:47,207 (267c) : INFO (logkit:16) - show title: All 2014-03-22 01:34:47,207 (267c) : INFO (logkit:16) - show id:192225 2014-03-22 01:34:47,207 (267c) : INFO (logkit:16) - show title: All 2014-03-22 01:34:47,207 (267c) : INFO (logkit:16) - show id:120075 2014-03-22 01:34:47,209 (267c) : INFO (logkit:16) - show title: All 2014-03-22 01:34:47,209 (267c) : INFO (logkit:16) - show id:201118 2014-03-22 01:34:47,210 (267c) : INFO (logkit:16) - show title: All 2014-03-22 01:34:47,210 (267c) : INFO (logkit:16) - show id:120165 2014-03-22 01:34:47,210 (267c) : INFO (logkit:16) - show title:And so on…