Skip to content

Commit

Permalink
Add new mirrors column
Browse files Browse the repository at this point in the history
  • Loading branch information
syeopite committed Aug 12, 2021
1 parent 48404d3 commit b3bb76a
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 40 deletions.
51 changes: 25 additions & 26 deletions instances.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ instances:
# source:
# notes:
# _ Hi I am an example!
# mirrors: # Mirrors should follow a reduced syntax of the base instance
# - url: https://us.example.com
# - country: US
#
# *Image attribute in status has higher prioirty than text. Thus, if this attribute is filled out
# The text attribute would only be used as a fallback.
Expand All @@ -49,6 +52,7 @@ instances:
is_modified:
source:
notes:
mirrors:

- url: https://yewtu.be
country: FR
Expand All @@ -62,6 +66,7 @@ instances:
is_modified:
source:
notes:
mirrors:

- url: https://invidious.kavin.rocks
country: IN
Expand All @@ -75,32 +80,12 @@ instances:
is_modified:
source:
notes:
mirrors:
- url: https://invidious-us.kavin.rocks
country: US

- url: https://invidious-us.kavin.rocks
country: US
status:
url: https://status.kavin.rocks/788216947
image: https://img.shields.io/uptimerobot/status/m788216947-f3f63d30899a10dbe9a0338a
text: Uptime Robot status
privacy_policy:
ddos_mitm_protection: Cloudflare
owner: https://github.com/FireMasterK
is_modified:
source:
notes:

- url: https://invidious-jp.kavin.rocks
country: JP
status:
url: https://status.kavin.rocks/788866642
image: https://img.shields.io/uptimerobot/status/m788866642-8a4478b8853722e98b7634e9
text: Uptime Robot status
privacy_policy:
ddos_mitm_protection: Cloudflare
owner: https://github.com/FireMasterK
is_modified:
source:
notes:
- url: https://invidious-jp.kavin.rocks
country: JP

- url: https://vid.puffyan.us
country: US
Expand All @@ -114,6 +99,7 @@ instances:
is_modified:
source:
notes:
mirrors:

- url: https://ytprivate.com
country: US
Expand All @@ -127,6 +113,7 @@ instances:
is_modified: true
source: https://github.com/ytprivatecom/invidious
notes:
mirrors:

- url: https://invidious.namazso.eu
country: DE
Expand All @@ -137,6 +124,7 @@ instances:
is_modified:
source:
notes:
mirrors:

- url: https://invidious.silkky.cloud
country: FI
Expand All @@ -151,6 +139,7 @@ instances:
source:
notes:
- "[Uses anti-bot protection](https://github.com/bunkerity/bunkerized-nginx)"
mirrors:

- url: https://invidious.exonip.de
country: DE
Expand All @@ -164,6 +153,7 @@ instances:
source: https://github.com/exonip-de/invidious-source-modifications
notes:
- "[Uses anti-bot protection](https://github.com/bunkerity/bunkerized-nginx)"
mirrors:

- url: https://inv.riverside.rocks
country: US
Expand All @@ -174,6 +164,7 @@ instances:
is_modified:
source:
notes:
mirrors:

- url: https://invidious.blamefran.net
country: US
Expand All @@ -184,6 +175,7 @@ instances:
is_modified:
source:
notes:
mirrors:

- url: https://ytb.trom.tf
country: DE
Expand All @@ -194,6 +186,7 @@ instances:
is_modified: True
source: https://gitlab.com/TioTrom/trom.tf-invidious
notes:
mirrors:

- url: https://y.com.cm/
country: DE
Expand All @@ -204,6 +197,7 @@ instances:
is_modified:
source:
notes:
mirrors:

- url: https://invidious.s1gm4.eu
country: FR
Expand All @@ -216,7 +210,8 @@ instances:
is_modified:
source:
notes:

mirrors:

- url: https://invidious.hub.ne.kr
country: SG
status:
Expand All @@ -226,6 +221,7 @@ instances:
is_modified:
source:
notes:
mirrors:

