myspac.py 733 B

12345678910111213141516171819
  1. from terroroftinytown.services.base import BaseService
  2. from terroroftinytown.services.status import URLStatus
  3. class MyspAcService(BaseService):
  4. def process_redirect(self, response):
  5. status, link, encoding = BaseService.process_redirect(self, response)
  6. if link.startswith('/') and link.endswith('/'):
  7. url = self.params['url_template'].format(shortcode=self.current_shortcode) + '/'
  8. response = self.fetch_url(url, 'head')
  9. status, link, encoding = BaseService.process_redirect(self, response)
  10. if link in ('https://myspace.com/404', 'http://myspace.com/404'):
  11. return URLStatus.not_found, None, None
  12. else:
  13. return status, link, encoding