32 """Check if the given URL is a direct link to a zip file"""
34 MTYPE =
'application/zip'
37 if mimetypes.guess_type(url)[0] == MTYPE:
42 request = urllib.request.Request(url, method=
'HEAD')
43 response = urllib.request.urlopen(request)
44 except Exception
as e:
45 raise PluginDownloadError(str(e))
47 return response.getheader(
'Content-Type') == MTYPE
76 """Download a plugin from a given URL into the given directory.
78 ``url`` may either point directly to a zip location (on any site),
79 or to a github repository.
81 Returns full path of the downloaded zip file.
84 dest_path = os.path.join(dest_dir,
'plugin.zip')
86 headers[
'User-Agent'] =
'krita-plugin-importer'
89 request = urllib.request.Request(zip_url, headers=headers)
90 with urllib.request.urlopen(request)
as source:
91 with open(dest_path,
'wb')
as destination:
92 destination.write(source.read())
93 except Exception
as e: