When I finished my work and wanted to watch Twitter's TL, I didn't have time to watch Twitter because I had a lot of other things I wanted to do, so I just listened to the iPhone talking.
iPhone8 13.2.3 Pythonista3 3.2 Tweepy 3.5.0
・ Installation of Pythonista3 ・ Twitter API registration application (Reference: Play with Python using Twitter API) ・ Installation of StaSh (Reference: Install StaSh on Pythonista 3) ・ Installation of Tweepy
This time I made the following file structure. ├─ twitterconfig.py # Manage credentials ├─sp_timeline.py # Code that actually works └
sp_timeline.py
#!Pythonista3
#Program to have iphone read your TL
import time, speech, twitterconfig
from twitterconfig import api
shu_kai = 0
maxid = None
while True:
home_tweet = api.home_timeline(max_id=maxid)
#Measures to prevent the last tweet of the first lap and the first tweet of the second lap from overlapping on the second lap
if maxid != None:
home_tweet = home_tweet[1:]
for tweet in home_tweet:
print('__________________________________________')
#View of tweeter
print(tweet.user.name + '(@' + tweet.user.screen_name +')')
#Display of tweet text
print(tweet.text)
#Do not read the link aloud
if 'https' in tweet.text:
https_ofset = tweet.text.find('https')
tweet.text = tweet.text[:https_ofset]
speech.say(tweet.text, 'ja-JP', 0.5)
time.sleep(15)
shu_kai += 1
shu_kai_text = str(shu_kai) + 'End of lap'
print('--------------',shu_kai_text,'--------------')
#maxid to the last tweet.Make it an id, and then bring an older timeline.
maxid = tweet.id
time.sleep(60)
It might be useful for Twitter addicts like me, as I can listen to TL while working elsewhere. However, the pronunciation of iPhone is not so good, so it might be a good idea to find someone else ...