{"id":3225,"date":"2019-05-10T16:12:15","date_gmt":"2019-05-10T08:12:15","guid":{"rendered":"https:\/\/damogame.cn\/wordpress\/?p=3225"},"modified":"2019-05-10T16:12:51","modified_gmt":"2019-05-10T08:12:51","slug":"chevereto-uploader","status":"publish","type":"post","link":"https:\/\/i007.cc\/wordpress\/archives\/3225","title":{"rendered":"Chevereto uploader"},"content":{"rendered":"<p>You can upload your image to the self-building chevereto by this tool. Actually , many people use shareX on Windows system , however , if you work on the OS X , mac os and linux , It&#8217;s terrible and time wasting to upload a image to self chevereto. If you have same issue , It&#8217;s time to use my tool.<\/p>\n<p>&nbsp;<\/p>\n<h1>how to use<\/h1>\n<p>You should find your API Key in yourselves&#8217;chevereto , It located at\u00a0<code>setting -&gt; API<\/code>\u00a0, and copy it to the\u00a0<code>upload.py<\/code>.<\/p>\n<p>Enjoy it !!!<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/github.com\/FormatFish\/chevereto-uploader\">\u6e90\u7801\u5730\u5740<\/a><\/p>\n<p>&nbsp;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">#coding=utf-8\r\nimport requests\r\nimport json\r\nimport mimetypes\r\nfrom PIL import ImageGrab\r\nimport datetime\r\n\r\ndef upload(files):\r\n    APIKey = \"YOU API KEY\"\r\n    format = \"json\"\r\n    url = \"http:\/\/image.cethik.vip\/api\/1\/upload\/?key=\"+ APIKey + \"&amp;format=\" + format\r\n    #files = \r\n    r = requests.post(url , files = files)\r\n\r\n    return json.loads(r.text)\r\n\r\ndef formatSource(filename):\r\n    imageList = []\r\n    type = mimetypes.guess_type(filename)[0]\r\n    imageList.append(('source' , (filename , open(filename , 'rb') , type)))\r\n    print imageList\r\n    return imageList\r\n\r\nif __name__ == \"__main__\":\r\n    print \"\u5c06\u56fe\u7247\u622a\u56fe\u6216\u590d\u5236\u5230\u526a\u5207\u677f\u4e2d\u5373\u53ef~~\uff0cctrl+z\u7ed3\u675f\"\r\n    recentVal = None\r\n    while(True):\r\n        tmpValue = ImageGrab.grabclipboard()\r\n        if recentVal != tmpValue:\r\n            recentVal = tmpValue\r\n            now = datetime.datetime.now()\r\n            now = now.strftime(\"%Y-%m-%d %H:%M:%S\")\r\n            filename = 'IMG'+ now + '.png'\r\n            if recentVal is not None:\r\n                recentVal.save(filename, 'png')\r\n                #filenames.append(filename)\r\n                #recentVal = None\r\n                print filename\r\n                jsonData = upload(formatSource(filename))\r\n\r\n                if jsonData['status_code'] != 200:\r\n                    print \"error: \" , jsonData['error']['message']\r\n                    print \"status code : \" , jsonData['status_code']\r\n                else:\r\n                    print \"orignal url: \" , jsonData['image']['display_url']\r\n                    print \"thumb url: \" , jsonData['image']['thumb']['url']<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You can upload your <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[],"tags":[119],"class_list":["post-3225","post","type-post","status-publish","format-standard","hentry","tag-03-"],"_links":{"self":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts\/3225","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/comments?post=3225"}],"version-history":[{"count":0,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts\/3225\/revisions"}],"wp:attachment":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/media?parent=3225"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/categories?post=3225"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/tags?post=3225"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}