summaryrefslogtreecommitdiff
path: root/anidb.py
diff options
context:
space:
mode:
Diffstat (limited to 'anidb.py')
-rw-r--r--anidb.py40
1 files changed, 23 insertions, 17 deletions
diff --git a/anidb.py b/anidb.py
index 62258c9..d5c93d4 100644
--- a/anidb.py
+++ b/anidb.py
@@ -37,28 +37,11 @@ options, args = op.parse_args(sys.argv[1:])
options.login = options.add
-# Authorization.
-
if options.login:
if not options.username:
options.username = raw_input('Username: ')
if not options.password:
options.passord = getpass.getpass()
- a = pyanidb.AniDB(options.username, options.password)
- try:
- a.auth()
- print 'Logged in as user %s.' % (options.username)
- if a.new_version:
- print 'New version available.'
- except pyanidb.AniDBUserError:
- print 'Invalid username/password.'
- sys.exit(1)
- except pyanidb.AniDBTimeout:
- print 'Connection timed out.'
- sys.exit(1)
- except pyanidb.AniDBError, e:
- print 'Fatal error:', e
- sys.exit(1)
# Input files.
@@ -77,6 +60,29 @@ for name in args:
subfiles.sort()
files += [os.path.join(root, file) for file in subfiles if sum([file.endswith('.' + suffix) for suffix in options.suffix])]
+if not files:
+ print 'All operations finished.'
+ sys.exit(0)
+
+# Authorization.
+
+if options.login:
+ a = pyanidb.AniDB(options.username, options.password)
+ try:
+ a.auth()
+ print 'Logged in as user %s.' % (options.username)
+ if a.new_version:
+ print 'New version available.'
+ except pyanidb.AniDBUserError:
+ print 'Invalid username/password.'
+ sys.exit(1)
+ except pyanidb.AniDBTimeout:
+ print 'Connection timed out.'
+ sys.exit(1)
+ except pyanidb.AniDBError, e:
+ print 'Fatal error:', e
+ sys.exit(1)
+
# Hashing.
for filename, hash in pyanidb.hash.hash_files(files):