go back to passwords, use diff format

This commit is contained in:
muskit
2024-04-19 23:30:28 -07:00
parent 18dfb0a7c9
commit bacc426a6d
3 changed files with 32 additions and 26 deletions
+3 -2
View File
@@ -11,13 +11,14 @@ class AccountPool:
creds = dotenv_values(working_path(file=".env"))
i = 0
while True:
if f"scraper_username_{i}" in creds and f"scraper_auth_token_{i}" in creds:
if f"scraper{i}_username" in creds and f"scraper{i}_password" in creds:
self.__accounts.append(
(creds[f"scraper_username_{i}"], creds[f"scraper_auth_token_{i}"])
(creds[f"scraper{i}_username"], creds[f"scraper{i}_password"])
)
i += 1
else:
break
print(f"{len(self.__accounts)} scraper credentials found!")
def use_index(self, idx):
self.__idx = idx
+7 -4
View File
@@ -1,6 +1,7 @@
from os.path import exists
from time import sleep
from datetime import datetime, timedelta
import traceback
import pytz
@@ -37,9 +38,9 @@ class Scraper:
try:
self.app.connect()
except:
self.app.load_auth_token(acc[1])
self.app.sign_in(*acc)
else:
self.app.load_auth_token(acc[1])
self.app.sign_in(*acc)
return True
print("exhausted all accounts!")
return False
@@ -101,12 +102,14 @@ class Scraper:
if "_Missing" in e.message: # tweet is probably unavailable
print(f"tweet {id} seems unavailable; skipping...")
return None
print("treating like RateLimitReached...")
print("treating like RateLimitReached and using the next scraper...")
# traceback.print_exc()
self.login_wait(private_user)
except Exception as e:
if not private_user:
print("Unhandled exception occurred, trying again as private...")
print("Unhandled exception occurred getting tweet!")
traceback.print_exc()
print("trying again as pvt-accessible...\n")
return self.get_tweet(id, True)
else:
print(