Skip to content

Instantly share code, notes, and snippets.

@cesarmiquel
Last active January 22, 2019 22:58
Show Gist options
  • Save cesarmiquel/8b876d3ad2f391eb22a7bff34357af6c to your computer and use it in GitHub Desktop.
Save cesarmiquel/8b876d3ad2f391eb22a7bff34357af6c to your computer and use it in GitHub Desktop.
Get starred repositories for a Github username.
# -*- coding: UTF-8 -*-
import sys
import json
import urllib2
def color(this_color, string):
return "\033[" + this_color + "m" + string + "\033[0m"
print
print color('34', '-' * 70)
print color('1;34', ' ' * 10 + u'๐ŸŒŸ U S E R G I T H U B S T A R S ๐ŸŒŸ')
print color('34', '-' * 70)
print
if len(sys.argv) != 2:
print
print "Please provide github username as argument"
print
sys.exit(0)
username = sys.argv[1]
stars_url = "https://api.github.com/users/%s/starred?per_page=200" % username
response = urllib2.urlopen(stars_url)
# TODO: get more than a single page of stas.
# print response.info() Retrieves a link for next and last pages.
feed = json.load(response)
for item in feed:
description = item['description']
if description == None:
description = '[without description] '
else:
description = description[:100]
print color('30', ' >> ') + color('1;37', item['full_name']) + '\n ' + color('32', description)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment