markdown-img-icexmoon 0.3.9__tar.gz → 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/PKG-INFO +30 -2
  2. markdown-img-icexmoon-0.3.9/src/markdown_img_icexmoon.egg-info/PKG-INFO → markdown_img_icexmoon-1.0.0/README.md +21 -15
  3. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/setup.cfg +1 -1
  4. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/config.py +5 -1
  5. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/globalization.py +6 -0
  6. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/help.info +1 -0
  7. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/help_en.info +1 -0
  8. markdown_img_icexmoon-1.0.0/src/markdown_img/img_service/fz_img_service.py +107 -0
  9. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/img_service_manager.py +5 -1
  10. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/main.py +2 -1
  11. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/smms_img.py +4 -0
  12. markdown-img-icexmoon-0.3.9/README.md → markdown_img_icexmoon-1.0.0/src/markdown_img_icexmoon.egg-info/PKG-INFO +44 -1
  13. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img_icexmoon.egg-info/SOURCES.txt +3 -1
  14. markdown_img_icexmoon-1.0.0/tests/test.py +12 -0
  15. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/LICENSE +0 -0
  16. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/pyproject.toml +0 -0
  17. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/setup.py +0 -0
  18. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/__init__.py +0 -0
  19. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/__main__.py +0 -0
  20. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/compress/__init__.py +0 -0
  21. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/compress/compress.py +0 -0
  22. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/compress/compress_manager.py +0 -0
  23. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/compress/compress_service.py +0 -0
  24. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/compress/none_compress_service.py +0 -0
  25. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/compress/pillow_compress_service.py +0 -0
  26. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/compress/tinypng_compress_service.py +0 -0
  27. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/config_backup.py +0 -0
  28. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/download_help.py +0 -0
  29. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/img_service/Upyun_img_service.py +0 -0
  30. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/img_service/__init__.py +0 -0
  31. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/img_service/bilibili_img_service.py +0 -0
  32. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/img_service/img_service.py +0 -0
  33. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/img_service/none_img_service.py +0 -0
  34. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/img_service/qcloud_img_service.py +0 -0
  35. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/img_service/qiniu_img_service.py +0 -0
  36. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/img_service/smms_img_service.py +0 -0
  37. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/img_service/vimcn_img_service.py +0 -0
  38. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/img_service/yujian_img_service.py +0 -0
  39. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/qcloud_client.py +0 -0
  40. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/qiniu_client.py +0 -0
  41. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/time_helper.py +0 -0
  42. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/tools/__init__.py +0 -0
  43. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/tools/debug.py +0 -0
  44. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/tools/file_tools.py +0 -0
  45. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/tools/my_time.py +0 -0
  46. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img/user_exception.py +0 -0
  47. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img_icexmoon.egg-info/dependency_links.txt +0 -0
  48. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img_icexmoon.egg-info/entry_points.txt +0 -0
  49. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img_icexmoon.egg-info/requires.txt +0 -0
  50. {markdown-img-icexmoon-0.3.9 → markdown_img_icexmoon-1.0.0}/src/markdown_img_icexmoon.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: markdown-img-icexmoon
3
- Version: 0.3.9
3
+ Version: 1.0.0
4
4
  Summary: A program for find and upload images in markdown file and will replace them.
5
5
  Home-page: https://github.com/icexmoon/markdown-img
6
6
  Author: icexmoon
@@ -12,6 +12,13 @@ Classifier: Operating System :: OS Independent
12
12
  Requires-Python: >=3.6
13
13
  Description-Content-Type: text/markdown
14
14
  License-File: LICENSE
15
+ Requires-Dist: requests
16
+ Requires-Dist: cos-python-sdk-v5
17
+ Requires-Dist: qiniu
18
+ Requires-Dist: upyun
19
+ Requires-Dist: Pillow
20
+ Requires-Dist: tinify
21
+ Dynamic: license-file
15
22
 
16
23
  # Markdown-img User's Guide
17
24
 
