Download the resources specified by url into dir_path. The resulting
            file path is returned.

            DownloadError is raised the resources cannot be downloaded.

def download(self, url, dir_path, filename=None):
        """ Download the resources specified by url into dir_path. The resulting
            file path is returned.

            DownloadError is raised the resources cannot be downloaded.
        """
        if not filename:
            filename = url.rsplit('/', 1)[1]
        path = os.path.join(dir_path, filename)

        content = self.fetch(url)
        with open(path, "wb") as f:
            f.write(content)

        return path