#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys, getopt
if sys.version_info[0] < 3:
    raise Exception("Python 2.x is not supported. Please upgrade to 3.x")
import got


def main(argv):

    if len(argv) == 0:
        print('You must pass some parameters. Use \"-h\" to help.')
        return

    if len(argv) == 1 and argv[0] == '-h':
        f = open('exporter_help_text.txt', 'r')
        print(f.read())
        f.close()
        return

    try:
        opts, args = getopt.getopt(argv, "", ("username=",
                                              "near=",
                                              "within=",
                                              "since=",
                                              "until=",
                                              "querysearch=",
                                              "toptweets",
                                              "maxtweets=",
                                              "output="))

        tweetCriteria = got.manager.TweetCriteria()
        outputFileName = "output_got.csv"

        for opt,arg in opts:
            if opt == '--username':
                tweetCriteria.username = arg

            elif opt == '--since':
                tweetCriteria.since = arg

            elif opt == '--until':
                tweetCriteria.until = arg

            elif opt == '--querysearch':
                tweetCriteria.querySearch = arg

            elif opt == '--toptweets':
                tweetCriteria.topTweets = True

            elif opt == '--maxtweets':
                tweetCriteria.maxTweets = int(arg)
            
            elif opt == '--near':
                tweetCriteria.near = '"' + arg + '"'
            
            elif opt == '--within':
                tweetCriteria.within = '"' + arg + '"'

            elif opt == '--output':
                outputFileName = arg
                
        outputFile = open(outputFileName, "w+", encoding="utf8")
        outputFile.write('date,username,retweets,favorites,text,geo,mentions,hashtags,id,permalink\n')

        print('Searching...\n')

        def receiveBuffer(tweets):
            for t in tweets:
                data = [t.date.strftime("%Y-%m-%d %H:%M:%S"),
                    t.username,
                    t.retweets,
                    t.favorites,
                    '"'+t.text.replace('"','""')+'"',
                    t.geo,
                    t.mentions,
                    t.hashtags,
                    t.id,
                    t.permalink]
                data[:] = [i if isinstance(i, str) else str(i) for i in data]
                outputFile.write(','.join(data) + '\n')

            outputFile.flush()
            print('More %d saved on file...\n' % len(tweets))

        got.manager.TweetManager.getTweets(tweetCriteria, receiveBuffer)

    except getopt.GetoptError as err:
        print('Arguments parser error, try -h')
        print('\n\t' + err.msg)

    except Exception as err:
        print('Error: ' + err.msg)

    finally:
        if "outputFile" in locals():
            outputFile.close()
            print('Done. Output file generated "%s".' % outputFileName)

if __name__ == '__main__':
    main(sys.argv[1:])

@@ -47,16 +47,20 @@
 %0A%0Aimport
+ os,
  sys, ge
@@ -1891,32 +1891,16 @@
 e = arg%0A
-                
 %0A       
@@ -2073,32 +2073,15 @@
     
-print('Searching...%5Cn')%0A
+cnt = 0
 %0A   
@@ -2112,16 +2112,42 @@
 weets):%0A
+            nonlocal cnt%0A%0A
         
@@ -2712,58 +2712,229 @@
     
-print('More %25d saved on file...%5Cn' %25 len(
+cnt += len(tweets)%0A%0A            if sys.stdout.isatty():%0A                print(%22%5CrSaved %25i%22%25cnt, end='', flush=True)%0A            else:%0A                print(cnt, end=' ', flush=True)%0A%0A        print(%22Downloading 
 tweets
-))%0A
+...%22)
 %0A   
@@ -3261,32 +3261,52 @@
 putFile.close()%0A
+            print()%0A
             prin

Add informer of the total amount of downloaded tweets