From cd7616ad6fa717413a4a544c030da4426f32d027 Mon Sep 17 00:00:00 2001 From: Bill Wiens Date: Wed, 29 Oct 2014 11:01:36 -0700 Subject: [PATCH 01/37] Add missing colon in code example --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 20dab4e..99c242e 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ client = ImgurClient(client_id, client_secret) # Example request items = client.gallery() -for item in items +for item in items: print(item.link) ``` From aead5dda30b3d6b8ca90f0c81b2d861e166d90d9 Mon Sep 17 00:00:00 2001 From: jasdev Date: Wed, 29 Oct 2014 21:39:50 -0700 Subject: [PATCH 02/37] Refreshing gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 298a1fb..fe956e6 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ config.json dist build imgurpython.egg-info +runner.py \ No newline at end of file From c26964cd95bd2025e42467510057436286ab90e2 Mon Sep 17 00:00:00 2001 From: Muntaser Ahmed Date: Thu, 30 Oct 2014 12:01:55 -0400 Subject: [PATCH 03/37] pep8 says do a barrel roll --- imgurpython/client.py | 6 ++++-- imgurpython/helpers/format.py | 10 +++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/imgurpython/client.py b/imgurpython/client.py index e08923e..541b983 100644 --- a/imgurpython/client.py +++ b/imgurpython/client.py @@ -558,7 +558,8 @@ def get_image(self, image_id): return Image(image) def upload_from_path(self, path, config=None, anon=True): - if not config: config = dict() + if not config: + config = dict() fd = open(path, 'rb') contents = fd.read() @@ -573,7 +574,8 @@ def upload_from_path(self, path, config=None, anon=True): return self.make_request('POST', 'upload', data, anon) def upload_from_url(self, url, config=None, anon=True): - if not config: config = dict() + if not config: + config = dict() data = { 'image': url, diff --git a/imgurpython/helpers/format.py b/imgurpython/helpers/format.py index b36536c..70cb39f 100644 --- a/imgurpython/helpers/format.py +++ b/imgurpython/helpers/format.py @@ -71,11 +71,11 @@ def build_notifications(response): def build_notification(item): notification = Notification( - item['id'], - item['account_id'], - item['viewed'], - item['content'] - ) + item['id'], + item['account_id'], + item['viewed'], + item['content'] + ) if 'comment' in notification.content: notification.content = format_comment_tree(item['content']) From 059f6b8a7106c1f24e80eb88b4e7a4d27ff244dd Mon Sep 17 00:00:00 2001 From: Michael Recachinas Date: Thu, 30 Oct 2014 22:49:12 -0400 Subject: [PATCH 04/37] Removed comma `self.created = created,` builds a tuple in `self.created`. This appears to be a mistake. See below for an example: ```python >>> x = 3, >>> x (3,) ``` --- imgurpython/imgur/models/account.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imgurpython/imgur/models/account.py b/imgurpython/imgur/models/account.py index 4f1f9a7..8bc2827 100644 --- a/imgurpython/imgur/models/account.py +++ b/imgurpython/imgur/models/account.py @@ -5,5 +5,5 @@ def __init__(self, id, url, bio, reputation, created, pro_expiration): self.url = url self.bio = bio self.reputation = reputation - self.created = created, + self.created = created self.pro_expiration = pro_expiration From 2c5d1603f9ff9b0e6ee764d19828a30630c973cf Mon Sep 17 00:00:00 2001 From: jasdev Date: Thu, 30 Oct 2014 20:21:05 -0700 Subject: [PATCH 05/37] Bugs fixes and version bump --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 1c84d09..b95b495 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ # Versions should comply with PEP440. For a discussion on single-sourcing # the version across setup.py and the project code, see # http://packaging.python.org/en/latest/tutorial.html#version - version='1.1.1', + version='1.1.2', description='Official Imgur python library with OAuth2 and samples', long_description='', From 6635a698531df9da9f4fbf93181273b3fd1b5062 Mon Sep 17 00:00:00 2001 From: jasdev Date: Wed, 5 Nov 2014 22:23:16 -0800 Subject: [PATCH 06/37] Adding rate limit information to resolve #17 --- README.md | 12 ++++++++++++ imgurpython/client.py | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/README.md b/README.md index 99c242e..1ab4395 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,18 @@ except ImgurClientError as e * ImgurClientRateLimitError - Rate limit error +### Credits + +To view client and user credit information, use the `credits` attribute of `ImgurClient`. +`credits` holds a dictionary with the following keys: +* UserLimit +* UserRemaining +* UserReset +* ClientLimit +* ClientRemaining + +For more information about rate-limiting, please see the note in our [docs](http://api.imgur.com/#limits)! + ## ImgurClient Functions ### Account diff --git a/imgurpython/client.py b/imgurpython/client.py index 541b983..f54e9f2 100644 --- a/imgurpython/client.py +++ b/imgurpython/client.py @@ -80,12 +80,17 @@ def __init__(self, client_id, client_secret, access_token=None, refresh_token=No if refresh_token is not None: self.auth = AuthWrapper(access_token, refresh_token, client_id, client_secret) + self.credits = self.get_credits() + def set_user_auth(self, access_token, refresh_token): self.auth = AuthWrapper(access_token, refresh_token, self.client_id, self.client_secret) def get_client_id(self): return self.client_id + def get_credits(self): + return self.make_request('GET', 'credits', None, True) + def get_auth_url(self, response_type='pin'): return '%soauth2/authorize?client_id=%s&response_type=%s' % (API_URL, self.client_id, response_type) @@ -126,6 +131,14 @@ def make_request(self, method, route, data=None, force_anon=False): else: response = method_to_call(url, headers=header, data=data) + self.credits = { + 'UserLimit': response.headers.get('X-RateLimit-UserLimit'), + 'UserRemaining': response.headers.get('X-RateLimit-UserRemaining'), + 'UserReset': response.headers.get('X-RateLimit-UserReset'), + 'ClientLimit': response.headers.get('X-RateLimit-ClientLimit'), + 'ClientRemaining': response.headers.get('X-RateLimit-ClientRemaining') + } + # Rate-limit check if response.status_code == 429: raise ImgurClientRateLimitError() From e7585c37f36bba4f26d22ed79299636f02e5d16d Mon Sep 17 00:00:00 2001 From: jasdev Date: Wed, 5 Nov 2014 22:24:25 -0800 Subject: [PATCH 07/37] Bumping pypi version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index b95b495..1ba4f53 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ # Versions should comply with PEP440. For a discussion on single-sourcing # the version across setup.py and the project code, see # http://packaging.python.org/en/latest/tutorial.html#version - version='1.1.2', + version='1.1.3', description='Official Imgur python library with OAuth2 and samples', long_description='', From 412148a6f8ad5b1473b85e9b4de37b8bae86eab0 Mon Sep 17 00:00:00 2001 From: Yves Dorfsman Date: Fri, 14 Nov 2014 05:09:15 -0700 Subject: [PATCH 08/37] Adding non-API entry points to README --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 1ab4395..7d86451 100644 --- a/README.md +++ b/README.md @@ -218,3 +218,13 @@ For more information about rate-limiting, please see the note in our [docs](http ### Memegen * `default_memes()` + +Imgur entry points +================== +| entry point | content | +|-----------------------------------|--------------------------------| +| imgur.com/{image_id} | image | +| imgur.com/{image_id}.extension | direct link to image (no html) | +| imgur.com/a/{album_id} | album | +| imgur.com/a/{album_id}#{image_id} | single image from an album | +| imgur.com/gallery/{image_id} | gallery | From 9c534adcefbdf140f5d761b3113c5715b4fdf12f Mon Sep 17 00:00:00 2001 From: Yves Dorfsman Date: Fri, 14 Nov 2014 19:15:34 -0700 Subject: [PATCH 09/37] added import for ImgurClientError in README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 1ab4395..c781c96 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,8 @@ Error types * ImgurClientError - General error handler, access message and status code via ```python +from imgurpython.helpers.error import ImgurClientError + try ... except ImgurClientError as e From 81d6772e7e2576a2e8840eceb406a6a6fc3165f0 Mon Sep 17 00:00:00 2001 From: ueg1990 Date: Tue, 18 Nov 2014 21:15:57 -0500 Subject: [PATCH 10/37] Add example to print links of a Gallery --- README.md | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/README.md b/README.md index c781c96..e184383 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,66 @@ To view client and user credit information, use the `credits` attribute of `Imgu For more information about rate-limiting, please see the note in our [docs](http://api.imgur.com/#limits)! +Examples +------------ + +## Anonymous Usage without user authorization + +### Print links in a Gallery +Output links from gallery could be a GalleyImage or GalleryAlbum + +#### Default +By default, this will return meme links on the first page (0) with section 'hot' sorted by 'viral', date range is 'day' and show_viral is set to True + +```python +items = client.gallery() +for item in items: + print(item.link) + +``` + +**Output** + + + http://i.imgur.com/dRMIpvS.png + http://imgur.com/a/uxKYS + http://i.imgur.com/jYvaxQ1.jpg + http://i.imgur.com/ZWQJSXp.jpg + http://i.imgur.com/arP5ZwL.jpg + http://i.imgur.com/BejpKnz.jpg + http://i.imgur.com/4FJF0Vt.jpg + http://i.imgur.com/MZSBjTP.jpg + http://i.imgur.com/EbeztS2.jpg + http://i.imgur.com/DuwnhKO.jpg + ... + ... + +#### With Specific Parameters +In this example, return meme links on the fourth page (3) with section 'top' sorted by 'time', date range is 'week' and show_viral is set to False + +```python +items = client.gallery(section='top', sort='time', page=3, window='week', show_viral=False) +for item in items: + print(item.link) + +``` + +**Output** + + + http://i.imgur.com/ls7OPx7.gif + http://i.imgur.com/FI7yPWo.png + http://imgur.com/a/8QKvH + http://i.imgur.com/h4IDMyK.gif + http://i.imgur.com/t4NpfCT.jpg + http://i.imgur.com/kyCP6q9.jpg + http://imgur.com/a/CU11w + http://i.imgur.com/q4rJFbR.jpg + http://i.imgur.com/gWaNC22.jpg + http://i.imgur.com/YEQomCd.gif + ... + ... + ## ImgurClient Functions ### Account From f92b4f0bb0b87183066330cb7fd628e8c25372c3 Mon Sep 17 00:00:00 2001 From: ueg1990 Date: Wed, 19 Nov 2014 00:22:32 -0500 Subject: [PATCH 11/37] Update README.md --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e184383..8645b9b 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ Examples Output links from gallery could be a GalleyImage or GalleryAlbum #### Default -By default, this will return meme links on the first page (0) with section 'hot' sorted by 'viral', date range is 'day' and show_viral is set to True +By default, this will return links to items on the first page (0) with section 'hot' sorted by 'viral', date range is 'day' and show_viral is set to True ```python items = client.gallery() @@ -148,10 +148,9 @@ for item in items: http://i.imgur.com/EbeztS2.jpg http://i.imgur.com/DuwnhKO.jpg ... - ... #### With Specific Parameters -In this example, return meme links on the fourth page (3) with section 'top' sorted by 'time', date range is 'week' and show_viral is set to False +In this example, return links to items on the fourth page (3) with section 'top' sorted by 'time', date range is 'week' and show_viral is set to False ```python items = client.gallery(section='top', sort='time', page=3, window='week', show_viral=False) @@ -174,7 +173,6 @@ for item in items: http://i.imgur.com/gWaNC22.jpg http://i.imgur.com/YEQomCd.gif ... - ... ## ImgurClient Functions From eafe1de5c2b2e538eb82538177bfb90b7651ba12 Mon Sep 17 00:00:00 2001 From: Yves Dorfsman Date: Sat, 22 Nov 2014 18:00:03 -0700 Subject: [PATCH 12/37] replaced image_id by gallery_post_id as per jacobgreenleaf suggestion. --- README.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7d86451..6047857 100644 --- a/README.md +++ b/README.md @@ -221,10 +221,11 @@ For more information about rate-limiting, please see the note in our [docs](http Imgur entry points ================== -| entry point | content | -|-----------------------------------|--------------------------------| -| imgur.com/{image_id} | image | -| imgur.com/{image_id}.extension | direct link to image (no html) | -| imgur.com/a/{album_id} | album | -| imgur.com/a/{album_id}#{image_id} | single image from an album | -| imgur.com/gallery/{image_id} | gallery | +| entry point | content | +|-------------------------------------|--------------------------------| +| imgur.com/{image_id} | image | +| imgur.com/{image_id}.extension | direct link to image (no html) | +| imgur.com/a/{album_id} | album | +| imgur.com/a/{album_id}#{image_id} | single image from an album | +| imgur.com/gallery/{gallery_post_id} | gallery | + From 98fe9a86b1fa92dd6bea392cc45bafdc05b0398d Mon Sep 17 00:00:00 2001 From: jasdev Date: Mon, 8 Dec 2014 18:30:49 -0800 Subject: [PATCH 13/37] Fixing code authorize step, resolves #26 --- imgurpython/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imgurpython/client.py b/imgurpython/client.py index f54e9f2..0875f14 100644 --- a/imgurpython/client.py +++ b/imgurpython/client.py @@ -99,7 +99,7 @@ def authorize(self, response, grant_type='pin'): 'client_id': self.client_id, 'client_secret': self.client_secret, 'grant_type': grant_type, - grant_type: response + 'code' if grant_type == 'authorization_code' else grant_type: response }, True) def prepare_headers(self, force_anon=False): From aa30c3f4d106c0660f27990cf22e9be6e48abe30 Mon Sep 17 00:00:00 2001 From: jasdev Date: Mon, 8 Dec 2014 18:32:02 -0800 Subject: [PATCH 14/37] Bumping version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 1ba4f53..2cf8866 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ # Versions should comply with PEP440. For a discussion on single-sourcing # the version across setup.py and the project code, see # http://packaging.python.org/en/latest/tutorial.html#version - version='1.1.3', + version='1.1.4', description='Official Imgur python library with OAuth2 and samples', long_description='', From 2421467e1f25f800496b3ac457850048d449af00 Mon Sep 17 00:00:00 2001 From: jasdev Date: Wed, 10 Dec 2014 10:43:31 -0800 Subject: [PATCH 15/37] Removing uses of id variable, fixes #24 --- imgurpython/imgur/models/account.py | 4 ++-- imgurpython/imgur/models/conversation.py | 4 ++-- imgurpython/imgur/models/custom_gallery.py | 4 ++-- imgurpython/imgur/models/message.py | 4 ++-- imgurpython/imgur/models/notification.py | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/imgurpython/imgur/models/account.py b/imgurpython/imgur/models/account.py index 8bc2827..4598bfa 100644 --- a/imgurpython/imgur/models/account.py +++ b/imgurpython/imgur/models/account.py @@ -1,7 +1,7 @@ class Account: - def __init__(self, id, url, bio, reputation, created, pro_expiration): - self.id = id + def __init__(self, account_id, url, bio, reputation, created, pro_expiration): + self.id = account_id self.url = url self.bio = bio self.reputation = reputation diff --git a/imgurpython/imgur/models/conversation.py b/imgurpython/imgur/models/conversation.py index 9d14554..9e8c12e 100644 --- a/imgurpython/imgur/models/conversation.py +++ b/imgurpython/imgur/models/conversation.py @@ -2,9 +2,9 @@ class Conversation: - def __init__(self, id, last_message_preview, datetime, with_account_id, with_account, message_count, messages=None, + def __init__(self, conversation_id, last_message_preview, datetime, with_account_id, with_account, message_count, messages=None, done=None, page=None): - self.id = id + self.id = conversation_id self.last_message_preview = last_message_preview self.datetime = datetime self.with_account_id = with_account_id diff --git a/imgurpython/imgur/models/custom_gallery.py b/imgurpython/imgur/models/custom_gallery.py index 2752764..9f0f78a 100644 --- a/imgurpython/imgur/models/custom_gallery.py +++ b/imgurpython/imgur/models/custom_gallery.py @@ -4,8 +4,8 @@ class CustomGallery: - def __init__(self, id, name, datetime, account_url, link, tags, item_count=None, items=None): - self.id = id + def __init__(self, custom_gallery_id, name, datetime, account_url, link, tags, item_count=None, items=None): + self.id = custom_gallery_id self.name = name self.datetime = datetime self.account_url = account_url diff --git a/imgurpython/imgur/models/message.py b/imgurpython/imgur/models/message.py index 185a0f4..5da36b2 100644 --- a/imgurpython/imgur/models/message.py +++ b/imgurpython/imgur/models/message.py @@ -1,7 +1,7 @@ class Message: - def __init__(self, id, from_user, account_id, sender_id, body, conversation_id, datetime): - self.id = id + def __init__(self, message_id, from_user, account_id, sender_id, body, conversation_id, datetime): + self.id = message_id self.from_user = from_user self.account_id = account_id self.sender_id = sender_id diff --git a/imgurpython/imgur/models/notification.py b/imgurpython/imgur/models/notification.py index 3da26b6..4a333a1 100644 --- a/imgurpython/imgur/models/notification.py +++ b/imgurpython/imgur/models/notification.py @@ -1,7 +1,7 @@ class Notification: - def __init__(self, id, account_id, viewed, content): - self.id = id + def __init__(self, notification_id, account_id, viewed, content): + self.id = notification_id self.account_id = account_id self.viewed = viewed self.content = content From aa5dbee40dcb368bbc5adc7cb6d82c6b6a74f136 Mon Sep 17 00:00:00 2001 From: jasdev Date: Wed, 10 Dec 2014 10:45:15 -0800 Subject: [PATCH 16/37] Bumping version to 1.1.5 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 2cf8866..46982b1 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ # Versions should comply with PEP440. For a discussion on single-sourcing # the version across setup.py and the project code, see # http://packaging.python.org/en/latest/tutorial.html#version - version='1.1.4', + version='1.1.5', description='Official Imgur python library with OAuth2 and samples', long_description='', From c25cf7e8704d52f95afe9a0cf7899006b3e16333 Mon Sep 17 00:00:00 2001 From: ueg1990 Date: Wed, 10 Dec 2014 18:41:56 -0500 Subject: [PATCH 17/37] More examples to EXAMPLES.md --- EXAMPLES.md | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 57 +---------------------------------------------------- 2 files changed, 58 insertions(+), 56 deletions(-) create mode 100644 EXAMPLES.md diff --git a/EXAMPLES.md b/EXAMPLES.md new file mode 100644 index 0000000..1e0a585 --- /dev/null +++ b/EXAMPLES.md @@ -0,0 +1,57 @@ +Examples +------------ + +## Anonymous Usage without user authorization + +### Print links in a Gallery +Output links from gallery could be a GalleyImage or GalleryAlbum + +#### Default +By default, this will return links to items on the first page (0) with section 'hot' sorted by 'viral', date range is 'day' and show_viral is set to True + +```python +items = client.gallery() +for item in items: + print(item.link) + +``` + +**Output** + + + http://i.imgur.com/dRMIpvS.png + http://imgur.com/a/uxKYS + http://i.imgur.com/jYvaxQ1.jpg + http://i.imgur.com/ZWQJSXp.jpg + http://i.imgur.com/arP5ZwL.jpg + http://i.imgur.com/BejpKnz.jpg + http://i.imgur.com/4FJF0Vt.jpg + http://i.imgur.com/MZSBjTP.jpg + http://i.imgur.com/EbeztS2.jpg + http://i.imgur.com/DuwnhKO.jpg + ... + +#### With Specific Parameters +In this example, return links to items on the fourth page (3) with section 'top' sorted by 'time', date range is 'week' and show_viral is set to False + +```python +items = client.gallery(section='top', sort='time', page=3, window='week', show_viral=False) +for item in items: + print(item.link) + +``` + +**Output** + + + http://i.imgur.com/ls7OPx7.gif + http://i.imgur.com/FI7yPWo.png + http://imgur.com/a/8QKvH + http://i.imgur.com/h4IDMyK.gif + http://i.imgur.com/t4NpfCT.jpg + http://i.imgur.com/kyCP6q9.jpg + http://imgur.com/a/CU11w + http://i.imgur.com/q4rJFbR.jpg + http://i.imgur.com/gWaNC22.jpg + http://i.imgur.com/YEQomCd.gif + ... \ No newline at end of file diff --git a/README.md b/README.md index 96e2d64..e38054f 100644 --- a/README.md +++ b/README.md @@ -118,61 +118,7 @@ For more information about rate-limiting, please see the note in our [docs](http Examples ------------ - -## Anonymous Usage without user authorization - -### Print links in a Gallery -Output links from gallery could be a GalleyImage or GalleryAlbum - -#### Default -By default, this will return links to items on the first page (0) with section 'hot' sorted by 'viral', date range is 'day' and show_viral is set to True - -```python -items = client.gallery() -for item in items: - print(item.link) - -``` - -**Output** - - - http://i.imgur.com/dRMIpvS.png - http://imgur.com/a/uxKYS - http://i.imgur.com/jYvaxQ1.jpg - http://i.imgur.com/ZWQJSXp.jpg - http://i.imgur.com/arP5ZwL.jpg - http://i.imgur.com/BejpKnz.jpg - http://i.imgur.com/4FJF0Vt.jpg - http://i.imgur.com/MZSBjTP.jpg - http://i.imgur.com/EbeztS2.jpg - http://i.imgur.com/DuwnhKO.jpg - ... - -#### With Specific Parameters -In this example, return links to items on the fourth page (3) with section 'top' sorted by 'time', date range is 'week' and show_viral is set to False - -```python -items = client.gallery(section='top', sort='time', page=3, window='week', show_viral=False) -for item in items: - print(item.link) - -``` - -**Output** - - - http://i.imgur.com/ls7OPx7.gif - http://i.imgur.com/FI7yPWo.png - http://imgur.com/a/8QKvH - http://i.imgur.com/h4IDMyK.gif - http://i.imgur.com/t4NpfCT.jpg - http://i.imgur.com/kyCP6q9.jpg - http://imgur.com/a/CU11w - http://i.imgur.com/q4rJFbR.jpg - http://i.imgur.com/gWaNC22.jpg - http://i.imgur.com/YEQomCd.gif - ... +Examples can be found [here](EXAMPLES.md) ## ImgurClient Functions @@ -210,7 +156,6 @@ for item in items: ### Comment * `get_comment(comment_id)` * `delete_comment(comment_id)` -* `create_album(fields)` * `get_comment_replies(comment_id)` * `post_comment_reply(comment_id, image_id, comment)` * `comment_vote(comment_id, vote='up')` From 95bce34ab2a67e929b17cce97e96a97f20fc0e7d Mon Sep 17 00:00:00 2001 From: ueg1990 Date: Sun, 14 Dec 2014 17:04:08 -0500 Subject: [PATCH 18/37] Convert old style classes to new style --- imgurpython/client.py | 4 ++-- imgurpython/imgur/models/account.py | 2 +- imgurpython/imgur/models/account_settings.py | 2 +- imgurpython/imgur/models/album.py | 2 +- imgurpython/imgur/models/comment.py | 2 +- imgurpython/imgur/models/conversation.py | 2 +- imgurpython/imgur/models/custom_gallery.py | 2 +- imgurpython/imgur/models/gallery_album.py | 2 +- imgurpython/imgur/models/gallery_image.py | 2 +- imgurpython/imgur/models/image.py | 2 +- imgurpython/imgur/models/message.py | 2 +- imgurpython/imgur/models/notification.py | 2 +- imgurpython/imgur/models/tag.py | 2 +- imgurpython/imgur/models/tag_vote.py | 2 +- 14 files changed, 15 insertions(+), 15 deletions(-) diff --git a/imgurpython/client.py b/imgurpython/client.py index 0875f14..f247d73 100644 --- a/imgurpython/client.py +++ b/imgurpython/client.py @@ -19,7 +19,7 @@ API_URL = 'https://api.imgur.com/' -class AuthWrapper: +class AuthWrapper(object): def __init__(self, access_token, refresh_token, client_id, client_secret): self.current_access_token = access_token @@ -55,7 +55,7 @@ def refresh(self): self.current_access_token = response_data['access_token'] -class ImgurClient: +class ImgurClient(object): allowed_album_fields = { 'ids', 'title', 'description', 'privacy', 'layout', 'cover' } diff --git a/imgurpython/imgur/models/account.py b/imgurpython/imgur/models/account.py index 4598bfa..01a798a 100644 --- a/imgurpython/imgur/models/account.py +++ b/imgurpython/imgur/models/account.py @@ -1,4 +1,4 @@ -class Account: +class Account(object): def __init__(self, account_id, url, bio, reputation, created, pro_expiration): self.id = account_id diff --git a/imgurpython/imgur/models/account_settings.py b/imgurpython/imgur/models/account_settings.py index 93d2da5..045aaf2 100644 --- a/imgurpython/imgur/models/account_settings.py +++ b/imgurpython/imgur/models/account_settings.py @@ -1,4 +1,4 @@ -class AccountSettings: +class AccountSettings(object): def __init__(self, email, high_quality, public_images, album_privacy, pro_expiration, accepted_gallery_terms, active_emails, messaging_enabled, blocked_users): diff --git a/imgurpython/imgur/models/album.py b/imgurpython/imgur/models/album.py index 6c49507..414acc2 100644 --- a/imgurpython/imgur/models/album.py +++ b/imgurpython/imgur/models/album.py @@ -1,4 +1,4 @@ -class Album: +class Album(object): # See documentation at https://api.imgur.com/ for available fields def __init__(self, *initial_data, **kwargs): diff --git a/imgurpython/imgur/models/comment.py b/imgurpython/imgur/models/comment.py index 49e343c..29e4a9f 100644 --- a/imgurpython/imgur/models/comment.py +++ b/imgurpython/imgur/models/comment.py @@ -1,4 +1,4 @@ -class Comment: +class Comment(object): # See documentation at https://api.imgur.com/ for available fields def __init__(self, *initial_data, **kwargs): diff --git a/imgurpython/imgur/models/conversation.py b/imgurpython/imgur/models/conversation.py index 9e8c12e..335196c 100644 --- a/imgurpython/imgur/models/conversation.py +++ b/imgurpython/imgur/models/conversation.py @@ -1,6 +1,6 @@ from .message import Message -class Conversation: +class Conversation(object): def __init__(self, conversation_id, last_message_preview, datetime, with_account_id, with_account, message_count, messages=None, done=None, page=None): diff --git a/imgurpython/imgur/models/custom_gallery.py b/imgurpython/imgur/models/custom_gallery.py index 9f0f78a..912ba6d 100644 --- a/imgurpython/imgur/models/custom_gallery.py +++ b/imgurpython/imgur/models/custom_gallery.py @@ -2,7 +2,7 @@ from .gallery_image import GalleryImage -class CustomGallery: +class CustomGallery(object): def __init__(self, custom_gallery_id, name, datetime, account_url, link, tags, item_count=None, items=None): self.id = custom_gallery_id diff --git a/imgurpython/imgur/models/gallery_album.py b/imgurpython/imgur/models/gallery_album.py index e947410..1622c99 100644 --- a/imgurpython/imgur/models/gallery_album.py +++ b/imgurpython/imgur/models/gallery_album.py @@ -1,4 +1,4 @@ -class GalleryAlbum: +class GalleryAlbum(object): # See documentation at https://api.imgur.com/ for available fields def __init__(self, *initial_data, **kwargs): diff --git a/imgurpython/imgur/models/gallery_image.py b/imgurpython/imgur/models/gallery_image.py index 73cc7ff..88faf19 100644 --- a/imgurpython/imgur/models/gallery_image.py +++ b/imgurpython/imgur/models/gallery_image.py @@ -1,4 +1,4 @@ -class GalleryImage: +class GalleryImage(object): # See documentation at https://api.imgur.com/ for available fields def __init__(self, *initial_data, **kwargs): diff --git a/imgurpython/imgur/models/image.py b/imgurpython/imgur/models/image.py index bd02b0c..18f257e 100644 --- a/imgurpython/imgur/models/image.py +++ b/imgurpython/imgur/models/image.py @@ -1,4 +1,4 @@ -class Image: +class Image(object): # See documentation at https://api.imgur.com/ for available fields def __init__(self, *initial_data, **kwargs): diff --git a/imgurpython/imgur/models/message.py b/imgurpython/imgur/models/message.py index 5da36b2..0f98f5e 100644 --- a/imgurpython/imgur/models/message.py +++ b/imgurpython/imgur/models/message.py @@ -1,4 +1,4 @@ -class Message: +class Message(object): def __init__(self, message_id, from_user, account_id, sender_id, body, conversation_id, datetime): self.id = message_id diff --git a/imgurpython/imgur/models/notification.py b/imgurpython/imgur/models/notification.py index 4a333a1..7966953 100644 --- a/imgurpython/imgur/models/notification.py +++ b/imgurpython/imgur/models/notification.py @@ -1,4 +1,4 @@ -class Notification: +class Notification(object): def __init__(self, notification_id, account_id, viewed, content): self.id = notification_id diff --git a/imgurpython/imgur/models/tag.py b/imgurpython/imgur/models/tag.py index 60a02ce..d9f8547 100644 --- a/imgurpython/imgur/models/tag.py +++ b/imgurpython/imgur/models/tag.py @@ -2,7 +2,7 @@ from .gallery_image import GalleryImage -class Tag: +class Tag(object): def __init__(self, name, followers, total_items, following, items): self.name = name diff --git a/imgurpython/imgur/models/tag_vote.py b/imgurpython/imgur/models/tag_vote.py index 6ac444f..eb1a995 100644 --- a/imgurpython/imgur/models/tag_vote.py +++ b/imgurpython/imgur/models/tag_vote.py @@ -1,4 +1,4 @@ -class TagVote: +class TagVote(object): def __init__(self, ups, downs, name, author): self.ups = ups From 1f1f67e3458e0018555a7aa284215caaacec1d92 Mon Sep 17 00:00:00 2001 From: Edwin Amsler Date: Sat, 14 Feb 2015 20:55:34 -0600 Subject: [PATCH 19/37] Add an example with usernames Hopefully this should save some users from trying to figure out what to put in the 'username' field before diving into the data model. --- EXAMPLES.md | 47 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/EXAMPLES.md b/EXAMPLES.md index 1e0a585..ecc8523 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -45,13 +45,40 @@ for item in items: http://i.imgur.com/ls7OPx7.gif - http://i.imgur.com/FI7yPWo.png - http://imgur.com/a/8QKvH - http://i.imgur.com/h4IDMyK.gif - http://i.imgur.com/t4NpfCT.jpg - http://i.imgur.com/kyCP6q9.jpg - http://imgur.com/a/CU11w - http://i.imgur.com/q4rJFbR.jpg - http://i.imgur.com/gWaNC22.jpg - http://i.imgur.com/YEQomCd.gif - ... \ No newline at end of file + http://i.imgur.com/FI7yPWo.png + http://imgur.com/a/8QKvH + http://i.imgur.com/h4IDMyK.gif + http://i.imgur.com/t4NpfCT.jpg + http://i.imgur.com/kyCP6q9.jpg + http://imgur.com/a/CU11w + http://i.imgur.com/q4rJFbR.jpg + http://i.imgur.com/gWaNC22.jpg + http://i.imgur.com/YEQomCd.gif + ... + +#### Getting the authenticated user's albums + +For endpoints that require usernames, once a user is authenticated we can use the keyword 'me' to pull their information. Here's how to pull one of their albums: + +```python + for album in client.get_account_albums('me'): + album_title = album.title if album.title else 'Untitled' + print('ID: {0} - {1}'.format(album.id, album_title)) + + for image in client.get_album_images(album.id): + image_title = image.title if image.title else 'Untitled' + print('\t{0}: {1}'.format(image_title, image.link)) + + # Save some API credits by not getting all albums + break +``` + +***Output*** + +Album: Qittens! (LPNnY) + Untitled: http://i.imgur.com/b9rL7ew.jpg + Untitled: http://i.imgur.com/Ymg3obW.jpg + Untitled: http://i.imgur.com/kMzbu0S.jpg + ... + + From c0cda99298d9f9b9df76650b74ff25f77b8b7e1d Mon Sep 17 00:00:00 2001 From: Edwin Amsler Date: Sat, 14 Feb 2015 20:56:30 -0600 Subject: [PATCH 20/37] Fix my formatting --- EXAMPLES.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/EXAMPLES.md b/EXAMPLES.md index ecc8523..fecd718 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -63,7 +63,7 @@ For endpoints that require usernames, once a user is authenticated we can use th ```python for album in client.get_account_albums('me'): album_title = album.title if album.title else 'Untitled' - print('ID: {0} - {1}'.format(album.id, album_title)) + print('Album: {0} ({1})'.format(album_title, album.id)) for image in client.get_album_images(album.id): image_title = image.title if image.title else 'Untitled' @@ -75,10 +75,11 @@ For endpoints that require usernames, once a user is authenticated we can use th ***Output*** -Album: Qittens! (LPNnY) - Untitled: http://i.imgur.com/b9rL7ew.jpg - Untitled: http://i.imgur.com/Ymg3obW.jpg - Untitled: http://i.imgur.com/kMzbu0S.jpg - ... + + Album: Qittens! (LPNnY) + Untitled: http://i.imgur.com/b9rL7ew.jpg + Untitled: http://i.imgur.com/Ymg3obW.jpg + Untitled: http://i.imgur.com/kMzbu0S.jpg + ... From fc6b1d0596578366f70fe21d43590cc0b20a7e44 Mon Sep 17 00:00:00 2001 From: Edwin Amsler Date: Sat, 14 Feb 2015 20:57:31 -0600 Subject: [PATCH 21/37] Yet more formatting I need to avoid using the Github website to test this stuff. --- EXAMPLES.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/EXAMPLES.md b/EXAMPLES.md index fecd718..2ec2cb7 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -61,16 +61,16 @@ for item in items: For endpoints that require usernames, once a user is authenticated we can use the keyword 'me' to pull their information. Here's how to pull one of their albums: ```python - for album in client.get_account_albums('me'): - album_title = album.title if album.title else 'Untitled' - print('Album: {0} ({1})'.format(album_title, album.id)) +for album in client.get_account_albums('me'): +album_title = album.title if album.title else 'Untitled' +print('Album: {0} ({1})'.format(album_title, album.id)) - for image in client.get_album_images(album.id): - image_title = image.title if image.title else 'Untitled' - print('\t{0}: {1}'.format(image_title, image.link)) +for image in client.get_album_images(album.id): + image_title = image.title if image.title else 'Untitled' + print('\t{0}: {1}'.format(image_title, image.link)) - # Save some API credits by not getting all albums - break +# Save some API credits by not getting all albums +break ``` ***Output*** From c7ab5d8741e1cf129e0222d7c85ead3c8a2afe19 Mon Sep 17 00:00:00 2001 From: Edwin Amsler Date: Sun, 15 Feb 2015 22:59:46 -0600 Subject: [PATCH 22/37] Create standalone auth example This will also save some typing for other examples --- examples/auth.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 examples/auth.py diff --git a/examples/auth.py b/examples/auth.py new file mode 100755 index 0000000..14b303d --- /dev/null +++ b/examples/auth.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python3 + +''' + Here's how you go about authenticating yourself! The important thing to + note here is that this script will be used in the other examples so + set up a test user with API credentials and set them up in here. +''' + +#client_id = 'YOUR CLIENT ID' +#client_secret = 'YOUR CLIENT SECRET' + +client_id = u'6d2d7ee5f212dc1' +client_secret = u'18828c1021069154576672e86b8ab2e1559d329a' + + +from imgurpython import ImgurClient + +def get_input(string): + ''' Get input from console regardless of python 2 or 3 ''' + try: + return raw_input(string) + except: + return input(string) + +def authenticate(): + client = ImgurClient(client_id, client_secret) + + # Authorization flow, pin example (see docs for other auth types) + authorization_url = client.get_auth_url('pin') + + print("Go to the following URL: {0}".format(authorization_url)) + + # Read in the pin, handle Python 2 or 3 here. + pin = get_input("Enter pin code: ") + + # ... redirect user to `authorization_url`, obtain pin (or code or token) ... + credentials = client.authorize(pin, 'pin') + client.set_user_auth(credentials['access_token'], credentials['refresh_token']) + + print("Authentication successful! Here are the details:") + print(" Access token: {0}".format(credentials['access_token'])) + print(" Refresh token: {0}".format(credentials['refresh_token'])) + + return client + +# If you want to run this as a standalone script, so be it! +if __name__ == "__main__": + authenticate() \ No newline at end of file From faa971adf88b769da5d2878cbbd66e36d9728d42 Mon Sep 17 00:00:00 2001 From: Edwin Amsler Date: Sun, 15 Feb 2015 23:45:54 -0600 Subject: [PATCH 23/37] Add an upload example --- examples/upload.py | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 examples/upload.py diff --git a/examples/upload.py b/examples/upload.py new file mode 100755 index 0000000..3014d6f --- /dev/null +++ b/examples/upload.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python3 + +''' + Here's how you upload an image. For this example, put the cutest picture + of a kitten you can find in this script's folder and name it 'Kitten.jpg' + + For more details about images and the API see here: + https://api.imgur.com/endpoints/image +''' + +# Pull authentication from the auth example (see auth.py) +from auth import authenticate + +from datetime import datetime + +album = None # You can also enter an album ID here +image_path = 'Kitten.jpg' + +def upload_kitten(client): + ''' + Upload a picture of a kitten. We don't ship one, so get creative! + ''' + + # Here's the metadata for the upload. All of these are optional, including + # this config dict itself. + config = { + 'album': album, + 'name': 'Catastrophe!', + 'title': 'Catastrophe!', + 'description': 'Cute kitten being cute on {0}'.format(datetime.now()) + } + + print("Uploading image... ") + image = client.upload_from_path(image_path, config=config, anon=False) + print("Done") + print() + + return image + + +# If you want to run this as a standalone script +if __name__ == "__main__": + client = authenticate() + image = upload_kitten(client) + + print("Image was posted! Go check your images you sexy beast!") + print("You can find it here: {0}".format(image['link'])) \ No newline at end of file From ccb3464a87e1f2909fff6c6e69a11952cdd4eadc Mon Sep 17 00:00:00 2001 From: Edwin Amsler Date: Mon, 16 Feb 2015 00:08:43 -0600 Subject: [PATCH 24/37] Move credentials to an INI file So that I can add it to my ignore list and not have people accidentally commit their credentials with code --- examples/auth.ini | 4 ++++ examples/auth.py | 22 +++++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 examples/auth.ini diff --git a/examples/auth.ini b/examples/auth.ini new file mode 100644 index 0000000..8eb90dc --- /dev/null +++ b/examples/auth.ini @@ -0,0 +1,4 @@ +[credentials] +client_id=YOUR ID HERE +client_secret=YOUR SECRET HERE +refresh_token= \ No newline at end of file diff --git a/examples/auth.py b/examples/auth.py index 14b303d..88c65fc 100755 --- a/examples/auth.py +++ b/examples/auth.py @@ -6,13 +6,6 @@ set up a test user with API credentials and set them up in here. ''' -#client_id = 'YOUR CLIENT ID' -#client_secret = 'YOUR CLIENT SECRET' - -client_id = u'6d2d7ee5f212dc1' -client_secret = u'18828c1021069154576672e86b8ab2e1559d329a' - - from imgurpython import ImgurClient def get_input(string): @@ -22,7 +15,22 @@ def get_input(string): except: return input(string) +def get_config(): + ''' More version compatibility stuff ''' + try: + import ConfigParser + return ConfigParser.ConfigParser() + except: + import configparser + return configparser.ConfigParser() + def authenticate(): + # Get client ID and secret from auth.ini + config = get_config() + config.read('auth.ini') + client_id = config['credentials']['client_id'] + client_secret = config['credentials']['client_secret'] + client = ImgurClient(client_id, client_secret) # Authorization flow, pin example (see docs for other auth types) From 00eed5f21a4f5c184f969e4ca49c8e7c1704ceeb Mon Sep 17 00:00:00 2001 From: Edwin Amsler Date: Mon, 16 Feb 2015 00:09:51 -0600 Subject: [PATCH 25/37] Ignore the auth.ini file --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index fe956e6..bd3907a 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ config.json dist build imgurpython.egg-info -runner.py \ No newline at end of file +runner.py +examples/auth.ini From 052b0266f3a0f32496bad6d5a0bcb5ae29000cdf Mon Sep 17 00:00:00 2001 From: Edwin Amsler Date: Mon, 16 Feb 2015 00:14:43 -0600 Subject: [PATCH 26/37] Move non-helpful stuff into their own file --- examples/auth.py | 17 +---------------- examples/helpers.py | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 16 deletions(-) create mode 100644 examples/helpers.py diff --git a/examples/auth.py b/examples/auth.py index 88c65fc..656130d 100755 --- a/examples/auth.py +++ b/examples/auth.py @@ -7,22 +7,7 @@ ''' from imgurpython import ImgurClient - -def get_input(string): - ''' Get input from console regardless of python 2 or 3 ''' - try: - return raw_input(string) - except: - return input(string) - -def get_config(): - ''' More version compatibility stuff ''' - try: - import ConfigParser - return ConfigParser.ConfigParser() - except: - import configparser - return configparser.ConfigParser() +from helpers import get_input, get_config def authenticate(): # Get client ID and secret from auth.ini diff --git a/examples/helpers.py b/examples/helpers.py new file mode 100644 index 0000000..7c9a0e8 --- /dev/null +++ b/examples/helpers.py @@ -0,0 +1,20 @@ +''' + These functions have nothing to do with the API, they just help ease + issues between Python 2 and 3 +''' + +def get_input(string): + ''' Get input from console regardless of python 2 or 3 ''' + try: + return raw_input(string) + except: + return input(string) + +def get_config(): + ''' Create a config parser for reading INI files ''' + try: + import ConfigParser + return ConfigParser.ConfigParser() + except: + import configparser + return configparser.ConfigParser() \ No newline at end of file From 24ac383355b5701ff10c6c3698c8fabe97d6fb3c Mon Sep 17 00:00:00 2001 From: Edwin Amsler Date: Mon, 16 Feb 2015 00:20:02 -0600 Subject: [PATCH 27/37] Reference our new INI file --- examples/auth.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/auth.py b/examples/auth.py index 656130d..3ced193 100755 --- a/examples/auth.py +++ b/examples/auth.py @@ -3,7 +3,7 @@ ''' Here's how you go about authenticating yourself! The important thing to note here is that this script will be used in the other examples so - set up a test user with API credentials and set them up in here. + set up a test user with API credentials and set them up in auth.ini. ''' from imgurpython import ImgurClient From 33a5563ab82808589c8c845996991e8c76b21fd9 Mon Sep 17 00:00:00 2001 From: Nate Shoffner Date: Mon, 9 Mar 2015 10:50:18 -0400 Subject: [PATCH 28/37] Use get() with ConfigParser for 2.x compatibility --- examples/auth.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/auth.py b/examples/auth.py index 3ced193..2f0b1f4 100755 --- a/examples/auth.py +++ b/examples/auth.py @@ -13,8 +13,8 @@ def authenticate(): # Get client ID and secret from auth.ini config = get_config() config.read('auth.ini') - client_id = config['credentials']['client_id'] - client_secret = config['credentials']['client_secret'] + client_id = config.get('credentials', 'client_id') + client_secret = config.get('credentials', 'client_secret') client = ImgurClient(client_id, client_secret) From 4684e2e2c46bf2aab9e743ce1ea0b7ea925ee51e Mon Sep 17 00:00:00 2001 From: jasdev Date: Thu, 23 Apr 2015 14:09:22 -0700 Subject: [PATCH 29/37] Adding Mashape support --- imgurpython/client.py | 17 +++++++++++++---- setup.py | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/imgurpython/client.py b/imgurpython/client.py index f247d73..e19e70e 100644 --- a/imgurpython/client.py +++ b/imgurpython/client.py @@ -17,6 +17,7 @@ from .imgur.models.account_settings import AccountSettings API_URL = 'https://api.imgur.com/' +MASHAPE_URL = 'https://imgur-apiv3.p.mashape.com/' class AuthWrapper(object): @@ -72,10 +73,11 @@ class ImgurClient(object): 'album', 'name', 'title', 'description' } - def __init__(self, client_id, client_secret, access_token=None, refresh_token=None): + def __init__(self, client_id, client_secret, access_token=None, refresh_token=None, mashape_key=None): self.client_id = client_id self.client_secret = client_secret self.auth = None + self.mashape_key = mashape_key if refresh_token is not None: self.auth = AuthWrapper(access_token, refresh_token, client_id, client_secret) @@ -103,20 +105,27 @@ def authorize(self, response, grant_type='pin'): }, True) def prepare_headers(self, force_anon=False): + headers = {} if force_anon or self.auth is None: if self.client_id is None: raise ImgurClientError('Client credentials not found!') else: - return {'Authorization': 'Client-ID %s' % self.get_client_id()} + headers['Authorization'] = 'Client-ID %s' % self.get_client_id() else: - return {'Authorization': 'Bearer %s' % self.auth.get_current_access_token()} + headers['Authorization'] = 'Bearer %s' % self.auth.get_current_access_token() + + if self.mashape_key is not None: + headers['X-Mashape-Key'] = self.mashape_key + + return headers + def make_request(self, method, route, data=None, force_anon=False): method = method.lower() method_to_call = getattr(requests, method) header = self.prepare_headers(force_anon) - url = API_URL + ('3/%s' % route if 'oauth2' not in route else route) + url = (MASHAPE_URL if self.mashape_key is not None else API_URL) + ('3/%s' % route if 'oauth2' not in route else route) if method in ('delete', 'get'): response = method_to_call(url, headers=header, params=data, data=data) diff --git a/setup.py b/setup.py index 46982b1..79bcbb8 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ # Versions should comply with PEP440. For a discussion on single-sourcing # the version across setup.py and the project code, see # http://packaging.python.org/en/latest/tutorial.html#version - version='1.1.5', + version='1.1.6', description='Official Imgur python library with OAuth2 and samples', long_description='', From 0aaaa98dc65a31eb234f53e3bd78688f7fb127d4 Mon Sep 17 00:00:00 2001 From: manu Date: Sat, 30 May 2015 12:38:37 +0200 Subject: [PATCH 30/37] adding a "page" parameter to get_gallery_favorites and get_account_favorites --- imgurpython/client.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/imgurpython/client.py b/imgurpython/client.py index e19e70e..544330b 100644 --- a/imgurpython/client.py +++ b/imgurpython/client.py @@ -184,15 +184,15 @@ def get_account(self, username): account_data['pro_expiration'], ) - def get_gallery_favorites(self, username): + def get_gallery_favorites(self, username, page=0): self.validate_user_context(username) - gallery_favorites = self.make_request('GET', 'account/%s/gallery_favorites' % username) + gallery_favorites = self.make_request('GET', 'account/%s/gallery_favorites/%d' % (username, page)) return build_gallery_images_and_albums(gallery_favorites) - def get_account_favorites(self, username): + def get_account_favorites(self, username, page=0): self.validate_user_context(username) - favorites = self.make_request('GET', 'account/%s/favorites' % username) + favorites = self.make_request('GET', 'account/%s/favorites/%d' % (username, page)) return build_gallery_images_and_albums(favorites) From 534c2c8d346e7067b78036f7ece9a1d36a6be18e Mon Sep 17 00:00:00 2001 From: Kevin Cramer Date: Thu, 1 Oct 2015 18:05:24 -0700 Subject: [PATCH 31/37] Update support info. --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index e38054f..999a987 100644 --- a/README.md +++ b/README.md @@ -22,9 +22,7 @@ Our developer documentation can be found [here](https://api.imgur.com/). Community --------- -The best way to reach out to Imgur for API support would be our -[Google Group](https://groups.google.com/forum/#!forum/imgur), [Twitter](https://twitter.com/imgurapi), or via - api@imgur.com. +The best way to reach out to Imgur for API support is emailing us at api@imgur.com. Installation ------------ From 33776a80930fe7b6a199b1b86fd8a78786e176e2 Mon Sep 17 00:00:00 2001 From: Ryan Hughes Date: Sun, 27 Dec 2015 05:28:48 -0500 Subject: [PATCH 32/37] closed file in upload_from_path The file no longer remains open after calling upload_from_path(). This would previously throw warnings. --- imgurpython/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/imgurpython/client.py b/imgurpython/client.py index 544330b..b860a1a 100644 --- a/imgurpython/client.py +++ b/imgurpython/client.py @@ -586,13 +586,13 @@ def upload_from_path(self, path, config=None, anon=True): fd = open(path, 'rb') contents = fd.read() b64 = base64.b64encode(contents) - data = { 'image': b64, 'type': 'base64', } - data.update({meta: config[meta] for meta in set(self.allowed_image_fields).intersection(config.keys())}) + fd.close() + return self.make_request('POST', 'upload', data, anon) def upload_from_url(self, url, config=None, anon=True): From 3d2d2866770d251bc81c73732fd19fdcaabe012b Mon Sep 17 00:00:00 2001 From: Jacob Greenleaf Date: Fri, 29 Jan 2016 12:54:42 -0800 Subject: [PATCH 33/37] Add TravisYML --- .travis.yml | 9 +++++++++ setup.py | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..8e11c2f --- /dev/null +++ b/.travis.yml @@ -0,0 +1,9 @@ +language: python +deploy: + provider: pypi + user: imgurops + password: + secure: DBBXzMOm037T4XUmfo0Gu9mAytw2DCYJT8i0KgihKYxS+uslF+dwHf2clBEWDLUE0xkXhqXetq+sNgfshovGKIqZanASYZ/6Zf5ikg10ApgaBidObv2XMYNyuQxL8Gqv9l2tdlWqdUoOJzRBMV2Nh0B3BJ9hG7V5NFMDcfG/qyo= + on: + tags: true + repo: Imgur/imgurpython diff --git a/setup.py b/setup.py index 79bcbb8..300e786 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ # Versions should comply with PEP440. For a discussion on single-sourcing # the version across setup.py and the project code, see # http://packaging.python.org/en/latest/tutorial.html#version - version='1.1.6', + version='1.1.7', description='Official Imgur python library with OAuth2 and samples', long_description='', From 8694d428046aee4a5ea47dab55ae86e5663b6e7e Mon Sep 17 00:00:00 2001 From: Jacob Greenleaf Date: Fri, 29 Jan 2016 13:04:22 -0800 Subject: [PATCH 34/37] Add requirements.txt to let Travis install requests --- requirements.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..f229360 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +requests From c43e2364c26eaeeba58abfa7f4a001528190aa73 Mon Sep 17 00:00:00 2001 From: Jacob Greenleaf Date: Fri, 29 Jan 2016 13:11:33 -0800 Subject: [PATCH 35/37] Do a simple syntax check on Travis script --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 8e11c2f..cd12a9d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,6 @@ language: python +script: + - python -m compileall deploy: provider: pypi user: imgurops From cb717fe7490d304f858f00b459166f8b42900300 Mon Sep 17 00:00:00 2001 From: Khazhismel Date: Wed, 2 Dec 2015 20:45:17 -0500 Subject: [PATCH 36/37] Allow uploading file-like objects, allowing uploading of BytesIO/etc. --- imgurpython/client.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/imgurpython/client.py b/imgurpython/client.py index b860a1a..9c41ea6 100644 --- a/imgurpython/client.py +++ b/imgurpython/client.py @@ -580,10 +580,13 @@ def get_image(self, image_id): return Image(image) def upload_from_path(self, path, config=None, anon=True): + with open(path, 'rb') as fd: + self.upload(fd, config, anon) + + def upload(self, fd, config=None, anon=True): if not config: config = dict() - fd = open(path, 'rb') contents = fd.read() b64 = base64.b64encode(contents) data = { @@ -591,7 +594,6 @@ def upload_from_path(self, path, config=None, anon=True): 'type': 'base64', } data.update({meta: config[meta] for meta in set(self.allowed_image_fields).intersection(config.keys())}) - fd.close() return self.make_request('POST', 'upload', data, anon) From 1cd23bc471c1682247e9e5afece3305073befd26 Mon Sep 17 00:00:00 2001 From: Kevin Cramer Date: Thu, 19 Oct 2017 13:14:04 -0700 Subject: [PATCH 37/37] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 999a987..c89b846 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +# The imgurpython project is no longer supported. + imgurpython ===========