tinyurlhu.py 780 B

123456789101112131415161718192021
  1. from terroroftinytown.services.base import BaseService
  2. from terroroftinytown.services.rand import HashRandMixin
  3. from terroroftinytown.client.errors import UnexpectedNoResult
  4. from terroroftinytown.services.status import URLStatus
  5. from terroroftinytown.six import u
  6. class TinyurlHuService(BaseService):
  7. def process_redirect_body(self, response):
  8. try:
  9. return BaseService.process_redirect_body(self, response)
  10. except UnexpectedNoResult:
  11. if b'Sajn\xc3\xa1lom, de a be\xc3\xadrt URL hib\xc3\xa1s!'.decode('utf8') in response.text:
  12. return (URLStatus.not_found, None, None)
  13. else:
  14. raise
  15. class TinyurlHu4Service(HashRandMixin, TinyurlHuService):
  16. def get_shortcode_width(self):
  17. return 4