RuudBurger/CouchPotatoServer — pull request #2155 by nrgaway (2013-09-14 02:22:47+00:00)
Title: Tv xem

I have completed the Xem info provider, but before I begin to implement it I want to submit this PR for merge so Rudd can take a look at errors that are occurring that I do not believe are a direct result from my code since all the tv show I tested with do actually add to the database correctly. The Xem info provider currently injects 'map_episode', 'map_absolute' and 'map_names' into the info object on the show and episode level which will be used to map episodes.

I figure since Rudd is more familiar with the code he should be able to either fix whats broken quickly or provide an explanation of what is actually happening.

Two shows I test with are 'Don't Trust the B---- in Apartment 23' (use bitch for search keyword) and 'American Dad!' (use american dad for keywords). All the episodes DO get correctly added to database but I am assuming because of other errors, the front end it notified as 'Show didn't add properly. Check logs'

Note. I deleted the database prior to testing to make sure it was fresh.

Here are the errors that happen when loading American Dad.

These happen a dozen times or so for the 200 or so episodes:
```
09-13 21:40:53 ERROR #[31m[ couchpotato.api] Failed doing nonblock request: Traceback (most recent call last):
File "/home/jason/src/CouchPotatoServer/couchpotato/api.py", line 50, in onNewMessage
self.finish(response)
File "/home/jason/src/CouchPotatoServer/libs/tornado/web.py", line 771, in finish
self.request.finish()
File "/home/jason/src/CouchPotatoServer/libs/tornado/httpserver.py", line 485, in finish
self.connection.finish()
File "/home/jason/src/CouchPotatoServer/libs/tornado/httpserver.py", line 240, in finish
self.stream.set_nodelay(True)
File "/home/jason/src/CouchPotatoServer/libs/tornado/iostream.py", line 769, in set_nodelay
self.socket.family in (socket.AF_INET, socket.AF_INET6)):
File "/usr/lib/python2.7/socket.py", line 219, in
family = property(lambda self: self._sock.family, doc="the socket family")
File "/usr/lib/python2.7/socket.py", line 170, in _dummy
raise error(EBADF, 'Bad file descriptor')
error: [Errno 9] Bad file descriptor
#[0m
09-13 21:40:53 DEBUG #[36m[o.core.notifications.core] Failed sending to listener: Traceback (most recent call last):

File "/home/jason/src/CouchPotatoServer/couchpotato/core/notifications/core/main.py", line 173, in frontend
'result': [notification],
File "/home/jason/src/CouchPotatoServer/couchpotato/api.py", line 53, in onNewMessage
self.finish({'success': False, 'error': 'Failed returning results'})
File "/home/jason/src/CouchPotatoServer/libs/tornado/web.py", line 770, in finish
self.flush(include_footers=True)
File "/home/jason/src/CouchPotatoServer/libs/tornado/web.py", line 724, in flush
chunk = transform.transform_chunk(chunk, include_footers)
File "/home/jason/src/CouchPotatoServer/libs/tornado/web.py", line 2244, in transform_chunk
self._gzip_file.write(chunk)
File "/usr/lib/python2.7/gzip.py", line 221, in write
self._check_closed()
File "/usr/lib/python2.7/gzip.py", line 155, in _check_closed
raise ValueError('I/O operation on closed file.')
ValueError: I/O operation on closed file.
```

Happened only once. Maybe it does not like the title:
```
09-13 21:39:16 DEBUG #[36m[edia.show.library.episode] Adding titles: [u'A.T. The Abusive Terrestrial']#[0m
Traceback (most recent call last):
File "/home/jason/src/CouchPotatoServer/libs/tornado/ioloop.py", line 461, in _run_callback
callback()
File "/home/jason/src/CouchPotatoServer/libs/tornado/stack_context.py", line 331, in wrapped
raise_exc_info(exc)
File "/home/jason/src/CouchPotatoServer/libs/tornado/stack_context.py", line 302, in wrapped
ret = fn(*args, **kwargs)
File "/home/jason/src/CouchPotatoServer/libs/tornado/iostream.py", line 365, in wrapper
self._maybe_add_error_listener()
File "/home/jason/src/CouchPotatoServer/libs/tornado/iostream.py", line 599, in _maybe_add_error_listener
self._add_io_state(ioloop.IOLoop.READ)
File "/home/jason/src/CouchPotatoServer/libs/tornado/iostream.py", line 629, in _add_io_state
self.fileno(), self._handle_events, self._state)
File "/home/jason/src/CouchPotatoServer/libs/tornado/iostream.py", line 682, in fileno
return self.socket.fileno()
File "/usr/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
File "/usr/lib/python2.7/socket.py", line 170, in _dummy
raise error(EBADF, 'Bad file descriptor')
socket.error: [Errno 9] Bad file descriptor
```

Happened a handful of times:
```
09-13 21:39:12 ERROR #[31mException in callback #[0m
Traceback (most recent call last):
File "/home/jason/src/CouchPotatoServer/libs/tornado/ioloop.py", line 461, in _run_callback
callback()
File "/home/jason/src/CouchPotatoServer/libs/tornado/stack_context.py", line 331, in wrapped
raise_exc_info(exc)
File "/home/jason/src/CouchPotatoServer/libs/tornado/stack_context.py", line 302, in wrapped
ret = fn(*args, **kwargs)
File "/home/jason/src/CouchPotatoServer/libs/tornado/iostream.py", line 365, in wrapper
self._maybe_add_error_listener()
File "/home/jason/src/CouchPotatoServer/libs/tornado/iostream.py", line 599, in _maybe_add_error_listener
self._add_io_state(ioloop.IOLoop.READ)
File "/home/jason/src/CouchPotatoServer/libs/tornado/iostream.py", line 629, in _add_io_state
self.fileno(), self._handle_events, self._state)
File "/home/jason/src/CouchPotatoServer/libs/tornado/iostream.py", line 682, in fileno
return self.socket.fileno()
File "/usr/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
File "/usr/lib/python2.7/socket.py", line 170, in _dummy
raise error(EBADF, 'Bad file descriptor')
error: [Errno 9] Bad file descriptor
```

After the shows are finished adding to database, I click on wanted and get the following error.
```
09-13 21:52:16 ERROR #[31m[ couchpotato.api] Failed doing api request "movie.list": Traceback (most recent call last):
File "/home/jason/src/CouchPotatoServer/couchpotato/api.py", line 99, in run_handler
result = api[route](**kwargs)
File "/home/jason/src/CouchPotatoServer/couchpotato/core/media/movie/_base/main.py", line 348, in listView
order = order
File "/home/jason/src/CouchPotatoServer/couchpotato/core/media/movie/_base/main.py", line 235, in list
.filter(Release.movie_id.in_(movie_ids)) \
AttributeError: type object 'Release' has no attribute 'movie_id'
```