tweets = {}
for line in archive.readlines():
- tid, text = line.strip().split(" ", 1)
- tweets[int(tid)] = text.decode("utf-8")
+ try:
+ tid, text = line.strip().split(" ", 1)
+ tweets[int(tid)] = text.decode("utf-8")
+ except Exception as e:
+ err("loading tweet %s failed due to %s" % (line, unicode(e)))
archive.close()
return tweets
return
for k in sorted(tweets.keys()):
- archive.write("%i %s\n" % (k, tweets[k].encode('utf-8')))
+ try:
+ archive.write("%i %s\n" % (k, tweets[k].encode('utf-8')))
+ except Exception as ex:
+ err("archiving tweet %s failed due to %s" % (k, unicode(ex)))
archive.close()
# authenticate using OAuth, asking for token if necessary
if options['oauth']:
- oauth_filename = (os.getenv("HOME", "") + os.sep
- + ".twitter-archiver_oauth")
+ oauth_filename = (os.environ.get('HOME',
+ os.environ.get('USERPROFILE', ''))
+ + os.sep
+ + '.twitter-archiver_oauth')
+
if not os.path.exists(oauth_filename):
oauth_dance("Twitter-Archiver", CONSUMER_KEY, CONSUMER_SECRET,
oauth_filename)