Created
May 22, 2015 17:32
-
-
Save cunningham/3f3ae2e4ef5a119662cf to your computer and use it in GitHub Desktop.
Towerfall replay poster
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
from hypchat import HypChat | |
import pyimgur | |
import glob | |
import os | |
#Info | |
hc_token = 'HIPCHAT_TOKEN' | |
replay_dir = '/PATH/TO/REPLAYS/' | |
posted_dir = '/PATH/TO/POSTED/FILES/' | |
imgur_client_id = 'IMGUR_CLIENT_ID' | |
room_to_post_to = 'TowerFall' | |
#Setup connections | |
h = HypChat(hc_token) | |
im = pyimgur.Imgur(imgur_client_id) | |
files_to_post = glob.glob('{0}/*.gif'.format(replay_dir)) | |
room = h.get_room(room_to_post_to) | |
#Iterate through files, uploading to imgur and posting link to Hipchat. | |
for f in files_to_post: | |
num_posted_files = len(glob.glob('{0}/*.gif'.format(posted_dir))) | |
file_name = 'replay{0}.gif'.format(str(num_posted_files + 1)) | |
os.rename(f, '{0}/posted/{1}'.format(replay_dir,file_name)) | |
uploaded_img = im.upload_image('{0}/posted/{1}'.format(replay_dir,file_name),title=file_name) | |
room.message('{0}: {1}'.format(file_name,uploaded_img.link),format='text') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment