コード例 #1
0
ファイル: imgur.py プロジェクト: pmdevita/GifReversingBot
    def analyze(self) -> bool:
        """Analyze an imgur gif and determine how to reverse and upload"""

        if not self.pic:
            return False
        # pprint(self.pic)

        if not self.pic['animated']:
            print("Not a gif!")
            return False
        r = requests.get(self.pic['mp4'])
        file = BytesIO(r.content)
        self.duration = get_duration(file)

        self.files.append(GifFile(file, host=self.host, gif_type=consts.MP4, duration=self.duration,
                                  size=self.pic['mp4_size']/1000000))

        # If the file type is a gif, add it as an option and prioritize it
        if self.pic['type'] == 'image/gif':
            r = requests.get(self.pic['gifv'][:-1])
            gif = BytesIO(r.content)
            if is_valid(gif):
                gif_file = GifFile(gif, host=self.host, gif_type=consts.GIF, duration=self.duration)
            # else:
            #     gif_file = GifFile(file, host=self.host, gif_type=consts.GIF, duration=self.duration)
                print("added gif file")
                self.files.insert(0, gif_file)
        print(self.files)
        return True
コード例 #2
0
ファイル: catbox.py プロジェクト: prasadiw/GifReversingBot
 def analyze(self):
     r = requests.get(self.url)
     file = BytesIO(r.content)
     if not is_valid(file):
         return False
     file = GifFile(file, self.host, consts.GIF)
     self.files.append(file)
     vid_file = GifFile(file,
                        self.host,
                        self.id.split(".")[-1],
                        audio=False)
     if self.id[-3:] == consts.GIF:
         self.files.append(vid_file)
     else:
         self.files.insert(0, vid_file)
     return True
コード例 #3
0
ファイル: imgur.py プロジェクト: prasadiw/GifReversingBot
    def analyze(self) -> bool:
        """Analyze an imgur gif using the imgurpython library and determine how to reverse and upload"""

        if not self.pic:
            return False
        pprint(vars(self.pic))

        if not self.pic.animated:
            print("Not a gif!")
            return False
        r = requests.get(self.pic.mp4)
        file = BytesIO(r.content)
        self.duration = get_duration(file)

        self.files.append(
            GifFile(file,
                    host=self.host,
                    gif_type=consts.MP4,
                    duration=self.duration,
                    size=self.pic.mp4_size / 1000000))

        # If the file type is a gif, add it as an option and prioritize it
        if self.pic.type == 'image/gif':
            r = requests.get(self.pic.gifv[:-1])
            gif = BytesIO(r.content)
            if is_valid(gif):
                gif_file = GifFile(gif,
                                   host=self.host,
                                   gif_type=consts.GIF,
                                   duration=self.duration)
            else:
                gif_file = GifFile(file,
                                   host=self.host,
                                   gif_type=consts.GIF,
                                   duration=self.duration)
            self.files.insert(0, gif_file)

        return True