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

	IF regexp_like(in_url, 'rule34\.xxx') THEN
		artist_name = substring(in_url from 52);
	ELSIF regexp_like(in_url, 'allthefallen\.moe') THEN
		artist_name = substring(in_url from 43);
	ELSIF regexp_like(in_url, 'e621\.net') THEN
		artist_name = substring(in_url from 29);
	ELSIF regexp_like(in_url, 'gelbooru\.com') THEN
		artist_name = substring(in_url from 54);
	ELSIF regexp_like(in_url, 'hypnohub\.net') THEN
		artist_name = substring(in_url from 54);
	ELSIF regexp_like(in_url, 'konachan\.com') THEN
		artist_name = substring(in_url from 32);
	ELSE
		RETURN NULL;
	END IF;
	
	RETURN artist_name;
END;
$$;
