Viewing: trunk/collection/views.py

Revision: 50

View as text-only | View History
Index: views.py
===================================================================
--- views.py	(revision 50)
+++ views.py	(revision 61)
@@ -12,7 +12,8 @@
 from django.contrib.auth import authenticate, login
 from django.template.loader import get_template
 from django.template.context import Context
-import random, urllib, json, datetime, sys, facebook
+import random, urllib, json, datetime, sys
+from django.conf import settings
 
 LENGTH_STAMP = datetime.datetime(1983, 05, 10)  # This is used to determine the length of a movie title. Trivia, what date is this from?
 
@@ -93,8 +94,6 @@
     form_class = MovieForm
     def form_valid(self, form):
         self.object = form.save()
-        #graph = facebook.GraphAPI('CAACEdEose0cBAHKxrwO0vkOeDXtvpRbQpRTN2qMZAAEtucZCh2nRKYBPqnWCOvOCvEPBQbuypEAactxnoqDXSK4Ah4yLO2oA3vfY254036ZBbzq7ce4ZAr3eKHyZBFyzxFanPwwQt0PZA6N9tsyvDbnmvDhZA6RLZBZBgesPjZBnPhLxcVqwvgWFRT2LZCKjaYBc00JJVk3wigjofINI0clOJX4jt70hXBZBMNgZD')
-        #graph.put_wall_post('This is a test wallpost from the Facebook API.')
         for watchlist in self.object.genre.watchlist_set.all():
             body = get_template("collection/notifications/new_movie.txt").render(Context({'user':watchlist.owner, 'movie':self.object}))
             watchlist.owner.email_user('Nick added a new %s movie' % self.object.genre, body)
@@ -122,9 +121,9 @@
             movie_title=movie_title.replace('Part 2', 'Part II').replace('Part 3', 'Part III').replace(', A', '')
             try:
                 if self.object.year:
-                    omdb = urllib.urlopen('http://www.omdbapi.com/?t=%s&y=%s' % (movie_title, self.object.year)).read()
+                    omdb = urllib.urlopen('http://www.omdbapi.com/?t=%s&y=%s&apikey=%s' % (movie_title, self.object.year, settings.OMDB_APIKEY)).read()
                 else:
-                    omdb = urllib.urlopen('http://www.omdbapi.com/?t=%s' % movie_title).read()
+                    omdb = urllib.urlopen('http://www.omdbapi.com/?t=%s&apikey=%s' % (movie_title, settings.OMDB_APIKEY)).read()
             except:
                 omdb = '{"Response":"False"}'
                 value = sys.exc_info()[1]
@@ -224,7 +223,7 @@
         messages.error(req, "You do not have access to update the info from IMDb.")
         return redirect(movie)
     try:
-        omdb = urllib.urlopen('http://www.omdbapi.com/?i=%s' % movie.imdb).read()
+        omdb = urllib.urlopen('http://www.omdbapi.com/?i=%s&apikey=%s' % (movie.imdb, settings.OMDB_APIKEY)).read()
     except:
         omdb = '{"Response":"False"}'
         value = sys.exc_info()[1]