@@ -35,6 +42,10 @@ English | [**简体中文**](https://github.com/icexmoon/markdown-img/blob/maste
35
42
  - [**Update the image bed acess token**](https://github.com/icexmoon/markdown-img#update-the-image-bed-access-token)
36
43
  - [**Scan images and create indexes**](https://github.com/icexmoon/markdown-img#scan-images-and-create-indexes)
37
44
  - [**Refreshing a copy of the image bed**](https://github.com/icexmoon/markdown-img#refreshing-a-copy-of-the-image-bed)
45
+ - [**Backing up the system configuration**](https://github.com/icexmoon/markdown-img#backing-up-the-system-configuration)
46
+ - [**List saved configurations**](https://github.com/icexmoon/markdown-img#list-saved-configurations)
47
+ - [**Replacing configurations**](https://github.com/icexmoon/markdown-img#replacing-configurations)
48
+ - [**Relative path image**](https://github.com/icexmoon/markdown-img#relative-path-image)
38
49
  - [**Acknowledgements**](https://github.com/icexmoon/markdown-img#acknowledgements)
39
50
  - [**Update Log**](https://github.com/icexmoon/markdown-img#update-log)
40
51
 
@@ -240,6 +251,19 @@ pymdimg --change_config xxx
240
251
 
241
252
  where `xxx` is the file name of the saved configuration you want to replace. To see what saved configurations are available, please use [Function: List saved configurations]. In addition, it is better to save the current configuration before using this function.
242
253
 
254
+ ### Relative path image
255
+
256
+ You can process the MD file using absolute path pictures to use relative path pictures, and the program will copy the original pictures to the images subdirectory of the current directory as relative path pictures.
257
+
258
+ The purpose of this function is to provide convenience for some cross-platform, multi-device users, using relative paths, raw images and MD files can be easily moved, or using a synchronization service similar to Nut Cloud for multi-device synchronization.
259
+
260
+ ```shell
261
+ pymdimg -m relative_img
262
+ ```
263
+
264
+ > - In order to avoid the corruption of the original MD file caused by program errors, one original file will be kept and backed up in the backup subdirectory.
265
+ > - Because of the difference between Windows and Linux platform separators, there is no guarantee that the relative directories of both will behave properly.
266
+
243
267
 
244
268
  ## Acknowledgements
245
269
 
@@ -296,3 +320,7 @@ Fix the bug that can't create img dir normally in Linux.
296
320
  ### 0.3.9
297
321
 
298
322
  Added the function to modify the absolute path image in the MD file to relative path.
323
+
324
+ ### 0.4.0
325
+
326
+ Added the support to fengzhen image bed.
@@ -1,18 +1,3 @@
1
- Metadata-Version: 2.1
2
- Name: markdown-img-icexmoon
3
- Version: 0.3.9
4
- Summary: A program for find and upload images in markdown file and will replace them.
5
- Home-page: https://github.com/icexmoon/markdown-img
6
- Author: icexmoon
7
- Author-email: icexmoon@qq.com
8
- Project-URL: Bug Tracker, https://github.com/icexmoon/markdown-img/issues
9
- Classifier: Programming Language :: Python :: 3
10
- Classifier: License :: OSI Approved :: MIT License
11
- Classifier: Operating System :: OS Independent
12
- Requires-Python: >=3.6
13
- Description-Content-Type: text/markdown
14
- License-File: LICENSE
15
-
16
1
  # Markdown-img User's Guide
17
2
 
18
3
  English | [**简体中文**](https://github.com/icexmoon/markdown-img/blob/master/README_cn.md)
@@ -35,6 +20,10 @@ English | [**简体中文**](https://github.com/icexmoon/markdown-img/blob/maste
35
20
  - [**Update the image bed acess token**](https://github.com/icexmoon/markdown-img#update-the-image-bed-access-token)
36
21
  - [**Scan images and create indexes**](https://github.com/icexmoon/markdown-img#scan-images-and-create-indexes)
37
22
  - [**Refreshing a copy of the image bed**](https://github.com/icexmoon/markdown-img#refreshing-a-copy-of-the-image-bed)
23
+ - [**Backing up the system configuration**](https://github.com/icexmoon/markdown-img#backing-up-the-system-configuration)
24
+ - [**List saved configurations**](https://github.com/icexmoon/markdown-img#list-saved-configurations)
25
+ - [**Replacing configurations**](https://github.com/icexmoon/markdown-img#replacing-configurations)
26
+ - [**Relative path image**](https://github.com/icexmoon/markdown-img#relative-path-image)
38
27
  - [**Acknowledgements**](https://github.com/icexmoon/markdown-img#acknowledgements)
39
28
  - [**Update Log**](https://github.com/icexmoon/markdown-img#update-log)
40
29
 
@@ -240,6 +229,19 @@ pymdimg --change_config xxx
240
229
 
241
230
  where `xxx` is the file name of the saved configuration you want to replace. To see what saved configurations are available, please use [Function: List saved configurations]. In addition, it is better to save the current configuration before using this function.
242
231
 
232
+ ### Relative path image
233
+
234
+ You can process the MD file using absolute path pictures to use relative path pictures, and the program will copy the original pictures to the images subdirectory of the current directory as relative path pictures.
235
+
236
+ The purpose of this function is to provide convenience for some cross-platform, multi-device users, using relative paths, raw images and MD files can be easily moved, or using a synchronization service similar to Nut Cloud for multi-device synchronization.
237
+
238
+ ```shell
239
+ pymdimg -m relative_img
240
+ ```
241
+
242
+ > - In order to avoid the corruption of the original MD file caused by program errors, one original file will be kept and backed up in the backup subdirectory.
243
+ > - Because of the difference between Windows and Linux platform separators, there is no guarantee that the relative directories of both will behave properly.
244
+
243
245
 
244
246
  ## Acknowledgements
245
247
 
@@ -296,3 +298,7 @@ Fix the bug that can't create img dir normally in Linux.
296
298
  ### 0.3.9
297
299
 
298
300
  Added the function to modify the absolute path image in the MD file to relative path.
301
+
302
+ ### 0.4.0
303
+
304
+ Added the support to fengzhen image bed.
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = markdown-img-icexmoon
3
- version = 0.3.9
3
+ version = 1.0.0
4
4
  author = icexmoon
5
5
  author_email = icexmoon@qq.com
6
6
  description = A program for find and upload images in markdown file and will replace them.
@@ -16,6 +16,7 @@ class Config():
16
16
  PARAM_QCLOUD_INFO = 'qcloud_info'
17
17
  PARAM_QINIU_INFO = "qiniu_info"
18
18
  PARAM_UPYUN_INFO = "upyun_info"
19
+ PARAM_FZ_INFO = "fz_info"
19
20
  PARAM_URL_ENCODE_MODE = 'url_encode_mode'
20
21
  PARAM_LANGUAGE = 'language'
21
22
  PARAM_COMPRESS = "compress"
@@ -42,6 +43,8 @@ class Config():
42
43
  UPYUN_INFO_PASSWORD = "password"
43
44
  UPYUN_INFO_DIR = "dir"
44
45
  UPYUN_INFO_DOMAIN = "domain"
46
+ FZ_INFO_PHONE = 'phone'
47
+ FZ_INFO_PWD = 'pwd'
45
48
  IMG_SERVICE_YUJIAN = 'yujian'
46
49
  IMG_SERVICE_SMMS = 'smms'
47
50
  IMG_SERVICE_RRUU = 'rruu'
@@ -61,6 +64,7 @@ class Config():
61
64
  IMG_SERVICE_BKIMG = "bkimg"
62
65
  IMG_SERVICE_MUKE = "muke"
63
66
  IMG_SERVICE_UPYUN = "upyun"
67
+ IMG_SERVICE_FZ = "fz"
64
68
  # 图片压缩相关配置
65
69
  COMPRESS_INFO_STATUS = "status"
66
70
  COMPRESS_INFO_LIMIT = "limit"
@@ -255,7 +259,7 @@ class Config():
255
259
  if info == '':
256
260
  raise UserException(UserException.CODE_NO_QINIU_INFO)
257
261
  return info
258
-
262
+
259
263
  def writeSmmsToken(self, token: str):
260
264
  with open(file=self.getSmmsTokenFile(), mode='w') as configFileOpen:
261
265
  print(token, file=configFileOpen)
@@ -49,6 +49,9 @@ class Globalization:
49
49
  "image_web_configs_changed": "图床配置已更新",
50
50
  "input_error_and_hint": "输入的值{}不合法,请阅读帮助文档。",
51
51
  "related_configs_changed": "相关配置已更新",
52
+ "fz_info_required": "缺少风筝图床相关配置,请输入",
53
+ "fz_info_phone":"手机号",
54
+ "fz_info_pwd":"密码",
52
55
  "qiniu_info_saved": "七牛云的相关信息已保存,请重新运行程序",
53
56
  "qiniu_info_required": "缺少七牛云的相关配置,请按提示输入",
54
57
  "qiniu_access_key_input": "请输入七牛云存储的access_key",
@@ -195,6 +198,9 @@ class Globalization:
195
198
  "current_operation_success": "Current operation executed successfully",
196
199
  "config_name": "Config name",
197
200
  "create_time": "Create time",
201
+ "fz_info_required": "Requre FZ image bed config, please enter",
202
+ "fz_info_phone":"phone",
203
+ "fz_info_pwd":"password",
198
204
  }
199
205
 
200
206
  def __new__(cls) -> Any:
@@ -18,6 +18,7 @@
18
18
  qcloud 腾讯云对象存储(需要提供必要连接信息)
19
19
  qiniu 七牛云(需要提供必要连接信息)
20
20
  upyun 又拍云(需要提供必要连接信息)
21
+ fz 风筝图床(需要提供必要的连接信息)
21
22
  bilibili,sougou,huluxia,catbox,360,postimages,ai58,gtimg,bkimg,muke
22
23
  -c --change_token 替换图床访问令牌
23
24
  this 当前图床
@@ -18,6 +18,7 @@
18
18
  qcloud Tencent Cloud Object Storage (required to provide necessary connection information)
19
19
  qiniu Qiniu Cloud (required to provide necessary connection information)
20
20
  upyun UPYun Cloud (required to provide necessary connection information)
21
+ fz fengzhen image bed (required to provide necessary connection information)
21
22
  bilibili,sougou,huluxia,catbox,360,postimages,ai58,gtimg,bkimg,muke
22
23
  -c --change_token Replace the image bed access token.
23
24
  this current image bed.
@@ -0,0 +1,107 @@
1
+ from .img_service import ImgService
2
+ import requests
3
+ from ..config import Config
4
+ from ..user_exception import UserException
5
+ import json
6
+ from typing import Any
7
+
8
+
9
+ class FzImgService(ImgService):
10
+ '''风筝图床'''
11
+
12
+ def __init__(self) -> None:
13
+ super().__init__()
14
+ self.sysConfig = Config.getInstance()
15
+
16
+ def __getToken(self):
17
+ if hasattr(self, "__token"):
18
+ return self.__token
19
+ phone = self.__getInfo('phone')
20
+ pwd = self.__getInfo('pwd')
21
+ self.__token = self.__login(phone, pwd)
22
+ return self.__token
23
+
24
+ def __login(self, phone: str, pwd: str) -> str:
25
+ '''登录并获取token'''
26
+ r = requests.post('https://imgbed.link/imgbed/user/login',
27
+ data={'phoneNum': phone, 'pwd': pwd})
28
+ try:
29
+ respJson = r.json()
30
+ except json.decoder.JSONDecodeError as e:
31
+ self.sysConfig.writeErrorLog("接口解析错误:"+str(e)+"\n返回信息:"+r.text)
32
+ raise UserException(UserException.CODE_UPLOAD_ERROR)
33
+ except Exception as e:
34
+ self.sysConfig.writeErrorLog("未知的接口调用错误:"+str(e))
35
+ raise UserException(UserException.CODE_UPLOAD_ERROR)
36
+ if respJson['code'] != 0:
37
+ raise UserException(
38
+ UserException.CODE_UPLOAD_ERROR, '接口调用出错:'+respJson['msg'])
39
+ return respJson['token']
40
+
41
+ def __getInfo(self, key: str) -> Any:
42
+ info = self.getConfigInfo()
43
+ if key in info:
44
+ return info[key]
45
+ raise UserException(UserException.CODE_OTHER, '缺少图床配置:'+key)
46
+
47
+ def getConfigInfo(self) -> dict:
48
+ sysConfig = Config.getInstance()
49
+ info = sysConfig.getConfigParam(Config.PARAM_FZ_INFO)
50
+ if info == '':
51
+ raise UserException(UserException.CODE_NO_IMG_SERVICE_CONFIG)
52
+ return info
53
+
54
+ def upload(self, localImg: str) -> str:
55
+ url = "https://imgbed.link/imgbed/file/upload"
56
+ payload = {}
57
+ imgOpen = open(localImg, 'rb')
58
+ files = {'file': imgOpen}
59
+ headers = {
60
+ 'User-Agent': 'Apifox/1.0.0 (https://www.apifox.cn)',
61
+ 'token': self.__getToken()
62
+ }
63
+
64
+ r = requests.request("POST", url, headers=headers,
65
+ data=payload, files=files)
66
+ imgOpen.close()
67
+ try:
68
+ respJson = r.json()
69
+ except json.decoder.JSONDecodeError as e:
70
+ self.sysConfig.writeErrorLog("接口解析错误:"+str(e)+"\n返回信息:"+r.text)
71
+ raise UserException(UserException.CODE_UPLOAD_ERROR)
72
+ except Exception as e:
73
+ self.sysConfig.writeErrorLog("未知的接口调用错误:"+str(e))
74
+ raise UserException(UserException.CODE_UPLOAD_ERROR)
75
+ return respJson['rows'][0]['url']
76
+
77
+ def inputConfig(self) -> None:
78
+ info = {}
79
+ print(self.globalization.getTextWithColon("fz_info_required"))
80
+ info[Config.FZ_INFO_PHONE] = input(
81
+ self.globalization.getTextWithColon("fz_info_phone"))
82
+ info[Config.FZ_INFO_PWD] = input(
83
+ self.globalization.getTextWithColon("fz_info_pwd"))
84
+ sysConfig = self.sysConfig
85
+ sysConfig.setConfigParam(Config.PARAM_FZ_INFO, info)
86
+ sysConfig.writeMainConfig()
87
+ print(self.globalization.getText("config_info_saved"))
88
+
89
+ def inputNewConfig(self) -> None:
90
+ info = {}
91
+ info[Config.FZ_INFO_PHONE] = input(
92
+ self.globalization.getTextWithColon("fz_info_phone"))
93
+ info[Config.FZ_INFO_PWD] = input(
94
+ self.globalization.getTextWithColon("fz_info_pwd"))
95
+ sysConfig = self.sysConfig
96
+ sysConfig.setConfigParam(Config.PARAM_FZ_INFO, info)
97
+ sysConfig.writeMainConfig()
98
+ print(self.globalization.getText("config_info_saved"))
99
+
100
+ def getConfigInfoText(self) -> tuple:
101
+ lines = list()
102
+ info = self.getConfigInfo()
103
+ lines.append(self.globalization.getTextWithParam(
104
+ "fz_info_phone", info[Config.FZ_INFO_PHONE]))
105
+ lines.append(self.globalization.getTextWithParam(
106
+ "fz_info_pwd", info[Config.FZ_INFO_PWD]))
107
+ return tuple(lines)
@@ -7,6 +7,7 @@ from .img_service.qcloud_img_service import QcloudImgService
7
7
  from .img_service.qiniu_img_service import QiniuImgService
8
8
  from .img_service.smms_img_service import SmmsImgService
9
9
  from .img_service.Upyun_img_service import UpyunImgService
10
+ from .img_service.fz_img_service import FzImgService
10
11
 
11
12
 
12
13
  class ImgServiceManager:
@@ -72,6 +73,8 @@ class ImgServiceManager:
72
73
  webImage = YujianImgService(YujianImgService.API_TYPE_MUKE)
73
74
  elif imgService == Config.IMG_SERVICE_UPYUN:
74
75
  webImage = UpyunImgService()
76
+ elif imgService == Config.IMG_SERVICE_FZ:
77
+ webImage = FzImgService()
75
78
  else:
76
79
  webImage = SmmsImgService()
77
80
  return webImage
@@ -86,7 +89,8 @@ class ImgServiceManager:
86
89
  Config.IMG_SERVICE_QCLOUD, Config.IMG_SERVICE_QINIU, Config.IMG_SERVICE_BILIBILI,
87
90
  Config.IMG_SERVICE_SOUGOU, Config.IMG_SERVICE_HULUXIA, Config.IMG_SERVICE_CATBOX,
88
91
  Config.IMG_SERVICE_360, Config.IMG_SERVICE_POSTIMAGES, Config.IMG_SERVICE_AI58,
89
- Config.IMG_SERVICE_GTIMG, Config.IMG_SERVICE_BKIMG, Config.IMG_SERVICE_MUKE, Config.IMG_SERVICE_UPYUN}
92
+ Config.IMG_SERVICE_GTIMG, Config.IMG_SERVICE_BKIMG, Config.IMG_SERVICE_MUKE, Config.IMG_SERVICE_UPYUN,
93
+ Config.IMG_SERVICE_FZ}
90
94
  if flag in supportedService:
91
95
  return True
92
96
  return False
@@ -152,7 +152,8 @@ class Main():
152
152
  shutil.copyfile(localImg, relativeLocalImage)
153
153
  # 替换图片路径为相对路径
154
154
  line = line.replace(
155
- localImg, "."+sysConfig.getPathSplit()+"images"+sysConfig.getPathSplit()+imgName)
155
+ # 改为使用/而非\
156
+ localImg, "."+"/"+"images"+"/"+imgName)
156
157
  copyFileOpen.write(line)
157
158
  copyFileOpen.close()
158
159
  # 保存原始文件备份
@@ -39,6 +39,10 @@ class SmmsImg():
39
39
  images[MAX_SAME_TIME_DEAL:len(images)], results)
40
40
 
41
41
  def uploadOne(self, localImg):
42
+ # 如果是 gif 而非静态图片,不压缩
43
+ if (localImg.endswith(".gif")):
44
+ imgService = ImgServiceManager.getImgService()
45
+ return imgService.upload(localImg)
42
46
  # 如果设置了压缩选项,进行压缩
43
47
  info = self.sysConfig.getCompressInfo()
44
48
  if(info[Config.COMPRESS_INFO_STATUS] == "on"):
@@ -1,3 +1,25 @@
1
+ Metadata-Version: 2.4
2
+ Name: markdown-img-icexmoon
3
+ Version: 1.0.0
4
+ Summary: A program for find and upload images in markdown file and will replace them.
5
+ Home-page: https://github.com/icexmoon/markdown-img
6
+ Author: icexmoon
7
+ Author-email: icexmoon@qq.com
8
+ Project-URL: Bug Tracker, https://github.com/icexmoon/markdown-img/issues
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.6
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: requests
16
+ Requires-Dist: cos-python-sdk-v5
17
+ Requires-Dist: qiniu
18
+ Requires-Dist: upyun
19
+ Requires-Dist: Pillow
20
+ Requires-Dist: tinify
21
+ Dynamic: license-file
22
+
1
23
  # Markdown-img User's Guide
2
24
 
3
25
  English | [**简体中文**](https://github.com/icexmoon/markdown-img/blob/master/README_cn.md)
@@ -20,6 +42,10 @@ English | [**简体中文**](https://github.com/icexmoon/markdown-img/blob/maste
20
42
  - [**Update the image bed acess token**](https://github.com/icexmoon/markdown-img#update-the-image-bed-access-token)
21
43
  - [**Scan images and create indexes**](https://github.com/icexmoon/markdown-img#scan-images-and-create-indexes)
22
44
  - [**Refreshing a copy of the image bed**](https://github.com/icexmoon/markdown-img#refreshing-a-copy-of-the-image-bed)
45
+ - [**Backing up the system configuration**](https://github.com/icexmoon/markdown-img#backing-up-the-system-configuration)
46
+ - [**List saved configurations**](https://github.com/icexmoon/markdown-img#list-saved-configurations)
47
+ - [**Replacing configurations**](https://github.com/icexmoon/markdown-img#replacing-configurations)
48
+ - [**Relative path image**](https://github.com/icexmoon/markdown-img#relative-path-image)
23
49
  - [**Acknowledgements**](https://github.com/icexmoon/markdown-img#acknowledgements)
24
50
  - [**Update Log**](https://github.com/icexmoon/markdown-img#update-log)
25
51
 
@@ -225,6 +251,19 @@ pymdimg --change_config xxx
225
251
 
226
252
  where `xxx` is the file name of the saved configuration you want to replace. To see what saved configurations are available, please use [Function: List saved configurations]. In addition, it is better to save the current configuration before using this function.
227
253
 
254
+ ### Relative path image
255
+
256
+ You can process the MD file using absolute path pictures to use relative path pictures, and the program will copy the original pictures to the images subdirectory of the current directory as relative path pictures.
257
+
258
+ The purpose of this function is to provide convenience for some cross-platform, multi-device users, using relative paths, raw images and MD files can be easily moved, or using a synchronization service similar to Nut Cloud for multi-device synchronization.
259
+
260
+ ```shell
261
+ pymdimg -m relative_img
262
+ ```
263
+
264
+ > - In order to avoid the corruption of the original MD file caused by program errors, one original file will be kept and backed up in the backup subdirectory.
265
+ > - Because of the difference between Windows and Linux platform separators, there is no guarantee that the relative directories of both will behave properly.
266
+
228
267
 
229
268
  ## Acknowledgements
230
269
 
@@ -280,4 +319,8 @@ Fix the bug that can't create img dir normally in Linux.
280
319
 
281
320
  ### 0.3.9
282
321
 
283
- Added the function to modify the absolute path image in the MD file to relative path.
322
+ Added the function to modify the absolute path image in the MD file to relative path.
323
+
324
+ ### 0.4.0
325
+
326
+ Added the support to fengzhen image bed.
@@ -28,6 +28,7 @@ src/markdown_img/compress/tinypng_compress_service.py
28
28
  src/markdown_img/img_service/Upyun_img_service.py
29
29
  src/markdown_img/img_service/__init__.py
30
30
  src/markdown_img/img_service/bilibili_img_service.py
31
+ src/markdown_img/img_service/fz_img_service.py
31
32
  src/markdown_img/img_service/img_service.py
32
33
  src/markdown_img/img_service/none_img_service.py
33
34
  src/markdown_img/img_service/qcloud_img_service.py
@@ -44,4 +45,5 @@ src/markdown_img_icexmoon.egg-info/SOURCES.txt
44
45
  src/markdown_img_icexmoon.egg-info/dependency_links.txt
45
46
  src/markdown_img_icexmoon.egg-info/entry_points.txt
46
47
  src/markdown_img_icexmoon.egg-info/requires.txt
47
- src/markdown_img_icexmoon.egg-info/top_level.txt
48
+ src/markdown_img_icexmoon.egg-info/top_level.txt
49
+ tests/test.py
@@ -0,0 +1,12 @@
1
+ import sys
2
+ sys.path.insert(-2, "D:\\workspace\\markdown-img2\\src")
3
+ print(sys.path)
4
+ from markdown_img.main import Main
5
+ import os
6
+ testFile = '.\\markdown_img\\test_image.md'
7
+ if os.path.exists(testFile):
8
+ os.remove(testFile)
9
+ main = Main()
10
+ main.changeImgService("upyun")
11
+ main.changeMainPrams({"compress_engine": "tinyPNG"})
12
+ main.main(True)