Last active
November 24, 2017 23:30
-
-
Save bsquidwrd/8020fe1f1adb456d0ce85168bd7fd4ad to your computer and use it in GitHub Desktop.
Get the first follower of a channel
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
import requests | |
from dateutil.parser import parse | |
channel = "lassiz" | |
client_id = "INSERT TWITCH CLIENT ID HERE" | |
number_of_followers_to_print = 100 | |
url = "https://api.twitch.tv/kraken/channels/{}/follows".format(channel) | |
payload = { | |
"direction": "asc", | |
"limit": "100", | |
} | |
headers = { | |
"Client-ID": client_id, | |
} | |
r = requests.get(url, params=payload, headers=headers).json() | |
for number, follower in enumerate(r["follows"]): | |
if number + 1 > number_of_followers_to_print: | |
break | |
count = str(number + 1) | |
total_followers = int(len(str(r['_total']))) # User for number padding | |
print(count.zfill(total_followers), parse(follower["created_at"]), follower["user"]["name"]) |
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
python-dateutil==2.6.1 | |
requests==2.12.4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment