From a2ebd9bca9c4077dc6642c29d4e6f2d7107c0c24 Mon Sep 17 00:00:00 2001 From: zyp Date: Tue, 16 May 2006 23:21:27 +0000 Subject: [project @ zyp-20060516232127-1ed2efc46068ab87] [project @ 33] Added optionparser. --- anidb_add | 63 --------------------------------------------------------------- 1 file changed, 63 deletions(-) delete mode 100644 anidb_add (limited to 'anidb_add') diff --git a/anidb_add b/anidb_add deleted file mode 100644 index b0d06bd..0000000 --- a/anidb_add +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env python - -import pyanidb, pyanidb.hash -import ConfigParser, os, sys, getpass, multihash - -def auth(): - try: - c = ConfigParser.ConfigParser() - c.read(os.path.expanduser('~/.pyanidb.conf')) - username = c.get('auth', 'username') - password = c.get('auth', 'password') - except: - username = raw_input('Username: ') - password = getpass.getpass() - return username, password - -username, password = auth() - -try: - a = pyanidb.AniDB(username, password) - #t = a.ping() - #if t: - # print 'AniDB is reachable, %.3fs' % (t) - #else: - # print 'AniDB is unreachable.' - # sys.exit(1) - a.auth() - print 'Logged in as user %s.' % (username) - if a.new_version: - print 'New version available.' - - files = [] - for name in sys.argv[1:]: - if os.access(name, os.R_OK): - files.append(name) - else: - print 'Invalid file: %s' % (name) - for filename, hash in pyanidb.hash.hash_files(files): - hash = hash.ed2k() - size = os.stat(filename).st_size - print 'Hashed: ed2k://|file|%s|%d|%s|' % (filename, size, hash) - try: - while 1: - try: - a.add_hash(size, hash) - except pyanidb.AniDBTimeout: - print 'Connection timed out, retrying.' - continue - break - except pyanidb.AniDBUnknownFile: - print 'Unknown file: %s' % (filename) - continue - print 'Added file: %s' % (filename) - print 'All operations finished.' -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) -- cgit v1.2.3