spicadox / auto-twitter-space Goto Github PK
View Code? Open in Web Editor NEWA script that tracks when twitter spaces go live
A script that tracks when twitter spaces go live
Just want to let you know that after running it without any problems for almost 6-8 hours, SLEEP_TIME = 2
, I finally got error code 88 rate limit exceeded
.
Tried running it again using my main account auth with a 10secs sleep time, unfortunately it only ran for 2 minutes before it got rate limited.
This is the error log from my main. Unfortunately I turned off logging after closing the last ticket, so I don't know when exactly the rate limit started.
2023-07-01 23:25:32 [index.py:159] DEBUG [*****] {'errors': [{'code': 88, 'message': 'Rate limit exceeded.'}]}
2023-07-01 23:25:32 [index.py:172] DEBUG 'list' object has no attribute 'get'
Traceback (most recent call last):
File "B:\!monitoring tools\auto-twitter-space\index.py", line 162, in get_space_tweet_id
elif rest_id_json.get('errors').get(0).get('code') == 239:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'get'
2023-07-01 23:25:42 [index.py:159] DEBUG [*******] {'errors': [{'code': 88, 'message': 'Rate limit exceeded.'}]}
2023-07-01 23:25:42 [index.py:172] DEBUG 'list' object has no attribute 'get'
Traceback (most recent call last):
File "B:\!monitoring tools\auto-twitter-space\index.py", line 162, in get_space_tweet_id
elif rest_id_json.get('errors').get(0).get('code') == 239:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'get'
UPDATE:
Saw #TwitterDown is trending and a lot of people got the same error whilst browsing Twitter. I guess it had something to do with the error above. I don't know whether to close or keep this issue open. Feel free to close this if you think I should close it.
Found out after I woke up that there was a live space from my timeline but there's no notification from the discord bot. Since the log was so long for me to look through it, so I tested it using my throwaway account and found this
2023-07-26 00:35:59 [index.py:615] INFO Starting program
2023-07-26 00:36:00 [index.py:106] DEBUG URL: https://twitter.com/i/api/fleets/v1/avatar_content?user_ids=1676104621075615745&only_spaces=true
2023-07-26 00:36:00 [index.py:107] DEBUG Header: {'date': 'Tue, 25 Jul 2023 16:36:27 GMT', 'perf': '7626143928', 'vary': 'Accept-Encoding', 'server': 'tsa_k', 'set-cookie': 'guest_id_marketing=v1%3A169030298783339706; Max-Age=63072000; Expires=Thu, 24 Jul 2025 16:36:28 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None, guest_id_ads=v1%3A169030298783339706; Max-Age=63072000; Expires=Thu, 24 Jul 2025 16:36:28 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None, personalization_id="v1_ZXExWryZ6M0W1ZrIlGBn8w=="; Max-Age=63072000; Expires=Thu, 24 Jul 2025 16:36:28 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None, guest_id=v1%3A169030298783339706; Max-Age=63072000; Expires=Thu, 24 Jul 2025 16:36:28 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None', 'content-type': 'application/json', 'content-length': '1215', 'x-amzn-trace-id': 'Root=1-64bffa0b-001b3fb17d8ac4ed682a364d', 'x-transaction-id': 'e11a9de42310bfcb', 'strict-transport-security': 'max-age=631138519', 'x-response-time': '672', 'x-connection-hash': 'beac6b65fd40c0bac1fe1e88c02385a1f5048edc4f3167ee28e430403e36d27e'}
2023-07-26 00:36:00 [index.py:110] DEBUG User Spaces: {'users': {'1676104621075615745': {'spaces': {'live_content': {'audiospace': {'broadcast_id': '1BRJjZPDkaZJw', 'id': '', 'state': '', 'creator_user_id': '', 'creator_twitter_user_id': 1676104621075615745, 'primary_admin_user_id': '', 'admin_user_ids': None, 'pending_admin_user_ids': None, 'admin_twitter_user_ids': [1676104621075615745], 'pending_admin_twitter_user_ids': None, 'max_admin_capacity': 0, 'max_guest_sessions': 0, 'conversation_controls': 0, 'created_at': None, 'updated_at': None, 'ended_at': None, 'start': '2023-07-25T16:31:42.664585058Z', 'scheduled_start': None, 'canceled_at': None, 'copyright_violations': None, 'is_locked': False, 'is_employee_only': False, 'rules': None, 'topics': None, 'is_muted': False, 'is_space_creator_muted': False, 'language': 'other', 'enable_server_audio_transcription': False, 'is_space_available_for_replay': False, 'replay_start_time': None, 'is_trending': False, 'vf_safety_level': 0, 'is_featured': False, 'is_creator_top_host': False, 'narrow_cast_space_type': 0, 'disallow_join': False, 'rsvp_count': 0, 'nsfw_label_pivot': None, 'uk_ru_conflict_label_pivot': None, 'total_participating': 0, 'total_participating_public': 0, 'total_participated': 0, 'total_participated_public': 0}}, 'participants': [1676104621075615745]}}}, 'refresh_delay_secs': 30}
2023-07-26 00:36:00 [index.py:433] DEBUG [HLzGDn7h457099] Looking for spaces...
2023-07-26 00:36:31 [index.py:290] DEBUG HTTPSConnectionPool(host='twitter.com', port=443): Max retries exceeded with url: /i/api/graphql/kZ9wfR8EBtiP0As3sFFrBA/AudioSpaceById?variables=%7B%22id%22%3A%221BRJjZPDkaZJw%22%2C%22isMetatagsQuery%22%3Afalse%2C%22withListeners%22%3Atrue%2C%22withReplays%22%3Atrue%7D&features=%7B%22spaces_2022_h2_clipping%22%3Atrue%2C%22spaces_2022_h2_spaces_communities%22%3Atrue%2C%22responsive_web_graphql_exclude_directive_enabled%22%3Afalse%2C%22verified_phone_label_enabled%22%3Afalse%2C%22creator_subscriptions_tweet_preview_api_enabled%22%3Atrue%2C%22responsive_web_graphql_skip_user_profile_image_extensions_enabled%22%3Afalse%2C%22tweetypie_unmention_optimization_enabled%22%3Atrue%2C%22responsive_web_edit_tweet_api_enabled%22%3Atrue%2C%22graphql_is_translatable_rweb_tweet_is_translatable_enabled%22%3Atrue%2C%22view_counts_everywhere_api_enabled%22%3Atrue%2C%22longform_notetweets_consumption_enabled%22%3Atrue%2C%22responsive_web_twitter_article_tweet_consumption_enabled%22%3Afalse%2C%22tweet_awards_web_tipping_enabled%22%3Afalse%2C%22freedom_of_speech_not_reach_fetch_enabled%22%3Atrue%2C%22freedom_of_speech_not_reach_appeal_label_enabled%22%3Afalse%2C%22standardized_nudges_misinfo%22%3Atrue%2C%22tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled%22%3Atrue%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Atrue%2C%22longform_notetweets_rich_text_read_enabled%22%3Atrue%2C%22longform_notetweets_inline_media_enabled%22%3Atrue%2C%22responsive_web_media_download_video_enabled%22%3Afalse%2C%22responsive_web_enhance_cards_enabled%22%3Afalse%7D (Caused by ResponseError('too many 403 error responses'))
2023-07-26 00:36:31 [index.py:291] DEBUG [HLzGDn7h457099] Connection issue occurred while looking for twitter space...
2023-07-26 00:36:31 [index.py:439] DEBUG [HLzGDn7h457099] Unable to get space details...
and it keeps repeating from DEBUG URL: https://twitter.com/i/api/fleets/v1/avatar_content?user_ids=1676104621075615745&only_spaces=true
to DEBUG [HLzGDn7h457099] Unable to get space details...
over and over until the live ended.
I've tried using AUTH and CT0 from both my main and throwaway account, the problem still there. I guess they changed something when they rebranded to X, because I can no longer see the spaces details tweets (on web. mobile apps work fine.)
It will not work if a reminder is set.
[ERROR] 'NoneType' object has no attribute 'strftime'
auto-twitter-space/twitter_space_bot.py
Lines 153 to 156 in b11791d
space[0] is <Space id=id state=scheduled>
I guess I need to add some handling of reminder exceptions...
i just found out that it stopped working. there's an error saying
403 Forbiddenve twitter spaces .
When authenticating requests to the Twitter API v2 endpoints, you must use keys and tokens from a Twitter developer App that is attached to a Project. You can create a project via the developer portal.
when i looked at my twitter developer portal, i no longer can see the details of the project that i created for this app and there's no space lookup for free tier.
i saw that you've created a dev branch, space bot v2 that uses guest token, i've tried to use the v2, but unfortunately it doesn't work.
got an error , it's about const.ALL_SPACE_TIMELINE
. i don't know what it's for, so i just delete the line for that and run it again.
found some random user that's currently live and the log just said
2023-06-14 02:53:26 [twitter_space_bot_v2.py:427] INFO Starting program
2023-06-14 02:53:26 [twitter_space_bot_v2.py:95] DEBUG Guest Token Response: <Response [200]>
2023-06-14 02:53:26 [twitter_space_bot_v2.py:98] DEBUG Renewed Guest Token: 1668693141803929601
2023-06-14 02:53:27 [twitter_space_bot_v2.py:193] DEBUG Space ID for ConsultingNaz(1356907079420833792): 1yoKMZaeqQzGQ
and it keeps repeating the 4th line over and over.
2023-07-01 05:48:03 [index.py:490] INFO Starting program
2023-07-01 05:48:04 [index.py:97] DEBUG Renewed Guest Token: 1674897688343752704
2023-07-01 05:48:04 [index.py:183] DEBUG [▪️▪️▪️] JSONDecodeError: <Response [404]>
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\models.py", line 971, in json
return complexjson.loads(self.text, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\json\__init__.py", line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "B:\!monitoring tools\auto-twitter-space\index.py", line 181, in get_space_tweet_id
rest_id_json = rest_id_response.json()
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\models.py", line 975, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Just found out that we can no longer browse Twitter without an account, does this error has something to do with it? Is there anyway to make this script works again?
UPDATE:
Found this tweet from a Twitter staff, don't know whether to share it here or not but just in case
😕
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.