liquidlight / tweetcam Goto Github PK
View Code? Open in Web Editor NEWTweetcam - tweet a twitter account and, using a raspberry pi, get a photo or video back
Tweetcam - tweet a twitter account and, using a raspberry pi, get a photo or video back
If the tweet is a delayed one, still update last reply ID
Take inspiration from here:
Add more tweet text for photos and videos
@mikestreety:
I have cloned your repo and installed all necessary imports (TwitterAPI, requests, etc.), I have changed _config.cfg to contain my own keys and did not touch any of the other default settings from the .skel file.
When I run python bot.py, as instructed by your README, I get the following error message from my Raspberry Pi:
Traceback (most recent call last):
File "bot.py", line 10, in <module>
for tweet in reversed(mentions):
TypeError: argument to reversed() must be a sequence
my bot.py looks like this:
#!/usr/bin/env python
# SETUP: Import global modules
import TweetStreetCam
g = TweetStreetCam.GraffCam()
mentions = g.GetMentions()
if mentions:
for tweet in reversed(mentions):
g.ActionTweet(tweet)
for tweet in g.GetStream():
if 'text' in tweet:
g.ActionTweet(tweet)
Im assuming this is a python problem right off the bat and might not have to do with my cloned version. The most apparent thing is that we are a TwitterResponse object back but the reversed method cannot handle it.
Do you know of a way to correct this?
Add instructions in a readme
Keep track of any failures and keep trying - rather than re-recording
Python allows you to get the current path:
os.path.dirname(os.path.abspath(__file__))
Can replace this:
https://github.com/liquidlight/graffcam/blob/master/TweetStreetCam.py#L22
And there would then be no need for the path in the config file
AVC-H264 import - frame size 1280 x 720 at 25.000 FPS
AVC Import results: 209 samples - Slices: 4 I 205 P 0 B - 0 SEI - 4 IDR
Saving /home/pi/tweet/media/videos/662227019011346433.mp4: 0.500 secs Interleaving
/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
400
{"request":"\/1.1\/media\/upload.json","error":"segment size must be \u003C= 1."}
Rather than waiting up to a minute to send, it should use streaming to action and reply instantly
If a video or image is successfully uploaded, delete it from the file system
Hi @mikestreety looks like my fix for #16 created another bug in its place; it is reproduced when the last_mention_id = 0. The resulting error is:
{u'errors': [{u'message': u'since_id parameter is invalid.', u'code': 44}]}
Traceback (most recent call last):
File "bot.py", line 7, in
mentions = g.GetMentions()
File "/home/amarzi/Documents/tweetcam/TweetStreetCam.py", line 64, in GetMentions
mentions = sorted(mentions, key=lambda k:k['id'])
File "/home/amarzi/Documents/tweetcam/TweetStreetCam.py", line 64, in
mentions = sorted(mentions, key=lambda k:k['id'])
TypeError: string indices must be integers
where the first line is the contents of the mentions response from twitter.
Can you try it on your system to see if you get the same bug/result?
I have a fix for it just in case; if twitter cannot somehow handle a 0 value for since_id then we can send in a parameterless mentions_timeline request like this: mentions = self.api.request('statuses/mentions_timeline', {}).json()
if that value is 0, otherwise we will send a parametered mentions_timeline request like before: mentions = self.api.request('statuses/mentions_timeline', {'since_id': last_mention_id}).json()
The revised GetMentions() method would be as follows:
def GetMentions(self):
last_mention_id = self.config.get('tweets', 'last_mention_id')
if last_mention_id == str(0):
mentions = self.api.request('statuses/mentions_timeline', {}).json()
else:
mentions = self.api.request('statuses/mentions_timeline', {'since_id': last_m$
mentions = sorted(mentions, key=lambda k:k['id'])
return mentions
As it's all over the shop now:
start_status = random.choice(json.loads(self.config.get('tweet_text', 'preperation')))
start_status = start_status.replace('[[user]]', '@%s' % (username))
The logging is a bit all over the place and repeats itself (and misses the fact uploads fail...)
If the tweet is more then X minutes old, rather than replying with a video/image, reply with an appology
For quick set up
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.