CREATE OR REPLACE FUNCTION public.get_website_name(in_url text) RETURNS text
	LANGUAGE plpgsql IMMUTABLE STRICT
	AS $$
DECLARE
	website_name text;
BEGIN
	in_url = trim(in_url);

	IF regexp_like(in_url, 'rule34\.xxx') THEN
		website_name = 'Rule34';
	ELSIF regexp_like(in_url, 'kemono\.su') THEN
		website_name = 'Kemono';
	ELSIF regexp_like(in_url, 'coomer\.su') THEN
		website_name = 'Coomer';
	ELSIF regexp_like(in_url, 'gofile\.io') THEN
		website_name = 'GoFile';
	ELSIF regexp_like(in_url, 'allthefallen\.moe') THEN
		website_name = 'ATF';
	ELSIF regexp_like(in_url, 'e621\.net') THEN
		website_name = 'e621';
	ELSIF regexp_like(in_url, 'gelbooru\.com') THEN
		website_name = 'Gelbooru';
	ELSIF regexp_like(in_url, 'hypnohub\.net') THEN
		website_name = 'HypnoHub';
	ELSIF regexp_like(in_url, 'konachan\.com') THEN
		website_name = 'Konachan';
	ELSIF regexp_like(in_url, 'pixiv\.net') THEN
		website_name = 'Pixiv';
	ELSIF regexp_like(in_url, 'fantia\.jp') THEN
		website_name = 'Fantia';
	ELSE
		RETURN NULL;
	END IF;

	RETURN website_name;
END;
$$;