- url: https://invidious.noho.st
country: GB
Expand All @@ -239,6 +235,7 @@ instances:
is_modified:
source:
notes:
mirrors:

- url: https://invidio.xamh.de
country: DE
Expand All @@ -252,6 +249,7 @@ instances:
is_modified:
source:
notes:
mirrors:

- url: https://youtube.076.ne.jp
country: JP
Expand All @@ -262,6 +260,7 @@ instances:
is_modified: True
source: https://git.076.ne.jp/TechnicalSuwako/invidious-mod
notes:
mirrors:


onion:
Expand Down
45 changes: 31 additions & 14 deletions src/create-instance-md.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,33 @@ def route(self, name):
"privacy_policy": self._create_privacy_policy_column,
"ddos_mitm_protection": self.ddos_protection,
"owner": self._create_owner_column,
"notes": self._create_notes_column
"notes": self._create_notes_column,
"mirrors": self._create_mirror_column
}

return router[name]

@staticmethod
def get_country_name_and_flag_from_code(code):
name = pycountry.countries.get(alpha_2=code).name
# https://stackoverflow.com/a/42235254
flag = (lambda s, e: chr(ord(s.upper()) - 0x41 + 0x1F1E6) +
chr(ord(e.upper()) - 0x41 + 0x1F1E6))(*list(code))

return name, flag


@staticmethod
def _create_url_column(url):
if not url:
return ""

hostname = urlparse(url).hostname
return f"[{hostname}]({url})"
return f"<a title='{hostname}' src='{url}'>{hostname[:35]}</a>"

@staticmethod
def _create_country_column(country_code):
country_name = pycountry.countries.get(alpha_2=country_code).name
# https://stackoverflow.com/a/42235254
flag = (lambda s, e: chr(ord(s.upper()) - 0x41 + 0x1F1E6) +
chr(ord(e.upper()) - 0x41 + 0x1F1E6)
)(*list(country_code))

return f"{flag} {country_name}"
def _create_country_column(self, country_code, mirrors=None):
main_name, main_flag = self.get_country_name_and_flag_from_code(country_code)
return f"{main_name} {main_flag}"

@staticmethod
def _create_status_column(status_dict):
Expand Down Expand Up @@ -84,10 +89,21 @@ def _create_notes_column(notes, is_modified, source):
notes_list.append(f" - [Instance is running a modified source code]({source})")
if notes:
[notes_list.append(f" - {note}") for note in notes]


return '<br/>'.join(notes_list)

def _create_mirror_column(self, mirrors):
if not mirrors:
return ""

country_column = []

for mirror in mirrors:
name, flag = self.get_country_name_and_flag_from_code(mirror["country"])
country_column.append(f"[{name} {flag}]({mirror['url']})")

return "<br/>".join(country_column)


class MDInstanceListBuilder:
def __init__(self, instance_list_config):
Expand All @@ -103,11 +119,11 @@ def _generate_heading(self):
def _create_instance_tables(self):
# HTTPS
self.md.new_header(level=1, title='Instances list')
rows = ["Address", "Country", "Status", "Privacy policy", "DDos Protection / MITM", "Owner", "Notes"]
rows = ["Address", "Country", "Mirrors", "Status", "Privacy policy", "DDos Protection / MITM", "Owner", "Notes"]
for instance in self.config["instances"]["https"]:
rows.extend(self._create_http_row(instance))

self.md.new_table(columns=7, rows=len(self.config["instances"]["https"]) + 1, text=rows, text_align='center')
self.md.new_table(columns=8, rows=len(self.config["instances"]["https"]) + 1, text=rows, text_align='center')

self.md.new_line()

Expand All @@ -132,6 +148,7 @@ def _create_http_row(self, instance):
return [
self.builder.route("url")(instance["url"]),
self.builder.route("country")(instance["country"]),
self.builder.route("mirrors")(instance["mirrors"]),
self.builder.route("status")(instance["status"]),
self.builder.route("privacy_policy")(instance["privacy_policy"]),
self.builder.route("ddos_mitm_protection")(instance["ddos_mitm_protection"]),
Expand Down

0 comments on commit b3bb76a

Please sign in to comment.