Exemple #1
0
    def publish(self):
        """
        Публикация поста
        """

        try:
            vk_id = re.findall(r'https?://vk\.com/wall(-?\d+_\d+)', self.link)[0]
            vk_post = clone_post(
                api=API(self.group.account_to_post.access_token),
                post=vk_id,
                to_id="-%s" % self.group.gid,
                album=self.group.album,
                cut_out={'hashtags': self.cut_out_hashtags, 'links_from_message': self.cut_out_links_from_message, 'attachment_links': self.cut_out_link_attachments},
                ac_key=self.group.account_to_post.ac_key,
                watermark_file=settings.MEDIA_ROOT + '/' + self.group.watermark.name if self.group.add_watermark is True and self.group.watermark != '' else ''
            )

            self.posted = True
            self.vk_post = vk_post
            self.when_posted = datetime.now()
        except Exception, ex:
            self.error_on_post = True
            save_err_to_db(ex, ErrorLog, template=ERROR_TEMPLATE, vk_id=vk_id, owner_id="-%s" % self.group.gid, album=self.group.album)
Exemple #2
0
 def test_clone(self):
      api = API('f0ac8a75f01f53f7f01f53f70ef0365513ff018f01a73e111aeea1643be6c9c')
      clone_post(api, '156261930_216', '', album='-14', cut_out={'attachment_links': True, 'hashtags': True, 'links_from_message': True}, ac_key='', watermark_file='media/watermarks/watermark1.jpg')