Skip to content

bouli/urlicon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

URLicon - v0.2.5

URLicon helps you to discover an possible icon from a URL.

We check for the metatag icons, favicons and, if we don't find, we check the first image in the URL html code. Finally, if nothing is found, we use the https://ui-avatars.com/api/ to bring you at least some avatar-like icon.

How to install and use

Install with uv or pip

uv add urlicon
# or
pip urlicon

Usage:

from urlicon import urlicon

url = "https://this-is.your-url.com/some-path"

icon_url = urlicon.get_url_icon(url)

print("icon:", icon_url)
# icon: "https://this-is.your-url.com/icon.jpeg"

Caching

URLicon use the unforgettable "cache" to avoid unecessary URL requests. It uses a temp dir for each execution. But you can define a your own directory and use the cache as much as you want setting SIMPLE_CACHE_ROOT_DIR env var.

SIMPLE_CACHE_ROOT_DIR = os.getenv("SIMPLE_CACHE_ROOT_DIR", None)
cache = unforgettable(cache_folder=SIMPLE_CACHE_ROOT_DIR)

And you can clean the cache with:

urlicon.unforgettable.clean()

See Also

License

This package is distributed under the MIT license.

About

`URLicon` helps you to discover an possible icon from a URL.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors