├── .gitignore ├── LICENSE ├── MANIFEST.in ├── README.rst ├── imgur_uploader.py ├── requirements.txt ├── setup.cfg └── setup.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Project-specific 2 | .env 3 | 4 | # Byte-compiled / optimized / DLL files 5 | __pycache__/ 6 | *.py[cod] 7 | 8 | # C extensions 9 | *.so 10 | 11 | # Distribution / packaging 12 | .Python 13 | env/ 14 | build/ 15 | develop-eggs/ 16 | dist/ 17 | downloads/ 18 | eggs/ 19 | .eggs/ 20 | lib/ 21 | lib64/ 22 | parts/ 23 | sdist/ 24 | var/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .coverage 43 | .coverage.* 44 | .cache 45 | nosetests.xml 46 | coverage.xml 47 | *,cover 48 | 49 | # Translations 50 | *.mo 51 | *.pot 52 | 53 | # Django stuff: 54 | *.log 55 | 56 | # Sphinx documentation 57 | docs/_build/ 58 | 59 | # PyBuilder 60 | target/ 61 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Andrew T. Baker 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include README.rst LICENSE requirements.txt -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | imgur-uploader 2 | ============== 3 | 4 | **NOTE: This repository is no longer maintained. See https://github.com/skorokithakis/imgur-uploader for the latest code.** 5 | 6 | A simple command line client for uploading files to Imgur. 7 | 8 | Created for my `PyCon US 2015 Docker tutorial `_ so that students using my cloud servers can see the gifs they create at the end of exercise 1. 9 | 10 | This tool is open source under the `MIT License `_. 11 | 12 | Quickstart 13 | ---------- 14 | 15 | Getting Imgur API credentials 16 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | 18 | Go to https://api.imgur.com/oauth2/addclient and register a new Imgur API client. You will need an Imgur account to do this. 19 | 20 | You can put it any valid URL for the callback URL - we won't be using it. 21 | 22 | Installing imgur-uploader 23 | ^^^^^^^^^^^^^^^^^^^^^^^^^ 24 | 25 | Installing imgur-uploader is easy. It runs on versions of Python >=2.7 or >=3.3. 26 | 27 | If you just want to use imgur-uploader, you can just ``pip install imgur-uploader``. 28 | 29 | If you want to tweak or enhance imgur-uploader, follow these instructions: 30 | 31 | #. Clone this repository 32 | #. Install the tool with ``pip install -e .`` 33 | 34 | Using imgur-uploader 35 | ^^^^^^^^^^^^^^^^^^^^ 36 | 37 | First, set the ``IMGUR_API_ID`` and ``IMGUR_API_SECRET`` environment variables in your terminal session, using your client's credentials. 38 | 39 | Upload an image by running ``imgur-uploader path/to/my.gif`` 40 | 41 | The tool will return a shortened link to your uploaded gif upon completion:: 42 | 43 | Uploading file my.gif 44 | ... 45 | File uploaded - see your gif at http://i.imgur.com/6WsQPpw.gif 46 | -------------------------------------------------------------------------------- /imgur_uploader.py: -------------------------------------------------------------------------------- 1 | from imgurpython import ImgurClient 2 | 3 | import click 4 | import os 5 | 6 | @click.command() 7 | @click.argument('gif', type=click.Path(exists=True)) 8 | def upload_gif(gif): 9 | """Uploads an image file to Imgur""" 10 | 11 | client_id = os.environ.get('IMGUR_API_ID') 12 | client_secret = os.environ.get('IMGUR_API_SECRET') 13 | 14 | if client_id is None or client_secret is None: 15 | click.echo('Cannot upload - could not find IMGUR_API_ID or IMGUR_API_SECRET environment variables') 16 | return 17 | 18 | client = ImgurClient(client_id, client_secret) 19 | 20 | click.echo('Uploading file {}'.format(click.format_filename(gif))) 21 | 22 | response = client.upload_from_path(gif) 23 | 24 | click.echo('File uploaded - see your gif at {}'.format(response['link'])) 25 | 26 | if __name__ == '__main__': 27 | upload_gif() 28 | 29 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | click==4.0 2 | imgurpython==1.1.5 3 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from setuptools import setup 4 | 5 | 6 | def read(*paths): 7 | """Build a file path from *paths* and return the contents.""" 8 | with open(os.path.join(*paths), 'r') as f: 9 | return f.read() 10 | 11 | setup( 12 | name='imgur-uploader', 13 | version='0.1.1', 14 | description='A simple command line client for uploading files to Imgur.', 15 | long_description=read('README.rst'), 16 | url='https://github.com/atbaker/imgur-uploader', 17 | license='MIT', 18 | author='Andrew Tork Baker', 19 | author_email='andrew@atbaker.me', 20 | py_modules=['imgur_uploader'], 21 | include_package_data=True, 22 | install_requires=[ 23 | 'click', 24 | 'imgurpython' 25 | ], 26 | entry_points=''' 27 | [console_scripts] 28 | imgur-uploader=imgur_uploader:upload_gif 29 | ''', 30 | classifiers=[ 31 | 'Development Status :: 5 - Production/Stable', 32 | 'Intended Audience :: Developers', 33 | 'Natural Language :: English', 34 | 'License :: OSI Approved :: MIT License', 35 | 'Operating System :: OS Independent', 36 | 'Programming Language :: Python', 37 | 'Programming Language :: Python :: 2', 38 | 'Programming Language :: Python :: 2.7', 39 | 'Programming Language :: Python :: 3', 40 | 'Programming Language :: Python :: 3.3', 41 | 'Programming Language :: Python :: 3.4', 42 | 'Topic :: Utilities', 43 | ] 44 | ) 45 | --------------------------------------------------------------------------------