Пример #1
0
def download(update, context):
    """Send a link of gathered infos and medias to downloading them."""
    user = update.message.from_user

    if str(user.id) in ADMINS:
        images_url = utils.download_zip_url(prefixes="/",
                                            resource_type="image")
        videos_url = utils.download_zip_url(prefixes="/",
                                            resource_type="video")
        update.message.reply_text('لینک دانلود آماده شد:\n'
                                  'برای دانلود تصاویر:\n'
                                  f'{images_url}\n'
                                  'برای دانلود فیلم‌ها:\n'
                                  f'{videos_url}')
    else:
        logger.info(
            f"A new user want be admin! its id: {user.id} - {user.username}")
        update.message.reply_text('کی گفته بهت این دستور کار می‌کنه؟')
Пример #2
0
 def test_archive_url(self):
     result = utils.download_zip_url(tags = [TEST_TAG], transformations = [{"width": 0.5},{"width": 2.0}])
     response = urllib2.urlopen(result)
     temp_file = tempfile.NamedTemporaryFile()
     temp_file_name = temp_file.name
     temp_file.write(response.read())
     temp_file.flush()
     with zipfile.ZipFile(temp_file_name, 'r') as zip_file:
         infos = zip_file.infolist()
         self.assertEqual(4, len(infos))
     temp_file.close()
Пример #3
0
 def test_download_zip_url_options(self):
     result = utils.download_zip_url(tags=[TEST_TAG],
                                     transformations=[{
                                         "width": 0.5
                                     }, {
                                         "width": 2.0
                                     }],
                                     cloud_name="demo")
     upload_prefix = cloudinary.config(
     ).upload_prefix or "https://api.cloudinary.com"
     six.assertRegex(self, result,
                     r'^{0}/v1_1/demo/.*$'.format(upload_prefix))
Пример #4
0
 def test_archive_url(self):
     result = utils.download_zip_url(tags=[TEST_TAG], transformations=[{"width": 0.5}, {"width": 2.0}])
     http = urllib3.PoolManager()
     response = http.request('get', result)
     with tempfile.NamedTemporaryFile() as temp_file:
         temp_file_name = temp_file.name
         temp_file.write(response.data)
         temp_file.flush()
         with zipfile.ZipFile(temp_file_name, 'r') as zip_file:
             infos = zip_file.infolist()
             self.assertEqual(4, len(infos))
     http.clear()
Пример #5
0
 def test_archive_url(self):
     result = utils.download_zip_url(tags=[TEST_TAG], transformations=[{"width": 0.5}, {"width": 2.0}])
     http = urllib3.PoolManager()
     response = http.request('get', result)
     with tempfile.NamedTemporaryFile() as temp_file:
         temp_file_name = temp_file.name
         temp_file.write(response.data)
         temp_file.flush()
         with zipfile.ZipFile(temp_file_name, 'r') as zip_file:
             infos = zip_file.infolist()
             self.assertEqual(4, len(infos))
     http.clear()
Пример #6
0
 def test_archive_url(self):
     result = utils.download_zip_url(tags=[TEST_TAG],
                                     transformations=[{
                                         "width": 0.5
                                     }, {
                                         "width": 2.0
                                     }])
     response = urllib2.urlopen(result)
     temp_file = tempfile.NamedTemporaryFile()
     temp_file_name = temp_file.name
     temp_file.write(response.read())
     temp_file.flush()
     with zipfile.ZipFile(temp_file_name, 'r') as zip_file:
         infos = zip_file.infolist()
         self.assertEqual(4, len(infos))
     temp_file.close()
Пример #7
0
 def test_download_zip_url_options(self):
     result = utils.download_zip_url(tags=[TEST_TAG], transformations=[{"width": 0.5}, {"width": 2.0}], cloud_name="demo")
     upload_prefix = cloudinary.config().upload_prefix or "https://api.cloudinary.com"
     six.assertRegex(self, result, r'^{0}/v1_1/demo/.*$'.format(upload_prefix))
Пример #8
0
 def test_download_zip_url_options(self):
     result = utils.download_zip_url(tags=[TEST_TAG], transformations=[{"width": 0.5}, {"width": 2.0}], cloud_name="demo")
     six.assertRegex(self, result, r'^https://api.cloudinary.com/v1_1/demo/.*$')