Realization of Picgo drawing bed tool with Python


1. PyPicGo

PyPicGo is a drawing bed tool, but PicGo is the implementation of Python version, and supports various plug-in custom plug-ins. At present, PyPicGo comes with gitee, github, SM. MS and 7 Niuyun pictures, as well as rename, notify and typora plug-ins, and supports downloading other plug-ins and Uploader from pypi

Source address:

“gitee” https://gitee.com/Ranger313/pypicgo

[github] https://github.com/AnsGoo/PyPicGo

1. Installation

pip install pypicgo

2. Configuration

The configuration file is located in the /$HOME/.PyPicGo/config.yml Directory, adopt YAML Configure in the way of. You must configure the uploader uploader , plug-ins plugins Optional quantity of

default: #  Default configuration

  uploader: gitee #  Default chart bed

  plugins: #  Global plug-in

    - module: pypicgo.plugins.rename.ReNamePlugin #  Graphic bed plug-in loading address

      config:

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

    - module: pypicgo.plugins.typora.TyporaPlugin

    - module: pypicgo.plugins.compress.CompressPlugin

    - module: pypicgo.plugins.notify.NotifyPlugin

uploaders: #  Available drawing bed

  smms: # sm.ms Graphic bed configuration

    module: pypicgo.uploaders.smms.uploader.SmmsUploader

    config:

      secret_token:  xxx

  gitee: # gitee  Graphic bed configuration

    module: pypicgo.uploaders.gitee.uploader.GiteeUploader

    config:

      domain: https://gitee.com

      owner: xxx

      repo: xxx

      img_path: xxx

      access_token: xxx

    plugins:

  github: # github Graphic bed configuration

    module: pypicgo.uploaders.github.uploader.GithubUploader

    config:

      domain: https://api.github.com

      owner: xxx

      repo: xxx

      img_path: xxx

      oauth_token: xxx

    plugins: # github  Graphic bed private plug-in

      - module: pypicgo.plugins.jsdelivr.JsDelivrPlugin

  qiniu: #7 Configuration of cattle cloud picture bed

      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

Refer to the documentation for more configuration instructions

3. Use

Help information

pypicgo -h

Upload a file

pypicgo -f picture1 picture2 ...

Specify the bed for uploading pictures

pypicgo -n github -f picture1 picture2 ...

If the system can’t find it pypicgo , please check python Adj. Scripts Is the folder added Path Environment variable

4. Supported map bed

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

5. Supported plug-ins

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

6. Uploader uploader

uploader Is a specific upload plug-in, and users need to inherit pypicgo.core.base.uploader.CommonUploader And implement YAML0 Method, and then reference it in the configuration file.

7. Plug-in system

PyPicgo There are three supported plug-ins before , after And final

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

If you want to customize the plug-in, just inherit any 1 base class plug-in as required, and implement the execute method, and in config.yml You can use the configuration in.

8. Development

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

cd pypicgo

pipenv shell

pipenv install

python run.py -n  Drawing bed name  -f img1.jpg img2.jpg