Created
September 4, 2019 17:50
-
-
Save enihsyou/9dbcc8df273e7a7ae24cc0795f561438 to your computer and use it in GitHub Desktop.
为梅林固件科学上网插件适配 N3RO 的 SIP002 URIs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from urllib.request import urlopen | |
from urllib.parse import unquote | |
import base64 | |
import re | |
n3ro_rss_link = input("N3RO SIP002 URIs: ").strip() | |
data = urlopen(n3ro_rss_link).read() | |
links = base64.b64decode(data).decode() | |
for link in links.splitlines(): | |
matcher = re.match(r"ss://(.+)@(.+)#(.+)", link) | |
a = base64.b64decode(matcher.group(1)).decode() | |
b = matcher.group(2) | |
c = unquote(matcher.group(3)) | |
ss_link = base64.b64encode((a + '@' + b).encode()).decode() | |
remark = c[:c.index('#')].replace(' ', '') | |
print('ss://' + ss_link + '#' + remark) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment