Skip to content
This repository was archived by the owner on Aug 7, 2024. It is now read-only.

Commit 1414e12

Browse files
authored
Merge pull request #414 from bear/develop
merge 3.2 Develop branch to prepare for release
2 parents 5c5ddbd + 6a3bc3d commit 1414e12

29 files changed

Lines changed: 751 additions & 568 deletions

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ docs:
3737
$(MAKE) -C doc html
3838

3939
lint:
40-
flake8 twitter > violations.flake8.txt
40+
pycodestyle --config={toxinidir}/setup.cfg twitter tests
4141

4242
test: lint
4343
python setup.py test

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ You can install python-twitter using::
4444

4545
$ pip install python-twitter
4646

47-
47+
4848
If you are using python-twitter on Google App Engine, see `more information <GAE.rst>`_ about including 3rd party vendor library dependencies in your App Engine project.
4949

5050

doc/changelog.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ What's New
3636

3737
* Google App Engine support has been reintegrated into the library. Check out `PR #383 <https://github.com/bear/python-twitter/pull/383>`_.
3838

39+
* `video_info` is now available on a `twitter.models.Media` object, which allows access to video urls/bitrates/etc. in the `extended_entities` node of a tweet.
40+
3941
What's Changed
4042
--------------
4143

@@ -99,3 +101,5 @@ ______________
99101
* Updated examples, specifically ``examples/twitter-to-xhtml.py``, ``examples/view_friends.py``, ``examples/shorten_url.py``
100102

101103
* Updated ``get_access_token.py`` script to be python3 compatible.
104+
105+
* :py:func:`twitter.api.Api.GetStreamFilter()` now accepts an optional languages parameter as a list.

doc/changes_to_tweet_counting.rst

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
REST API Changes
2+
=================
3+
4+
Information compiled on Sept 14, 2016.
5+
6+
``statuses/update`` Endpoint
7+
----------------------------
8+
9+
``auto_populate_reply_metadata``
10+
+++++++++++++++++++++++++++++++
11+
12+
* Default is ``false``
13+
14+
* Must have ``in_reply_to_status_id`` set.
15+
16+
* Unknown what happens if not set. Probably error (does it get posted?)
17+
18+
* If the status to which you're replying is deleted, tweet will fail to post.
19+
20+
``exclude_reply_user_ids``
21+
++++++++++++++++++++++++++
22+
23+
* List of ``user_ids`` to remove from result of ``auto_populate_reply_metadata``.
24+
25+
* Doesn't apply to the first ``user_id``.
26+
27+
* If you try to remove it, this will be silently ignored by Twitter.
28+
29+
``attachment_url``
30+
++++++++++++++++++
31+
32+
* Must be a status permalnk or a DM deep link.
33+
34+
* If it's anything else and included in this parameter, Twitter will return an error.
35+
36+
37+
Most Other Endpoints
38+
--------------------
39+
40+
``tweet_mode``
41+
++++++++++++++
42+
43+
* Any endpoint that returns a tweet will accept this param.
44+
45+
* Must be in ``['compat', 'extended']``
46+
47+
* If ``tweet_mode == 'compat'``, then no ``extended_tweet`` node in the json returned.
48+
49+
* If ``tweet_mode == 'extended'``, then you'll get the ``extended_tweet`` node.
50+
51+
52+
Errors
53+
------
54+
* 44 -> URL passed to attachment_url is invalid
55+
56+
* 385 -> Replied to deleted tweet or tweet not visible to you
57+
58+
* 386 -> Too many attachments types (ie a GIF + quote tweet)
59+
60+
61+
Streaming API
62+
=============
63+
64+
Everything is going to be compatibility mode for now; however **all** tweets with have an ``extended_tweet`` node, which will contain the new information. According to Twitter's documentation though, there's the possibility that this node may not exist. We should be careful about making assumptions here.
65+
66+
67+
Changes to Models
68+
=================
69+
70+
Classic tweet: tweet with length < 140 char.
71+
Extended tweet: tweet with extended entities and text > 140 chars.
72+
73+
Twitter doesn't say if extended tweet with a total length of < 140 characters will be considered a "Classic tweet". They also state that an extended tweet shall have "text content [that] exceeds 140 characters in length", however this is contradictory to earlier statements about total text length retaining a hard max at 140 characters.
74+
75+
There will be two rendering modes: Compatibility and Extended. If in compatibility mode and tweet is "classic", no changes to tweet JSON. If in Extended mode, the following will change:
76+
77+
* ``text`` -> truncated version of the extended tweet's text + "..." + permalink to tweet. (Twitter is mute on whether an extended tweet's with (text + @mentions + urls) < 140 characters will have the @mentions + urls put back in ``text`` field.)
78+
79+
* ``truncated`` -> gets set to ``True`` if extended tweet is rendered in compat mode.

doc/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@
5757
# built documents.
5858
#
5959
# The short X.Y version.
60-
version = '3.1'
60+
version = '3.2'
6161
# The full version, including alpha/beta/rc tags.
62-
release = '3.1'
62+
release = '3.2dev0'
6363

6464
# The language for content autogenerated by Sphinx. Refer to documentation
6565
# for a list of supported languages.

examples/streaming/track_users.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
# ----------------------------------------------------------------------
1818

19-
# This file demonstrates how to track mentions of a specific set of users and
20-
# archive those mentions to a local file. The output file will contain one
21-
# JSON string per line per Tweet.
19+
# This file demonstrates how to track mentions of a specific set of users in
20+
# english language and archive those mentions to a local file. The output
21+
# file will contain one JSON string per line per Tweet.
2222

2323
# To use this example, replace the W/X/Y/Zs with your keys obtained from
2424
# Twitter, or uncomment the lines for getting an environment variable. If you
@@ -52,6 +52,10 @@
5252
'@twitterapi',
5353
'@support']
5454

55+
# Languages to filter tweets by is a list. This will be joined by Twitter
56+
# to return data mentioning tweets only in the english language.
57+
LANGUAGES = ['en']
58+
5559
# Since we're going to be using a streaming endpoint, there is no need to worry
5660
# about rate limits.
5761
api = Api(CONSUMER_KEY,
@@ -64,7 +68,7 @@ def main():
6468
with open('output.txt', 'a') as f:
6569
# api.GetStreamFilter will return a generator that yields one status
6670
# message (i.e., Tweet) at a time as a JSON dictionary.
67-
for line in api.GetStreamFilter(track=USERS):
71+
for line in api.GetStreamFilter(track=USERS, languages=LANGUAGES):
6872
f.write(json.dumps(line))
6973
f.write('\n')
7074

examples/view_friends.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@
3636

3737

3838
# Create an Api instance.
39-
api = twitter.Api(consumer_key='consumer_key',
40-
consumer_secret='consumer_secret',
41-
access_token_key='access_token',
42-
access_token_secret='access_token_secret')
39+
api = twitter.Api(consumer_key=CONSUMER_KEY,
40+
consumer_secret=CONSUMER_SECRET,
41+
access_token_key=ACCESS_TOKEN,
42+
access_token_secret=ACCESS_TOKEN_SECRET)
4343

4444
users = api.GetFriends()
4545

requirements.testing.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ pytest
77
pytest-cov
88
pytest-runner
99
mccabe
10-
flake8
1110
mock
1211
six
1312
coverage

setup.cfg

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ ignore =
88
violations.flake8.txt
99

1010
[flake8]
11-
ignore = E111,E124,E126,E201,E202,E221,E241,E302,E501
11+
ignore = E111,E124,E126,E221,E501
1212

1313
[pep8]
14-
ignore = E111,E124,E126,E128,E201,E202,E221,E226,E241,E301,E302,E303,E402,E501,W291
15-
max-line-length = 160
14+
ignore = E111,E124,E126,E221,E501
15+
max-line-length = 100
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"contributors": null, "in_reply_to_status_id_str": null, "lang": "en", "source": "<a href=\"http://twitter.com\" rel=\"nofollow\">Twitter Web Client</a>", "in_reply_to_user_id": null, "possibly_sensitive_appealable": false, "coordinates": null, "truncated": true, "retweet_count": 0, "retweeted": false, "possibly_sensitive": false, "in_reply_to_user_id_str": null, "entities": {"symbols": [], "user_mentions": [], "urls": [{"expanded_url": "https://twitter.com/i/web/status/782737772490600448", "indices": [117, 140], "url": "https://t.co/et3OTOxWSa", "display_url": "twitter.com/i/web/status/7\u2026"}], "hashtags": []}, "geo": null, "is_quote_status": false, "favorite_count": 0, "id_str": "782737772490600448", "id": 782737772490600448, "created_at": "Mon Oct 03 00:23:22 +0000 2016", "text": "has more details about these changes. Thanks for making more expressive!writing requirements to python_twitt pytho\u2026 https://t.co/et3OTOxWSa", "place": null, "in_reply_to_screen_name": null, "in_reply_to_status_id": null, "favorited": false, "user": {"follow_request_sent": false, "protected": true, "default_profile_image": true, "profile_sidebar_fill_color": "000000", "favourites_count": 1, "utc_offset": null, "has_extended_profile": false, "lang": "en", "profile_image_url": "http://abs.twimg.com/sticky/default_profile_images/default_profile_2_normal.png", "friends_count": 2, "profile_text_color": "000000", "geo_enabled": true, "profile_banner_url": "https://pbs.twimg.com/profile_banners/4012966701/1453123196", "verified": false, "listed_count": 1, "is_translator": false, "location": "", "entities": {"description": {"urls": []}}, "name": "notinourselves", "is_translation_enabled": false, "time_zone": null, "id_str": "4012966701", "profile_background_tile": false, "followers_count": 1, "profile_sidebar_border_color": "000000", "contributors_enabled": false, "following": false, "description": "", "url": null, "statuses_count": 84, "default_profile": false, "profile_link_color": "000000", "profile_image_url_https": "https://abs.twimg.com/sticky/default_profile_images/default_profile_2_normal.png", "notifications": false, "profile_background_image_url": "http://pbs.twimg.com/profile_background_images/736320724164448256/LgaAQoav.jpg", "screen_name": "notinourselves", "profile_background_image_url_https": "https://pbs.twimg.com/profile_background_images/736320724164448256/LgaAQoav.jpg", "id": 4012966701, "profile_use_background_image": true, "created_at": "Wed Oct 21 23:53:04 +0000 2015", "profile_background_color": "000000"}}

0 commit comments

Comments
 (0)