Example #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('کی گفته بهت این دستور کار می‌کنه؟')
Example #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()
Example #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))
Example #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()
Example #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()
 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()
Example #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))
Example #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/.*$')