Last active
January 22, 2019 22:58
-
-
Save cesarmiquel/8b876d3ad2f391eb22a7bff34357af6c to your computer and use it in GitHub Desktop.
Get starred repositories for a Github username.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: UTF-8 -*- | |
import sys | |
import json | |
import urllib2 | |
def color(this_color, string): | |
return "\033[" + this_color + "m" + string + "\033[0m" | |
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) | |
if len(sys.argv) != 2: | |
print "Please provide github username as argument" | |
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