lqg 1 year ago
parent
commit
39671f6ba9
3 changed files with 55 additions and 6 deletions
  1. 16 0
      crawl_alist.py
  2. 33 0
      gen_sql.py
  3. 6 6
      list.txt

+ 16 - 0
crawl_alist.py

@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8 -*-
+'''
+@Contact :   liuyuqi.gov@msn.cn
+@Time    :   2023/02/26 13:12:56
+@License :   Copyright © 2017-2022 liuyuqi. All Rights Reserved.
+@Desc    :   爬取alist
+'''
+
+class CrawlAlist(object):
+    
+    def __init__(self):
+        pass
+
+if __name__=='__main__':
+    pass

+ 33 - 0
gen_sql.py

@@ -0,0 +1,33 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8 -*-
+'''
+@Contact :   liuyuqi.gov@msn.cn
+@Time    :   2023/02/26 13:12:22
+@License :   Copyright © 2017-2022 liuyuqi. All Rights Reserved.
+@Desc    :   根据list.txt生成执行sql,然后导入sqlite实现批量导入系统
+前期检测list.txt各行是否有效,并维护这个列表
+'''
+
+import os,sys,re
+
+# 最新的id
+initId=65
+
+def gen(id:int, url:str):
+    '''生成sql'''
+    mount_path= url.split("//")[1].split(":")[0]
+    print("-----------------"+mount_path)
+    sql = "INSERT INTO \"main\".\"x_storages\" (\"id\", \"mount_path\", \"order\", \"driver\", \"cache_expiration\", \"status\", \"addition\", \"remark\", \"modified\", \"disabled\", \"order_by\", \"order_direction\", \"extract_folder\", \"web_proxy\", \"webdav_policy\", \"down_proxy_url\") VALUES (%s, '/NetDriverA/%s', 0, 'AList V3', 30, 'work', '{\"root_folder_path\":\"/\",\"url\":\"%s\",\"password\":\"\",\"access_token\":\"\"}', '%s', '2023-02-26 20:47:36.498219296+08:00', 0, '', '', '', 0, '302_redirect', '');"
+    sql=sql % (id, mount_path, url, url)
+    sql=sql.replace(r'\"','"')
+    with open('result.sql','a+',encoding='utf-8') as file:
+        file.write(sql+"\r\n")
+    
+if __name__=='__main__':
+    with open('list.txt','r',encoding='utf-8') as file:
+        lines = file.readlines()
+        for line in lines:
+            gen(initId, line)
+            initId=initId+1
+            # break
+        print("最后更新id为:"+str(initId))

+ 6 - 6
list.txt

@@ -3,7 +3,7 @@ https://110.41.3.238/
 http://49.66.187.13:8890/
 http://171.223.201.190:5678/
 http://124.221.89.31:9002/
-124.220.165.179:9002
+http://124.220.165.179:9002
 https://119.28.142.150/
 http://49.84.221.180:8887/
 http://220.191.96.215:5656/
@@ -45,10 +45,10 @@ http://116.230.162.219:8899/
 http://144.123.89.22:5678/
 https://193.111.31.4/
 https://193.111.30.116/
-14.118.210.102:9002
+http://14.118.210.102:9002
 http://221.9.78.46:8890/
 http://113.73.189.253:8088/
-180.108.20.198:9000
+http://180.108.20.198:9000
 http://125.90.254.107:5678/
 http://139.227.78.108:5555/
 http://119.91.201.196:8800/
@@ -64,7 +64,7 @@ http://43.138.88.231:5678/
 https://122.242.162.87:12345/
 http://118.120.249.3:8082/
 http://118.113.234.76:8082/
-140.237.242.22:8888
+http://140.237.242.22:8888
 http://27.154.215.196:8890/
 http://123.113.10.39:8890/
 http://123.123.30.52:8890/
@@ -75,11 +75,11 @@ http://123.118.6.209:8890/
 http://123.121.1.152:8890/
 https://119.8.46.228/
 https://119.3.6.116/
-115.227.211.69:1000
+http://115.227.211.69:1000
 http://101.34.67.237:5678/
 http://222.178.213.122:8088/
 http://39.152.41.90:5678/
-123.134.163.158:9001
+http://123.134.163.158:9001
 https://110.40.247.239/
 http://49.66.209.166:8890/
 http://49.65.90.190:8890/