From e192f9ae2b268065fa5ce03db5355009cc82663c Mon Sep 17 00:00:00 2001 From: Dylan Date: Tue, 21 May 2024 20:22:07 +0100 Subject: [PATCH] Sort bearers by most recent success & fix deploy issue --- .github/workflows/deploy.yml | 2 +- twExtract/__init__.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index e881bd7..2a3ba95 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -27,7 +27,7 @@ jobs: cache: 'npm' - name: Install packages - run: npm install -g serverless + run: npm install -g serverless@3.25.1 - name: Install serverless-wsgi run: serverless plugin install -n serverless-wsgi diff --git a/twExtract/__init__.py b/twExtract/__init__.py index 30ab58b..54bd3a6 100644 --- a/twExtract/__init__.py +++ b/twExtract/__init__.py @@ -57,6 +57,11 @@ def cycleBearerTokenGet(url,headers): # try another bearer token print(f"Error 429 but {rateLimitRemaining} remaining") continue + else: + # move successful token to the front if it's not already there + if token != bearerTokens[0]: + bearerTokens.insert(0,bearerTokens.pop(bearerTokens.index(token))) + return tweet except Exception as e: pass return tweet