mirror of
https://github.com/SouthFox-D/SouthFox-D.github.io.git
synced 2024-11-25 08:26:51 +01:00
utils: ipfs changes
This commit is contained in:
parent
b72826dbd3
commit
6f14782528
1 changed files with 8 additions and 7 deletions
13
utils.py
13
utils.py
|
@ -104,8 +104,11 @@ def backupImg():
|
||||||
result = re.findall('!\[(.*?)\]\((.*?)\)', mdText)
|
result = re.findall('!\[(.*?)\]\((.*?)\)', mdText)
|
||||||
|
|
||||||
for i in range(len(result)):
|
for i in range(len(result)):
|
||||||
img_quote = result[i][0]
|
#img_quote = result[i][0]
|
||||||
img_url = result[i][1]
|
img_url = result[i][1]
|
||||||
|
if 'ipfs' in img_url:
|
||||||
|
urlname = img_url.split(u"/")
|
||||||
|
img_url = str(urlname[-1])
|
||||||
nowImgList.append(img_url)
|
nowImgList.append(img_url)
|
||||||
|
|
||||||
downLoadList = list(set(nowImgList).difference((set(imgJson["img"]))))
|
downLoadList = list(set(nowImgList).difference((set(imgJson["img"]))))
|
||||||
|
@ -127,15 +130,13 @@ def backupImg():
|
||||||
|
|
||||||
|
|
||||||
def downloadImg(imgList):
|
def downloadImg(imgList):
|
||||||
|
ipfs_gateWay = ['https://cf-ipfs.com/ipfs/', 'https://ipfs.io/ipfs/', 'https://dweb.link/ipfs/']
|
||||||
for img_url in imgList:
|
for img_url in imgList:
|
||||||
# img name spell
|
img_name = img_url
|
||||||
urlname = img_url.split(u"/")
|
|
||||||
img_name = str(urlname[-1])
|
|
||||||
if img_url == "":
|
if img_url == "":
|
||||||
continue
|
continue
|
||||||
# download img
|
# download img
|
||||||
ipfs_gateWay = ['https://cf-ipfs.com/ipfs/', 'https://ipfs.io/ipfs/', 'https://dweb.link/ipfs/']
|
if 'https' not in img_url:
|
||||||
if 'ipfs' in img_url:
|
|
||||||
img_url = random.choice(ipfs_gateWay) + img_name
|
img_url = random.choice(ipfs_gateWay) + img_name
|
||||||
|
|
||||||
response = requests.get(img_url)
|
response = requests.get(img_url)
|
||||||
|
|
Loading…
Reference in a new issue