From a5a6f5180a8d765677cdedaaf59b6d86d6dc9e42 Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Wed, 27 Dec 2023 00:53:11 +0100 Subject: [PATCH] Soundcloud & IGDB --- socials_util/__init__.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/socials_util/__init__.py b/socials_util/__init__.py index d102ec4..892a1d2 100644 --- a/socials_util/__init__.py +++ b/socials_util/__init__.py @@ -56,6 +56,8 @@ class SocialSiteId(aenum.Enum): ITCH_IO_DEVELOPER = 8176 FIREFOX_PROFILE_BOOKMARKS = 33 COHOST_PROFILE = 117203288 + SOUNDCLOUD_ARTIST = 3040 + IGDB_GAME_ID = 5794 def wikidata_property(self, client): return client.get(WIKIDATA_PROPERTIES[self]) @@ -69,6 +71,7 @@ AGGERAGOR_SOCIALS = { SocialSiteId.CARRD_PAGE, SocialSiteId.LINK_COLLECTION_PAGE, SocialSiteId.DANBOORU_ARTIST, + SocialSiteId.IGDB_GAME_ID, } @enforce_types @@ -125,11 +128,13 @@ WIKIDATA_PROPERTIES = { SocialSiteId.BLUESKY_PROFILE: WikidataInfo(None, 78194383), SocialSiteId.ITCH_IO_DEVELOPER: WikidataInfo(8176, 22905933), SocialSiteId.COHOST_PROFILE: WikidataInfo(None, 117203288), + SocialSiteId.SOUNDCLOUD_ARTIST: WikidataInfo(3040, None), + SocialSiteId.IGDB_GAME_ID: WikidataInfo(5794, None), } def re_social_subdomain(main_domain): #return r'^(?:https?:\/\/)?([\w_-]+)\.'+re.escape(main_domain)+'\/?$' - return r'^(?:https?:\/\/)?([\w_-]+)\.'+re.escape(main_domain)+'(\/.*)?$' + return r'^(?:https?:\/\/)?([\w_-]+)\.'+re.escape(main_domain)+r'(\/.*)?$' RE_ID = r'@?([^/]+)' RE_ANY_SUBPATH = r'(|\/|\/.*)$' @@ -140,7 +145,7 @@ def re_social_path(main_domain): def re_social_path_adv(main_domain, *path): assert not main_domain.startswith('www.'), 'Redundant www.' - l = [r'^', '(?:https?:\/\/)?', r'(?:www\.)?', re.escape(main_domain)] + l = [r'^', r'(?:https?:\/\/)?', r'(?:www\.)?', re.escape(main_domain)] for p in path: if p != RE_ANY_SUBPATH: @@ -192,7 +197,6 @@ URL_PARSE_DANBOORU_ARTIST = re_social_path_adv('danbooru.donmai.us', 'artists', URL_PARSE_BANDCAMP = re_social_subdomain('bandcamp.com') URL_PARSE_BLUESKY = re_social_path_adv('bsky.app', 'profile', RE_ID) URL_PARSE_ITCH_IO_DEVELOPER = re_social_subdomain('itch.io') -URL_PARSE_COHOST = re_social_path_adv('cohost.org', RE_ID) REGEXES = [ # Reddit @@ -295,7 +299,13 @@ REGEXES = [ (URL_PARSE_ITCH_IO_DEVELOPER, SocialSiteId.ITCH_IO_DEVELOPER), # Cohost - (URL_PARSE_COHOST, SocialSiteId.COHOST_PROFILE), + (re_social_path_adv('cohost.org', RE_ID), SocialSiteId.COHOST_PROFILE), + + # Soundcloud + (re_social_path_adv('soundcloud.com', RE_ID), SocialSiteId.IGDB_GAME_ID), + + # IGDB + (re_social_path_adv('igdb.com', 'games', RE_ID), SocialSiteId.IGDB_GAME_ID), ] WELL_KNOWN_MASTODON_INSTANCES = frozenset({