Merge pull request #465 from Daniel-Valentine/fix/460
(#460) get Libreddit instances from libbacon/libreddit-instances
This commit is contained in:
commit
5d74d475bd
|
@ -238,21 +238,30 @@ def bibliogram():
|
||||||
|
|
||||||
def libreddit():
|
def libreddit():
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
'https://raw.githubusercontent.com/spikecodes/libreddit/master/README.md')
|
'https://github.com/libbacon/libreddit-instances/raw/master/instances.json')
|
||||||
|
rJson = json.loads(r.text)
|
||||||
libredditList = {}
|
libredditList = {}
|
||||||
libredditList['normal'] = []
|
libredditList['normal'] = []
|
||||||
libredditList['tor'] = []
|
libredditList['tor'] = []
|
||||||
libredditList['i2p'] = []
|
libredditList['i2p'] = []
|
||||||
libredditList['loki'] = []
|
libredditList['loki'] = []
|
||||||
|
|
||||||
tmp = re.findall(
|
if 'instances' not in rJson:
|
||||||
r"\| \[.*\]\(([-a-zA-Z0-9@:%_\+.~#?&//=]{2,}\.[a-z]{2,}\b(?:\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?)\)*\|*[A-Z]{0,}.*\|.*\|", r.text)
|
mightyList['libreddit'] = libredditList
|
||||||
|
print(Fore.RED + 'Failed to fetch ' + Style.RESET_ALL + 'LibReddit')
|
||||||
|
return
|
||||||
|
|
||||||
|
for item in rJson['instances']:
|
||||||
|
if 'url' in item:
|
||||||
|
url = item['url']
|
||||||
|
libredditList['normal'].append(url)
|
||||||
|
elif 'onion' in item:
|
||||||
|
onion = item['onion']
|
||||||
|
libredditList['tor'].append(onion)
|
||||||
|
elif 'i2p' in item:
|
||||||
|
i2p = item['i2p']
|
||||||
|
libredditList['i2p'].append(i2p)
|
||||||
|
|
||||||
for item in tmp:
|
|
||||||
if re.search(torRegex, item):
|
|
||||||
libredditList['tor'].append(item)
|
|
||||||
else:
|
|
||||||
libredditList['normal'].append(item)
|
|
||||||
mightyList['libreddit'] = libredditList
|
mightyList['libreddit'] = libredditList
|
||||||
print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'LibReddit')
|
print(Fore.GREEN + 'Fetched ' + Style.RESET_ALL + 'LibReddit')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue