resolve_url#

scikitplot.corpus.resolve_url(url, kind=None)[source]#

Resolve a provider-specific URL to a direct-download URL.

Parameters:
urlstr

Original URL.

kindURLKind or None, optional

Pre-computed classification. If None, classify_url is called. Default: None.

Returns:
str

Direct-download URL. For WEB_PAGE and YOUTUBE kinds, the original URL is returned unchanged (they are not download targets). For DOWNLOADABLE and GITHUB_RAW, the URL is returned as-is (already direct). For GOOGLE_DRIVE and GITHUB_BLOB, the resolved URL is returned.

Raises:
ValueError

If the URL cannot be resolved (e.g. malformed Google Drive link).

Parameters:
Return type:

str

Examples

>>> resolve_url("https://drive.google.com/file/d/abc123/view")
'https://drive.google.com/uc?export=download&id=abc123'
>>> resolve_url("https://github.com/user/repo/blob/main/data.csv")
'https://raw.githubusercontent.com/user/repo/main/data.csv'