Giter Site home page Giter Site logo

tweetcam's People

Contributors

arashmarzi avatar mikestreety avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

tweetcam's Issues

TypeError: argument to reversed() must be a sequence

@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?

Handle a 400 error - try and reupload

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."}

Add streaming

Rather than waiting up to a minute to send, it should use streaming to action and reply instantly

TypeError: string indices must be integers

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

Make getting tweet text a function of sorts

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))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.