Downloads and saves profile pic.

def download_profilepic(self, profile: Profile, _attempt: int = 1) -> None:
        """Downloads and saves profile pic."""

        def _epoch_to_string(epoch: datetime) -> str:
            return epoch.strftime('%Y-%m-%d_%H-%M-%S_UTC')

        profile_pic_response = self.context.get_raw(profile.profile_pic_url)
        if 'Last-Modified' in profile_pic_response.headers:
            date_object = datetime.strptime(profile_pic_response.headers["Last-Modified"], '%a, %d %b %Y %H:%M:%S GMT')
            profile_pic_bytes = None
            profile_pic_identifier = _epoch_to_string(date_object)
        else:
            date_object = None
            profile_pic_bytes = profile_pic_response.content
            profile_pic_identifier = md5(profile_pic_bytes).hexdigest()[:16]
        profile_pic_extension = 'jpg'
        if ((format_string_contains_key(self.dirname_pattern, 'profile') or
             format_string_contains_key(self.dirname_pattern, 'target'))):
            filename = '{0}/{1}_profile_pic.{2}'.format(self.dirname_pattern.format(profile=profile.username.lower(),
                                                                                    target=profile.username.lower()),
                                                        profile_pic_identifier, profile_pic_extension)
        else:
            filename = '{0}/{1}_{2}_profile_pic.{3}'.format(self.dirname_pattern.format(), profile.username.lower(),
                                                            profile_pic_identifier, profile_pic_extension)
        content_length = profile_pic_response.headers.get('Content-Length', None)
        if os.path.isfile(filename) and (not self.context.is_logged_in or
                                         content_length is not None and os.path.getsize(filename) >= int(content_length)):
            self.context.log(filename + ' already exists')
            return None
        self.context.write_raw(profile_pic_bytes if profile_pic_bytes else profile_pic_response, filename)
        if date_object:
            os.utime(filename, (datetime.now().timestamp(), date_object.timestamp()))
        self.context.log('')