Skip to content
Browse files

Move interactive access to separate script.

This removes the interactive behavior of tmdb_api.py and places it in a
new script.  The script can be run from the source directory, but does
not get installed with the library.
  • Loading branch information...
1 parent 30a0d39 commit 76c8c518ff8dcc1206a984d2a5c12503f194870a @wagnerrp committed
Showing with 53 additions and 16 deletions.
  1. +53 −0 scripts/pytmdb3.py
  2. +0 −16 tmdb3/tmdb_api.py
View
53 scripts/pytmdb3.py
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+
+from optparse import OptionParser
+from tmdb3 import *
+
+import sys
+
+if __name__ == '__main__':
+ # this key is registered to this library for testing purposes.
+ # please register for your own key if you wish to use this
+ # library in your own application.
+ # http://help.themoviedb.org/kb/api/authentication-basics
+ set_key('1acd79ff610c77f3040073d004f7f5b0')
+
+ parser = OptionParser()
+ parser.add_option('-v', "--version", action="store_true", default=False,
+ dest="version", help="Display version.")
+ parser.add_option('-d', "--debug", action="store_true", default=False,
+ dest="debug", help="Enables verbose debugging.")
+ parser.add_option('-c', "--no-cache", action="store_true", default=False,
+ dest="nocache", help="Disables request cache.")
+ opts, args = parser.parse_args()
+
+ if opts.version:
+ from tmdb3.tmdb_api import __title__, __purpose__, __version__, __author__
+ print __title__
+ print ""
+ print __purpose__
+ print "Version: "+__version__
+ sys.exit(0)
+
+# TODO: make this actually do something
+# if opts.debug:
+# DEBUG = True
+
+ if opts.nocache:
+ set_cache(engine='null')
+ else:
+ set_cache(engine='file', filename='/tmp/pytmdb3.cache')
+
+ banner = 'PyTMDB3 Interactive Shell.'
+ import code
+ try:
+ import readline, rlcompleter
+ except ImportError:
+ pass
+ else:
+ readline.parse_and_bind("tab: complete")
+ banner += ' TAB completion available.'
+ namespace = globals().copy()
+ namespace.update(locals())
+ code.InteractiveConsole(namespace).interact(banner)
+
View
16 tmdb3/tmdb_api.py
@@ -509,19 +509,3 @@ def _populate(self):
return Request('collection/{0}'.format(self.id), \
language=self._locale.language)
-if __name__ == '__main__':
- set_key('c27cb71cff5bd76e1a7a009380562c62') #MythTV API Key
- DEBUG = True
-
- banner = 'tmdb_api interactive shell.'
- import code
- try:
- import readline, rlcompleter
- except:
- pass
- else:
- readline.parse_and_bind("tab: complete")
- banner += ' TAB completion available.'
- namespace = globals().copy()
- namespace.update(locals())
- code.InteractiveConsole(namespace).interact(banner)

0 comments on commit 76c8c51

Please sign in to comment.
Something went wrong with that request. Please try again.