]> git.mxchange.org Git - fba.git/blob - fba/helpers/software.py
Continued:
[fba.git] / fba / helpers / software.py
1 # Fedi API Block - An aggregator for fetching blocking data from fediverse nodes
2 # Copyright (C) 2023 Free Software Foundation
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU Affero General Public License as published
6 # by the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU Affero General Public License for more details.
13 #
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
16
17 import logging
18
19 from fba.helpers import tidyup
20 from fba.helpers import version
21
22 logging.basicConfig(level=logging.INFO)
23 logger = logging.getLogger(__name__)
24
25 def alias(software: str) -> str:
26     logger.debug("software='%s'- CALLED!", software)
27     if not isinstance(software, str) and software is not None:
28         raise ValueError(f"software[]='{type(software)}' is not type 'str'")
29
30     logger.debug("software='%s'- BEFORE!", software)
31     software = tidyup.domain(software)
32     logger.debug("software='%s'- AFTER!", software)
33
34     if software in ["akkoma", "rebased", "akkounfucked", "ched", "incestoma"]:
35         logger.debug("Setting pleroma: software='%s'", software)
36         software = "pleroma"
37     elif "radiant" in software:
38         logger.debug("Setting radiant: software='%s'", software)
39         software = "radiant"
40     elif software in ["hometown", "ecko", "fedibird" ] or "되는 마스토돈" in software or "mastodon" in software:
41         logger.debug("Setting mastodon: software='%s'", software)
42         software = "mastodon"
43     elif software in ["slipfox calckey", "calckey", "groundpolis", "foundkey", "cherrypick", "meisskey", "magnetar", "keybump", "dolphin", "calckey social", "azk.sns", "firefish", "qtmmsky", "iceshrimp", "owohub"] or "shumihub" in software or "мисскей" in software or "milkey" in software or "misskey" in software:
44         logger.debug("Setting misskey: software='%s'", software)
45         software = "misskey"
46     elif software in ["runtube.re", "islameye"]:
47         logger.debug("Setting peertube: software='%s'", software)
48         software = "peertube"
49     elif software in ["nextcloud social", "nextcloudpi", "storage share"] or "nextcloud" in software:
50         logger.debug("Setting nextcloud: software='%s'", software)
51         software = "nextcloud"
52     elif software == "activity-relay":
53         logger.debug("Setting activityrelay: software='%s'", software)
54         software = "activityrelay"
55     elif "owncast" in software:
56         logger.debug("Setting owncast: software='%s'", software)
57         software = "owncast"
58     elif software in ["streams-hubzilla-social", "streams13"]:
59         logger.debug("Setting streams: software='%s'", software)
60         software = "streams"
61     elif software == "roadhouse":
62         logger.debug("Setting hubzilla: software='%s'", software)
63         software = "hubzilla"
64     elif software == "takahē":
65         logger.debug("Setting takahe: software='%s'", software)
66         software = "takahe"
67     elif software == "diaspora* social network":
68         logger.debug("Setting diaspora: software='%s'", software)
69         software = "diaspora"
70     elif software == "tkz relay":
71         logger.debug("Setting aoderelay: software='%s'", software)
72         software = "aoderelay"
73     elif software == "gitdab":
74         logger.debug("Setting forgejo: software='%s'", software)
75         software = "forgejo"
76     elif software.find("/") > 0:
77         logger.warning("Spliting of slash: software='%s'", software)
78         software = software.split("/")[-1]
79     elif software.find("|") > 0:
80         logger.warning("Spliting of pipe: software='%s'", software)
81         software = software.split("|")[0]
82     elif "powered by" in software:
83         logger.debug("software='%s' has 'powered by' in it", software)
84         software = version.strip_powered_by(software)
85
86     if isinstance(software, str) and " by " in software:
87         logger.debug("software='%s' has ' by ' in it", software)
88         software = version.strip_until(software, " by ")
89     elif isinstance(software, str) and " - " in software:
90         logger.debug("software='%s' has ' - ' in it", software)
91         software = version.strip_until(software, " - ")
92     elif isinstance(software, str) and " see " in software:
93         logger.debug("software='%s' has ' see ' in it", software)
94         software = version.strip_until(software, " see ")
95
96     logger.debug("software['%s']='%s'", type(software), software)
97     if software == "":
98         logger.warning("tidyup.domain() left no software name behind: software='%s'", software)
99         software = None
100     else:
101         logger.debug("software='%s' is being cleaned up further ...")
102         software = software.rstrip("!")
103
104     logger.debug("software[%s]='%s' - EXIT!", type(software), software)
105     return software