|
1 | | -#!/usr/bin/env python3 |
| 1 | +# -*- coding: utf-8 -*- |
2 | 2 | # pylint: disable=invalid-name |
3 | 3 | """ |
4 | 4 | Upload image file or image URL to the ptpimg.me image hosting. |
5 | 5 |
|
6 | | -Borrowed from https://github.com/theirix/ptpimg-uploader/blob/master/ptpimg_uploader.py |
| 6 | +Borrowed from |
| 7 | +https://github.com/theirix/ptpimg-uploader/blob/master/ptpimg_uploader.py |
7 | 8 |
|
8 | 9 | """ |
9 | 10 |
|
10 | 11 | import contextlib |
11 | 12 | import mimetypes |
12 | 13 | import os |
13 | 14 | from io import BytesIO |
14 | | -from sys import stdout |
15 | 15 | from textwrap import dedent |
16 | 16 |
|
17 | 17 | import requests |
|
24 | 24 | config.register( |
25 | 25 | 'PtpImg', 'api_key', |
26 | 26 | dedent("""\ |
27 | | - To find your PTPImg API key, login to https://ptpimg.me, |
28 | | - open the page source (i.e. "View->Developer->View source" menu in Chrome), |
29 | | - find the string api_key and copy the hexademical string from the value attribute. |
| 27 | + To find your PTPImg API key, login to https://ptpimg.me, open the page |
| 28 | + source (i.e. "View->Developer->View source" menu in Chrome), find the |
| 29 | + string api_key and copy the hexademical string from the value attribute. |
30 | 30 | Your API key should look like 43fe0fee-f935-4084-8a38-3e632b0be68c. |
31 | 31 | 3. Enter the API Key below |
32 | 32 | API Key""")) |
@@ -109,7 +109,8 @@ def upload_urls(self, *urls): |
109 | 109 | resp = requests.get(url, timeout=self.timeout) |
110 | 110 | if resp.status_code != requests.codes.ok: |
111 | 111 | raise ValueError( |
112 | | - 'Cannot fetch url {} with error {}'.format(url, resp.status_code)) |
| 112 | + 'Cannot fetch url {} with error {}'.format( |
| 113 | + url, resp.status_code)) |
113 | 114 |
|
114 | 115 | mime_type = resp.headers['content-type'] |
115 | 116 | if not mime_type or mime_type.split('/')[0] != 'image': |
|
0 commit comments