Hey guys,
Decided to dive head first into channel development for something new to learn, and I've very quickly found myself overwhelmed. :( I am using a relatively easy video streaming website as my first project. (I say easy because direct video links are available from the html and I've read that makes it "easy" lol). While I have a basic understanding of Python, I'm attempting to learn about xpath etc as I go.
I know its probably me doing something retarded, but can someone take a quick look at this code and explain to me what I'm doing wrong. The idea here is that I load the page, use the xpath query to create a list (I've created/tested the xpath query with a chrome plugin), and then display that list as my menu.
def MainMenu():
oc = ObjectContainer()
search_page = XML.ElementFromURL("http://kissanime.com/AnimeList/MostPopular")
item = search_page.xpath("//table[@class='listing']/tbody/tr/td[1]")
for each in item:
oc.Append(each)
return oc
However, I immediately get this error from the log:
013-08-08 18:43:13,974 (1820) : INFO (core:598) - Started plug-in
2013-08-08 18:43:13,974 (1820) : DEBUG (socketinterface:144) - Starting socket server
2013-08-08 18:43:13,976 (1820) : DEBUG (runtime:1104) - Created a thread named 'start'
2013-08-08 18:43:13,976 (1820) : INFO (socketinterface:168) - Socket server started on port 63762
2013-08-08 18:43:13,976 (1820) : INFO (pipeinterface:25) - Entering run loop
2013-08-08 18:43:13,976 (1820) : DEBUG (runtime:714) - Handling request GET /:/prefixes
2013-08-08 18:43:13,977 (1820) : DEBUG (runtime:811) - Found route matching /:/prefixes
2013-08-08 18:43:14,059 (658) : DEBUG (services:362) - Loaded services
2013-08-08 18:43:14,062 (1820) : DEBUG (runtime:911) - Response: [200] MediaContainer, 455 bytes
2013-08-08 18:43:14,065 (8c4) : DEBUG (services:438) - No shared code to load
2013-08-08 18:43:14,118 (1a94) : DEBUG (runtime:714) - Handling request GET /video/kissanime
2013-08-08 18:43:14,119 (1a94) : DEBUG (runtime:811) - Found route matching /video/kissanime
2013-08-08 18:43:14,121 (1a94) : DEBUG (networking:172) - Requesting 'http://kissanime.com/AnimeList/MostPopular'
2013-08-08 18:43:14,789 (1a94) : CRITICAL (core:561) - Exception (most recent call last):
File "C:\Users\Jamieson\AppData\Local\Plex Media Server\Plug-ins\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\components\runtime.py", line 837, in handle_request
result = f(**d)
File "C:\Users\Jamieson\AppData\Local\Plex Media Server\Plug-ins\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\handlers\base.py", line 119, in call
result = self.func(*args, **kwargs)
File "C:\Users\Jamieson\AppData\Local\Plex Media Server\Plug-ins\KissAnime.bundle\Contents\Code\__init__.py", line 30, in MainMenu
search_page = XML.ElementFromURL("http://kissanime.com/AnimeList/MostPopular")
File "C:\Users\Jamieson\AppData\Local\Plex Media Server\Plug-ins\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\api\parsekit.py", line 345, in ElementFromURL
).content, encoding=encoding, max_size=max_size)
File "C:\Users\Jamieson\AppData\Local\Plex Media Server\Plug-ins\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\api\parsekit.py", line 301, in ElementFromString
return self._core.data.xml.from_string(string, encoding = encoding)
File "C:\Users\Jamieson\AppData\Local\Plex Media Server\Plug-ins\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\components\data.py", line 169, in from_string
return etree.fromstring(markup)
File "lxml.etree.pyx", line 2743, in lxml.etree.fromstring (..\src\lxml\lxml.etree.c:52665)
File "parser.pxi", line 1573, in lxml.etree._parseMemoryDocument (..\src\lxml\lxml.etree.c:79932)
File "parser.pxi", line 1452, in lxml.etree._parseDoc (..\src\lxml\lxml.etree.c:78774)
File "parser.pxi", line 960, in lxml.etree._BaseParser._parseDoc (..\src\lxml\lxml.etree.c:75389)
File "parser.pxi", line 564, in lxml.etree._ParserContext._handleParseResultDoc (..\src\lxml\lxml.etree.c:71739)
File "parser.pxi", line 645, in lxml.etree._handleParseResult (..\src\lxml\lxml.etree.c:72614)
File "parser.pxi", line 585, in lxml.etree._raiseParseError (..\src\lxml\lxml.etree.c:71955)
XMLSyntaxError: Opening and ending tag mismatch: link line 18 and head, line 40, column 8
2013-08-08 18:43:14,795 (1a94) : DEBUG (runtime:911) - Response: [500] 2336 bytes
Am I not using the API correctly?
Cheers in advance,
Jamie

