Skip to content

Commit

Permalink
Premium endpoints w/ tweet_mode
Browse files Browse the repository at this point in the history
It seems that the Premium endpoints no longer being sent the tweet_mode
query parameter. This commit ensures that it is not sent with GNIP or
Premium API calls.

Fixes #360
  • Loading branch information
edsu committed Dec 14, 2020
1 parent 15e64b7 commit 5c5e548
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ notifications:
secure: PY7GyhVBacVqytImbrcyKlDY/uVDTtOMMQ8bEDnhbH9XZA7nOD0dXsEffz93tA1ldJd1+0zsnt9itqdk4pYXBMTcZ6uWE5H2j7KIYylQa2A2Sj5GC3/KjrbFGfqMAXYs+rc9rrlqYkwjztu+bnNqTDnq0Y4Pw0YlMs23NT6GlMg=
env:
global:
- TWITTER_ENV: docnowdev
- secure: iztxqCY9N5v5Zx7wkjrU91Sa6QBHHYDaFcqBp22CnaU2LP4bWYS5oM6M3aRku8Xj9c2dgWmqyuMstAgAWTkz8ws3yLrUI50Nr+Q+RldEt+KAi2znVahgJQOQHasQwtd1IXca1i8XSUcKtCQyd3ihj3Ycw5yRLSv04EazOB0EOiU=
- secure: RK31uyLWaMjCyDQrk8goy5HfHZNuJzqe1UjAXtkh1se7KjVacBqiYnjFj4vLio/hVPkygp9k33Ls+m7qXBkBlk1kzmr37na1z2yVjg9Wo2Nq/wtBFwGy33uVgeWOHIo2ac86XIYBQZABo+3o/Zq9ukYgRGQoyEG3c80oClHSTIk=
- secure: dWVB5UlbkcGS/owMqppttM3kluV4/SA5ABqH1GlTnsRp7zl4TM7v+Ds/xCr7b4q+SFjEz9+mwdlqU2P/rwVfYiuKTQT/oAWaUBLgQJX8nO4GspD4cOg4okGeAsoZ993C8cUjnpeDp9aq99IpJizd0emzuncc0NzBBvIQlc2+zKA=
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from setuptools import setup

# Also in twarc/__init__.py
__version__ = '1.12.0'
__version__ = '1.12.1'

with open("README.md") as f:
long_description = f.read()
Expand Down
2 changes: 1 addition & 1 deletion twarc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '1.12.0' # also in setup.py
__version__ = '1.12.1' # also in setup.py

from .client import Twarc
from .command import main
14 changes: 12 additions & 2 deletions twarc/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -774,8 +774,8 @@ def get(self, *args, **kwargs):
if not self.client:
self.connect()

# set default tweet_mode; only used for non-gnip endpoints
if not args[0].startswith("https://gnip-api"):
# set default tweet_mode; only used for non-premium/non-gnip endpoints
if self.is_standard_v1(args[0]):
if "params" not in kwargs:
kwargs["params"] = {"tweet_mode": self.tweet_mode}
else:
Expand Down Expand Up @@ -1081,4 +1081,14 @@ def configure(self):
def default_config(self):
return os.path.join(os.path.expanduser("~"), ".twarc")

def is_standard_v1(self, url):
result = True
if url.startswith('https://gnip-api.twitter.com'):
result = False
elif url.startswith('https://api.twitter.com/1.1/tweets/search/30day'):
result = False
elif url.startswith('https://api.twitter.com/1.1/tweets/search/fullarchive'):
result = False
return result


0 comments on commit 5c5e548

Please sign in to comment.