def check_content_is_nzb(self): if self._content_is_nzb is None: content = self.get_content() try: # TODO: yenc decoding and possibly some more # because this alone never seems to work decode_nzb(content) except DecodeNzbError: self._content_is_nzb = False else: self._content_is_nzb = True return self._content_is_nzb
def check_content_is_nzb(self): if self._content_is_nzb is None: content = self.get_content() if content.startswith('=ybegin'): try: # TODO: yenc decoding and possibly some more # because this alone never seems to work ydecoded = content # TODO decode_nzb(ydecoded) except DecodeNzbError: self._content_is_nzb = False else: self._content_is_nzb = True self._content_is_nzb = True # TODO else: self._content_is_nzb = False return self._content_is_nzb
def get_nzb(self, post): "Retrieves the nzb for a post, returned is the nzb content" assert self.is_connected() zipped = StringIO() # TODO: maybe replace this with os.tmpfile try: for messageid in post.nzb: self._nntp.body('<%s>' % messageid, zipped) except nntplib.NNTPTemporaryError as e: if e.response == '430 No such article': raise NotFoundError else: raise content = zipped.getvalue() del zipped try: return decode_nzb(content) except DecodeNzbError as e: raise ConnectionError(e.msg)