利用Python实现Picgo图床工具

作者:L-L 时间:2023-10-09 16:10:45 

一、PyPicGo

PyPicGo 是一款图床工具,是PicGo是Python版实现,并支持各种插件自定义插件,目前PyPicGo自带了gitee、github、SM.MS和七牛云图传,以及rename、notify和typora等插件,并支持从pypi中下载其他插件和Uploader

源码地址:

【gitee】https://gitee.com/Ranger313/pypicgo

【github】https://github.com/AnsGoo/PyPicGo

1、安装

pip install pypicgo

2、配置

配置文件位于/$HOME/.PyPicGo/config.yml目录下,采用YAML的方式进行配置。必须配置上传器uploader,插件plugins的数量可选


default: # 默认配置

uploader: gitee # 默认图床

plugins: # 全局插件

- module: pypicgo.plugins.rename.ReNamePlugin # 图床插件加载地址

config:

format: liunx{hash}chenghaiwen{date}-{filename}

- module: pypicgo.plugins.typora.TyporaPlugin

- module: pypicgo.plugins.compress.CompressPlugin

- module: pypicgo.plugins.notify.NotifyPlugin

uploaders: # 可用图床

smms: # sm.ms图床配置

module: pypicgo.uploaders.smms.uploader.SmmsUploader

config:

secret_token:  xxx

gitee: # gitee 图床配置

module: pypicgo.uploaders.gitee.uploader.GiteeUploader

config:

domain: https://gitee.com

owner: xxx

repo: xxx

img_path: xxx

access_token: xxx

plugins:

github: # github图床配置

module: pypicgo.uploaders.github.uploader.GithubUploader

config:

domain: https://api.github.com

owner: xxx

repo: xxx

img_path: xxx

oauth_token: xxx

plugins: # github 图床私有插件

- module: pypicgo.plugins.jsdelivr.JsDelivrPlugin

qiniu: #七牛云图床配置

moduele: pypicgo.uploaders.qiniu.uploader.QiNiuUploader

config:

domain: http://demo.pypicho.com/

bucket_name: pypicgo

apis:

- http://up-z1.qiniup.com

access_key: xxx

secret_key:  xxxx

更多的配置说明参考文档

3、使用

帮助信息


pypicgo -h

上传文件


pypicgo -f picture1 picture2 ...

指定上传图床


pypicgo -n github -f picture1 picture2 ...

如果系统找不到pypicgo,请检查pythonScripts文件夹是否被加入Path环境变量

4、支持的图床

图床名模块地址
giteepypicgo.uploaders.gitee.uploader.GiteeUploader
七牛云pypicgo.uploaders.github.uploader.QiNiuUploader
githubpypicgo.uploaders.qiniu.uploader.GithubUploader
SM.MSpypicgo.uploaders.smms.uploader.SmmsUploader

5、支持的插件

插件名称用途windowslinuxmac
rename上传前重命名图片支持支持支持
notify上传成功失败的系统通知支持支持支持
typoratypora编辑器支持支持支持支持
compress图片上传前压缩支持支持支持
jsdelivrgithub CDN 加速支持支持支持
clipboard上传完成将远程地址复制到剪切板支持支持支持

6、Uploader上传器

uploader是具体的上传插件,用户需要继承pypicgo.core.base.uploader.CommonUploader并实现upload方法,然后在配置文件中引用即可.

7、插件系统

PyPicgo支持的插件分为三种beforeafterfinal

插件类型运行时间基类类示例插件运行时入参
before在图片上传前运行pypicgo.core.base.plugin.BeforePluginrenameFile
after在图片上传后运行pypicgo.core.base.plugin.AfterPluginnotifyResult
final在所有图片上传后运行pypicgo.core.base.plugin.FinallyPlugintyporaList[Result]

如果想自定义插件只要根据要求继承任意一个基类插件,并实现execute方法,并在config.yml中配置即可使用.

8、开发


git clone git@github.com:AnsGoo/PyPicGo.git

cd pypicgo

pipenv shell

pipenv install

python run.py -n 图床名 -f img1.jpg img2.jpg

来源:https://www.cnblogs.com/rangger/p/15559808.html

标签:Python,Picgo,图床,工具
0
投稿

猜你喜欢

  • css+JavaScript实现PDF、ZIP、DOC链接的标注

    2007-05-11 17:03:00
  • pyqt5的QWebEngineView 使用模板的方法

    2022-04-17 08:23:12
  • django 使用内置messages的操作

    2023-04-23 13:35:56
  • Python BeautifulSoup基本用法详解(通过标签及class定位元素)

    2022-11-06 10:50:49
  • 10个杀手级应用的Python自动化脚本

    2023-10-06 14:01:53
  • python的数据与matlab互通问题:SciPy

    2022-05-16 04:53:48
  • 部署ASP.NET Core程序到Windows系统

    2024-05-09 09:04:38
  • Python中datetime模块参考手册

    2021-04-21 23:31:12
  • 在Django admin中编辑ManyToManyField的实现方法

    2021-03-05 18:03:47
  • mysql中如何优化表释放表空间

    2024-01-18 09:58:27
  • np.newaxis 实现为 numpy.ndarray(多维数组)增加一个轴

    2021-02-14 07:48:20
  • 安装dbus-python的简要教程

    2021-09-07 10:09:43
  • Django打印出在数据库中执行的语句问题

    2024-01-21 04:26:41
  • SQL Server性能的改进得益于逻辑数据库设计

    2009-10-23 13:55:00
  • Python selenium环境搭建实现过程解析

    2023-10-06 06:18:48
  • pandas DataFrame 交集并集补集的实现

    2023-05-02 12:03:27
  • Python网络编程之TCP与UDP协议套接字用法示例

    2023-12-07 06:34:45
  • mysql 常用命令集锦(Linux/Windows)

    2024-01-17 07:26:20
  • Python3.6基于正则实现的计算器示例【无优化简单注释版】

    2023-07-19 05:29:25
  • tensorflow pb to tflite 精度下降详解

    2023-05-25 19:05:41
  • asp之家 网络编程 m.aspxhome.com