{"action":"created","comment":{"url":"https://api.github.com/repos/snarfed/granary/pulls/comments/38274174","id":38274174,"diff_hunk":"@@ -0,0 +1,371 @@\n+from apiclient.errors import HttpError\n+from apiclient.http import BatchHttpRequest\n+from oauth_dropins.webutil import util\n+from oauth_dropins import flickr_auth\n+\n+import appengine_config\n+import datetime\n+import functools\n+import itertools\n+import json\n+import logging\n+import requests\n+import source\n+import sys\n+import mf2py\n+import urllib2\n+\n+\n+class Flickr(source.Source):\n+\n+  DOMAIN = 'flickr.com'\n+  NAME = 'Flickr'\n+\n+  API_EXTRAS = ','.join(('date_upload', 'date_taken', 'views', 'media',\n+                         'description' 'tags', 'machine_tags', 'geo'))\n+\n+  def __init__(self, access_token_key, access_token_secret, user_id=None):\n+    \"\"\"Constructor.\n+\n+    Args:\n+      access_token_key: string, OAuth access token key\n+      access_token_secret: string, OAuth access token secret\n+      user_id: string, the logged in user's Flickr nsid (optional)\n+    \"\"\"\n+    self.access_token_key = access_token_key\n+    self.access_token_secret = access_token_secret\n+    self.user_id = user_id\n+\n+  def call_api_method(self, method, params={}):\n+    \"\"\"Call a Flickr API method.\n+    \"\"\"\n+    return flickr_auth.call_api_method(\n+      method, params, self.access_token_key, self.access_token_secret)\n+\n+  def get_activities_response(self, user_id=None, group_id=None, app_id=None,\n+                              activity_id=None, start_index=0, count=0,\n+                              etag=None, min_id=None, cache=None,\n+                              fetch_replies=False, fetch_likes=False,\n+                              fetch_shares=False, fetch_events=False,\n+                              search_query=None):\n+    \"\"\"Get Flickr actvities\n+    \"\"\"\n+    if user_id is None:\n+      user_id = 'me'\n+    if group_id is None:\n+      group_id = source.FRIENDS\n+\n+    params = {}\n+    method = None\n+    solo = False\n+\n+    if activity_id:\n+      method = 'flickr.photos.getInfo'\n+      params['photo_id'] = activity_id\n+      solo = True\n+    elif group_id == source.SELF:\n+      method = 'flickr.people.getPhotos'\n+      params['user_id'] = user_id\n+      params['extras'] = self.API_EXTRAS","path":"granary/flickr.py","position":69,"original_position":69,"commit_id":"5ba877b8b15c9681032524840e83e146db329b17","original_commit_id":"5ba877b8b15c9681032524840e83e146db329b17","user":{"login":"snarfed","id":778068,"avatar_url":"https://avatars.githubusercontent.com/u/778068?v=3","gravatar_id":"","url":"https://api.github.com/users/snarfed","html_url":"https://github.com/snarfed","followers_url":"https://api.github.com/users/snarfed/followers","following_url":"https://api.github.com/users/snarfed/following{/other_user}","gists_url":"https://api.github.com/users/snarfed/gists{/gist_id}","starred_url":"https://api.github.com/users/snarfed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snarfed/subscriptions","organizations_url":"https://api.github.com/users/snarfed/orgs","repos_url":"https://api.github.com/users/snarfed/repos","events_url":"https://api.github.com/users/snarfed/events{/privacy}","received_events_url":"https://api.github.com/users/snarfed/received_events","type":"User","site_admin":false},"body":"minor, style: maybe consolidate these two into `if solo` below","created_at":"2015-08-30T18:11:51Z","updated_at":"2015-08-30T18:11:51Z","html_url":"https://github.com/snarfed/granary/pull/33#discussion_r38274174","pull_request_url":"https://api.github.com/repos/snarfed/granary/pulls/33","_links":{"self":{"href":"https://api.github.com/repos/snarfed/granary/pulls/comments/38274174"},"html":{"href":"https://github.com/snarfed/granary/pull/33#discussion_r38274174"},"pull_request":{"href":"https://api.github.com/repos/snarfed/granary/pulls/33"}}},"pull_request":{"url":"https://api.github.com/repos/snarfed/granary/pulls/33","id":43715068,"html_url":"https://github.com/snarfed/granary/pull/33","diff_url":"https://github.com/snarfed/granary/pull/33.diff","patch_url":"https://github.com/snarfed/granary/pull/33.patch","issue_url":"https://api.github.com/repos/snarfed/granary/issues/33","number":33,"state":"open","locked":false,"title":"Flickr support","user":{"login":"kylewm","id":950127,"avatar_url":"https://avatars.githubusercontent.com/u/950127?v=3","gravatar_id":"","url":"https://api.github.com/users/kylewm","html_url":"https://github.com/kylewm","followers_url":"https://api.github.com/users/kylewm/followers","following_url":"https://api.github.com/users/kylewm/following{/other_user}","gists_url":"https://api.github.com/users/kylewm/gists{/gist_id}","starred_url":"https://api.github.com/users/kylewm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kylewm/subscriptions","organizations_url":"https://api.github.com/users/kylewm/orgs","repos_url":"https://api.github.com/users/kylewm/repos","events_url":"https://api.github.com/users/kylewm/events{/privacy}","received_events_url":"https://api.github.com/users/kylewm/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-08-30T15:32:35Z","updated_at":"2015-08-30T18:11:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a4fb1fb3b7ba9526cb16c19fff23d41f2010a728","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/snarfed/granary/pulls/33/commits","review_comments_url":"https://api.github.com/repos/snarfed/granary/pulls/33/comments","review_comment_url":"https://api.github.com/repos/snarfed/granary/pulls/comments{/number}","comments_url":"https://api.github.com/repos/snarfed/granary/issues/33/comments","statuses_url":"https://api.github.com/repos/snarfed/granary/statuses/5ba877b8b15c9681032524840e83e146db329b17","head":{"label":"kylewm:flickr-support","ref":"flickr-support","sha":"5ba877b8b15c9681032524840e83e146db329b17","user":{"login":"kylewm","id":950127,"avatar_url":"https://avatars.githubusercontent.com/u/950127?v=3","gravatar_id":"","url":"https://api.github.com/users/kylewm","html_url":"https://github.com/kylewm","followers_url":"https://api.github.com/users/kylewm/followers","following_url":"https://api.github.com/users/kylewm/following{/other_user}","gists_url":"https://api.github.com/users/kylewm/gists{/gist_id}","starred_url":"https://api.github.com/users/kylewm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kylewm/subscriptions","organizations_url":"https://api.github.com/users/kylewm/orgs","repos_url":"https://api.github.com/users/kylewm/repos","events_url":"https://api.github.com/users/kylewm/events{/privacy}","received_events_url":"https://api.github.com/users/kylewm/received_events","type":"User","site_admin":false},"repo":{"id":17553043,"name":"granary","full_name":"kylewm/granary","owner":{"login":"kylewm","id":950127,"avatar_url":"https://avatars.githubusercontent.com/u/950127?v=3","gravatar_id":"","url":"https://api.github.com/users/kylewm","html_url":"https://github.com/kylewm","followers_url":"https://api.github.com/users/kylewm/followers","following_url":"https://api.github.com/users/kylewm/following{/other_user}","gists_url":"https://api.github.com/users/kylewm/gists{/gist_id}","starred_url":"https://api.github.com/users/kylewm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kylewm/subscriptions","organizations_url":"https://api.github.com/users/kylewm/orgs","repos_url":"https://api.github.com/users/kylewm/repos","events_url":"https://api.github.com/users/kylewm/events{/privacy}","received_events_url":"https://api.github.com/users/kylewm/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kylewm/granary","description":"A library and REST API that converts Facebook, Google+, Instagram, and Twitter data to ActivityStreams format.","fork":true,"url":"https://api.github.com/repos/kylewm/granary","forks_url":"https://api.github.com/repos/kylewm/granary/forks","keys_url":"https://api.github.com/repos/kylewm/granary/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kylewm/granary/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kylewm/granary/teams","hooks_url":"https://api.github.com/repos/kylewm/granary/hooks","issue_events_url":"https://api.github.com/repos/kylewm/granary/issues/events{/number}","events_url":"https://api.github.com/repos/kylewm/granary/events","assignees_url":"https://api.github.com/repos/kylewm/granary/assignees{/user}","branches_url":"https://api.github.com/repos/kylewm/granary/branches{/branch}","tags_url":"https://api.github.com/repos/kylewm/granary/tags","blobs_url":"https://api.github.com/repos/kylewm/granary/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kylewm/granary/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kylewm/granary/git/refs{/sha}","trees_url":"https://api.github.com/repos/kylewm/granary/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kylewm/granary/statuses/{sha}","languages_url":"https://api.github.com/repos/kylewm/granary/languages","stargazers_url":"https://api.github.com/repos/kylewm/granary/stargazers","contributors_url":"https://api.github.com/repos/kylewm/granary/contributors","subscribers_url":"https://api.github.com/repos/kylewm/granary/subscribers","subscription_url":"https://api.github.com/repos/kylewm/granary/subscription","commits_url":"https://api.github.com/repos/kylewm/granary/commits{/sha}","git_commits_url":"https://api.github.com/repos/kylewm/granary/git/commits{/sha}","comments_url":"https://api.github.com/repos/kylewm/granary/comments{/number}","issue_comment_url":"https://api.github.com/repos/kylewm/granary/issues/comments{/number}","contents_url":"https://api.github.com/repos/kylewm/granary/contents/{+path}","compare_url":"https://api.github.com/repos/kylewm/granary/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kylewm/granary/merges","archive_url":"https://api.github.com/repos/kylewm/granary/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kylewm/granary/downloads","issues_url":"https://api.github.com/repos/kylewm/granary/issues{/number}","pulls_url":"https://api.github.com/repos/kylewm/granary/pulls{/number}","milestones_url":"https://api.github.com/repos/kylewm/granary/milestones{/number}","notifications_url":"https://api.github.com/repos/kylewm/granary/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kylewm/granary/labels{/name}","releases_url":"https://api.github.com/repos/kylewm/granary/releases{/id}","created_at":"2014-03-08T23:01:51Z","updated_at":"2015-07-29T17:17:52Z","pushed_at":"2015-08-30T15:28:55Z","git_url":"git://github.com/kylewm/granary.git","ssh_url":"git@github.com:kylewm/granary.git","clone_url":"https://github.com/kylewm/granary.git","svn_url":"https://github.com/kylewm/granary","homepage":"http://facebook-activitystreams.appspot.com/","size":2300,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"snarfed:master","ref":"master","sha":"dd6edd00c5cc033b7041abf3ccdb12231dc12fee","user":{"login":"snarfed","id":778068,"avatar_url":"https://avatars.githubusercontent.com/u/778068?v=3","gravatar_id":"","url":"https://api.github.com/users/snarfed","html_url":"https://github.com/snarfed","followers_url":"https://api.github.com/users/snarfed/followers","following_url":"https://api.github.com/users/snarfed/following{/other_user}","gists_url":"https://api.github.com/users/snarfed/gists{/gist_id}","starred_url":"https://api.github.com/users/snarfed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snarfed/subscriptions","organizations_url":"https://api.github.com/users/snarfed/orgs","repos_url":"https://api.github.com/users/snarfed/repos","events_url":"https://api.github.com/users/snarfed/events{/privacy}","received_events_url":"https://api.github.com/users/snarfed/received_events","type":"User","site_admin":false},"repo":{"id":3557653,"name":"granary","full_name":"snarfed/granary","owner":{"login":"snarfed","id":778068,"avatar_url":"https://avatars.githubusercontent.com/u/778068?v=3","gravatar_id":"","url":"https://api.github.com/users/snarfed","html_url":"https://github.com/snarfed","followers_url":"https://api.github.com/users/snarfed/followers","following_url":"https://api.github.com/users/snarfed/following{/other_user}","gists_url":"https://api.github.com/users/snarfed/gists{/gist_id}","starred_url":"https://api.github.com/users/snarfed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snarfed/subscriptions","organizations_url":"https://api.github.com/users/snarfed/orgs","repos_url":"https://api.github.com/users/snarfed/repos","events_url":"https://api.github.com/users/snarfed/events{/privacy}","received_events_url":"https://api.github.com/users/snarfed/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/snarfed/granary","description":"Fetches and converts data between Facebook, Google+, Instagram, and Twitter native APIs, ActivityStreams, microformats2 HTML and JSON, Atom, and more.","fork":false,"url":"https://api.github.com/repos/snarfed/granary","forks_url":"https://api.github.com/repos/snarfed/granary/forks","keys_url":"https://api.github.com/repos/snarfed/granary/keys{/key_id}","collaborators_url":"https://api.github.com/repos/snarfed/granary/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/snarfed/granary/teams","hooks_url":"https://api.github.com/repos/snarfed/granary/hooks","issue_events_url":"https://api.github.com/repos/snarfed/granary/issues/events{/number}","events_url":"https://api.github.com/repos/snarfed/granary/events","assignees_url":"https://api.github.com/repos/snarfed/granary/assignees{/user}","branches_url":"https://api.github.com/repos/snarfed/granary/branches{/branch}","tags_url":"https://api.github.com/repos/snarfed/granary/tags","blobs_url":"https://api.github.com/repos/snarfed/granary/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/snarfed/granary/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/snarfed/granary/git/refs{/sha}","trees_url":"https://api.github.com/repos/snarfed/granary/git/trees{/sha}","statuses_url":"https://api.github.com/repos/snarfed/granary/statuses/{sha}","languages_url":"https://api.github.com/repos/snarfed/granary/languages","stargazers_url":"https://api.github.com/repos/snarfed/granary/stargazers","contributors_url":"https://api.github.com/repos/snarfed/granary/contributors","subscribers_url":"https://api.github.com/repos/snarfed/granary/subscribers","subscription_url":"https://api.github.com/repos/snarfed/granary/subscription","commits_url":"https://api.github.com/repos/snarfed/granary/commits{/sha}","git_commits_url":"https://api.github.com/repos/snarfed/granary/git/commits{/sha}","comments_url":"https://api.github.com/repos/snarfed/granary/comments{/number}","issue_comment_url":"https://api.github.com/repos/snarfed/granary/issues/comments{/number}","contents_url":"https://api.github.com/repos/snarfed/granary/contents/{+path}","compare_url":"https://api.github.com/repos/snarfed/granary/compare/{base}...{head}","merges_url":"https://api.github.com/repos/snarfed/granary/merges","archive_url":"https://api.github.com/repos/snarfed/granary/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/snarfed/granary/downloads","issues_url":"https://api.github.com/repos/snarfed/granary/issues{/number}","pulls_url":"https://api.github.com/repos/snarfed/granary/pulls{/number}","milestones_url":"https://api.github.com/repos/snarfed/granary/milestones{/number}","notifications_url":"https://api.github.com/repos/snarfed/granary/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/snarfed/granary/labels{/name}","releases_url":"https://api.github.com/repos/snarfed/granary/releases{/id}","created_at":"2012-02-27T05:30:53Z","updated_at":"2015-08-04T19:14:06Z","pushed_at":"2015-08-30T15:32:35Z","git_url":"git://github.com/snarfed/granary.git","ssh_url":"git@github.com:snarfed/granary.git","clone_url":"https://github.com/snarfed/granary.git","svn_url":"https://github.com/snarfed/granary","homepage":"","size":3871,"stargazers_count":60,"watchers_count":60,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":7,"forks":9,"open_issues":7,"watchers":60,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/snarfed/granary/pulls/33"},"html":{"href":"https://github.com/snarfed/granary/pull/33"},"issue":{"href":"https://api.github.com/repos/snarfed/granary/issues/33"},"comments":{"href":"https://api.github.com/repos/snarfed/granary/issues/33/comments"},"review_comments":{"href":"https://api.github.com/repos/snarfed/granary/pulls/33/comments"},"review_comment":{"href":"https://api.github.com/repos/snarfed/granary/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/snarfed/granary/pulls/33/commits"},"statuses":{"href":"https://api.github.com/repos/snarfed/granary/statuses/5ba877b8b15c9681032524840e83e146db329b17"}}}}