def from_session(session, metadata, guid, rating_key, state): return WatchSession( session.key, metadata, guid, rating_key, state, session=session ) @staticmethod def from_info(info, metadata, guid, rating_key): if not info: return None return WatchSession( 'logging-%s' % info.get('machineIdentifier'), metadata, guid, rating_key, info['state'] ) def __repr__(self): return build_repr(self, [ 'key', 'rating_key', 'cur_state', 'progress', 'user', 'client' ]) def __str__(self): return self.__repr__() ClassRegistry.register('watch_session.WatchSession', WatchSession)
self.error = self.format_exception(exceptions[0]) self.exceptions = exceptions else: self.error = None self.exceptions = [] self.save() @staticmethod def format_exception(exc): if isinstance(exc, trakt.RequestError): # trakt.py _, desc = exc.error if len(exc.error) == 2 else ("Unknown", "Unknown") # Format message return 'trakt.tv - %s: "%s"' % (exc.status_code, desc) return '%s: "%s"' % (getattr(type(exc), '__name__'), exc.message) def __repr__(self): return build_repr(self, [ 'previous_timestamp', 'previous_elapsed', 'previous_success', 'last_success' ]) def __str__(self): return self.__repr__() ClassRegistry.register('sync_status.SyncStatus', SyncStatus)