timeline progressbars
@@ -699,11 +699,27 @@ def timeline(
)
count = 0
+
+ pbar = tqdm(disable=hide_progress, total=3200)
+ if use_search:
+ pbar = TimestampProgressBar(
+ since_id, until_id, start_time, end_time, disable=hide_progress
+ )
+
+ with pbar as progress:
for result in tweets:
_write(result, outfile)
count += len(result["data"])
+ if use_search and isinstance(pbar, TimestampProgressBar):
+ progress.update_with_result(result)
+ else:
+ progress.update(len(result["data"]))
+
if limit != 0 and count >= limit:
+ # Display message when stopped early
+ progress.desc = f"Set --limit of {limit} reached"
+ progress.early_stop = True
break
@@ -766,7 +782,10 @@ def timelines(
total_count = 0
line_count = 0
seen = set()
+
+ with FileSizeProgressBar(infile, disable=hide_progress) as progress:
for line in infile:
+ progress.update(len(line))
line_count += 1
line = line.strip()
if line == "":
@@ -778,7 +797,9 @@ def timelines(
# first try to get user ids from a flattened Twitter response
json_data = json.loads(line)
try:
- users = set([t["author"]["id"] for t in ensure_flattened(json_data)])
+ users = set(
+ [t["author"]["id"] for t in ensure_flattened(json_data)]
+ )
except (KeyError, ValueError):
# if it's not tweet JSON but it parsed as a string use that as a user
if isinstance(json_data, str) and json_data:
@@ -972,7 +993,10 @@ def conversations(
count = 0
stop = False
+
+ with FileSizeProgressBar(infile, disable=hide_progress) as progress:
for line in infile:
+ progress.update(len(line))
conv_ids = []
# stop will get set when the total tweet limit has been met
