title: Python script to download all the media from a Telegram Channel using Telethon
body: <p>I was trying to use Telethon but turns out is really slow</p>
  <p>So I tried using <a href="https://gist.github.com/painor/7e74de80ae0c819d3e9abcf9989a8dd6" rel="nofollow noreferrer">this gist</a> as suggested in
  <a href="https://stackoverflow.com/questions/59801767/how-to-correctly-use-the-iter-download-functionality-for-multi-connection-downlo">this post</a></p>
  <p>I have the following errors . Can anyone please help me?</p>
  <p>Here is my code:</p>
  <pre><code>from telethon.sync import TelegramClient
  from FastTelethon import download_file
  import os
  import asyncio
  
  
  async def getAllMediaFromchannel():
      os.chdir(&quot;/home/gtxtreme/Documents/McHumour&quot;)
      api_hash = &quot;&lt;hidden&gt;&quot;
      api_id = &lt;hidden&gt;
  
      client = TelegramClient('MCHumour', api_id, api_hash)
      client.start()
      ch_entity = await client.get_entity(&quot;telegram.me/joinchat/AAAAAEXnb4jK7xyU1SfAsw&quot;)
  
      messages = client.iter_messages(ch_entity, limit=50)
  
      def progress_cb(current, total):
          print('Uploaded', current, 'out of', total,
                'bytes: {:.5%}'.format(current / total))
  
      async for msg in messages:
          result = await download_file(client, msg.document, &quot;/home/gtxtreme/Documents/McHumour&quot;,
                                       progress_callback=progress_cb)
          print(&quot;*************************\nFile named {0} saved to {1} successfully\n********************&quot;.format(
              msg.message, result))
  
  
  if __name__ == '__main__':
      loop = asyncio.get_event_loop()
      loop.run_until_complete(getAllMediaFromchannel())
  
  </code></pre>
  <p>Here is my error</p>
  <pre><code>[gtxtreme@archlinux ~]$ python PycharmProjects/python_gtxtreme/tgBotrev1.py 
  
  PycharmProjects/python_gtxtreme/tgBotrev1.py:13: RuntimeWarning: coroutine 'AuthMethods._start' was never awaited
  RuntimeWarning: Enable tracemalloc to get the object allocation traceback
  Traceback (most recent call last):
    File &quot;PycharmProjects/python_gtxtreme/tgBotrev1.py&quot;, line 31, in &lt;module&gt;
      loop.run_until_complete(getAllMediaFromchannel())
    File &quot;/usr/lib/python3.8/asyncio/base_events.py&quot;, line 612, in run_until_complete
      return future.result()
    File &quot;PycharmProjects/python_gtxtreme/tgBotrev1.py&quot;, line 14, in getAllMediaFromchannel
      ch_entity = await client.get_entity(&quot;telegram.me/joinchat/AAAAAEXnb4jK7xyU1SfAsw&quot;)
    File &quot;/usr/lib/python3.8/site-packages/telethon/client/users.py&quot;, line 310, in get_entity
      result.append(await self._get_entity_from_string(x))
    File &quot;/usr/lib/python3.8/site-packages/telethon/client/users.py&quot;, line 512, in _get_entity_from_string
      invite = await self(
    File &quot;/usr/lib/python3.8/site-packages/telethon/client/users.py&quot;, line 30, in __call__
      return await self._call(self._sender, request, ordered=ordered)
    File &quot;/usr/lib/python3.8/site-packages/telethon/client/users.py&quot;, line 56, in _call
      future = sender.send(request, ordered=ordered)
    File &quot;/usr/lib/python3.8/site-packages/telethon/network/mtprotosender.py&quot;, line 170, in send
      raise ConnectionError('Cannot send requests while disconnected')
  ConnectionError: Cannot send requests while disconnected
  
  [gtxtreme@archlinux ~]$
  
  </code></pre>
  <p>Also any other suitable way of doing it would be preferred</p>