Skip to content

Instantly share code, notes, and snippets.

@sdornan
Created October 11, 2011 00:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sdornan/1276924 to your computer and use it in GitHub Desktop.
Save sdornan/1276924 to your computer and use it in GitHub Desktop.
Replace WoW Achievement Icons
from giantbomb.game_achievements.models import Achievement
from giantbomb.game_achievements.services import base, wow
wf = wow.WarcraftFetcher()
agg = base.Aggregator()
wow_achs = Achievement.objects.filter(service_game__service=4)
num_achs = len(wow_achs)
for index, ach in enumerate(wow_achs):
print '(%s/%s): Replacing icon of %s' % (index+1, num_achs, ach)
try:
image = ach.image_locked
except:
image = None
if image:
image.delete()
try:
image = ach.image_unlocked
except:
image = None
if image:
image.delete()
url = wf.get_achievement_image(ach.service_unique_achievement_id)
ach.image_locked = agg.fetch_image(url, ach.name + ' locked')
ach.image_unlocked = agg.fetch_image(url, ach.name + ' unlocked')
ach.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment