agermanidis / SnapchatBot

[deprecated] Python library for building bots that live on Snapchat
MIT License
517 stars 105 forks source link

Saved images are empty. #13

Closed N07070 closed 9 years ago

N07070 commented 9 years ago

Hello, I tried this :

#!/usr/bin/python
# -*- coding: utf-8 -*-
from argparse import ArgumentParser
from snapchat_bots import SnapchatBot, Snap
from snapchat_bots.utils import save_snap

class FbStoryBot(SnapchatBot):

    # Acceuillir l'utilisateur
    def on_friend_add(self, friend):
        self.log(str(friend)+" has added me !")
        self.send_snap(friend, Snap.from_file('resources/auto_welcome.png'))

    # Dire au revoir si il nous supprime
    def on_friend_delete(self, friend):
        self.log(str(friend)+" does not want me anymore...")
        self.send_snap(friend, Snap.from_file('resources/adieu.png'))
        self.log("Said goodbye.")
        self.delete_friend(friend)

    # Ajout d'une story
    def on_snap(self, sender, snap):
        # Ajout d'un log dans un fichier texte ?
        self.log("Recived a snap from "+str(sender))
        self.post_story(snap)
        self.log("Saved the snap in the directory.")
        save_snap(snap)

if __name__ == '__main__':
    # parser = ArgumentParser('Auto-Welcomer Bot')

    # parser.add_argument('-u', '--username', required=True, type=str, help="Username of the account to run the bot on")
    # parser.add_argument('-p', '--password', required=True, type=str, help="Password of the account to run the bot on")

    # args = parser.parse_args()

    bot = FbStoryBot('xxxxx', 'xxxxx')
    #Lister tout les utilisateurs puis le nombre d'utilisateurs.
    bot.listen()

but when I display it ( on a computer, or with Imagemagick with X forwarding ), it give an empyt image.

Any ideals ?

EthanBlackburn commented 9 years ago

I just tried it on OSX 10.9.5 and it saves the image correctly. What OS are you on?

N07070 commented 9 years ago

Linux, Debian. Up-to-date, last version. I works on a other linux, based on ubuntu.

EthanBlackburn commented 9 years ago

Just tested on RHEL 6.6 and the image is indeed empty. I'll take a look

EthanBlackburn commented 9 years ago

Actually it looks like none of SnapchatBots functionalities are working at all on RHEL 6.6. The bot doesn't even recognize snaps. I think this is a deeper issue than just image capture

N07070 commented 9 years ago

I chmod 777 the directory where they are saved, no change. It's not linux, cause it's working on my desktop. Did you use your bot in a desktop env. ? Because, when it works, I'm in a desktop. So, maybe that's the thing ?

identify.im6: Empty input file snapbot_saves/xxxx-2.23.2015-0:37:42.jpg' @ error/jpeg.c/JPEGErrorHandler/316.

EthanBlackburn commented 9 years ago

I tested in a virtualenv and without. They both worked on OSX 10.9.5. Neither works on red hat

EthanBlackburn commented 9 years ago

Ahh, I found the error. line 64 in snap.py:

if self.media_type is MEDIA_TYPE_VIDEO or MEDIA_TYPE_VIDEO_WITHOUT_AUDIO

should be

if self.media_type is MEDIA_TYPE_VIDEO or self.media_type is MEDIA_TYPE_VIDEO_WITHOUT_AUDIO

agermanidis commented 9 years ago

Thanks @EthanBlackburn for fixing this! @N07070, do you still get empty snap saves after the latest commit?

N07070 commented 9 years ago

Yep, now my images are HD ! Thanks !