<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Telegram Tracker</title>
    <description>The latest articles on Forem by Telegram Tracker (@telegramtracker).</description>
    <link>https://forem.com/telegramtracker</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F982990%2F1501d05f-cb46-4933-8501-a317a84dfc6d.png</url>
      <title>Forem: Telegram Tracker</title>
      <link>https://forem.com/telegramtracker</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/telegramtracker"/>
    <language>en</language>
    <item>
      <title>Pyrogram download telegram media files</title>
      <dc:creator>Telegram Tracker</dc:creator>
      <pubDate>Fri, 23 Dec 2022 02:37:39 +0000</pubDate>
      <link>https://forem.com/telegramtracker/pyrogram-download-telegram-media-files-1e31</link>
      <guid>https://forem.com/telegramtracker/pyrogram-download-telegram-media-files-1e31</guid>
      <description>&lt;p&gt;To download the media from a message we can use &lt;code&gt;download_media()&lt;/code&gt;. This can uses by users and bots&lt;/p&gt;

&lt;p&gt;Examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Download from Message
await app.download_media(message)

# Download from file id
await app.download_media(message.photo.file_id)

# Keep track of the progress while downloading
async def progress(current, total):
    print(f"{current * 100 / total:.1f}%")

await app.download_media(message, progress=progress)

# Download media in-memory

file = await app.download_media(message, in_memory=True)
file_name = file.name
file_bytes = bytes(file.getbuffer())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Parameters:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;message&lt;/code&gt; (Message | str) – Pass a Message containing the media, the media itself (message.audio, message.video, …) or a file id as string.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;file_name&lt;/code&gt; (str, optional) – A custom file_name to be used instead of the one provided by Telegram. By default, all files are downloaded in the downloads folder in your working directory. You can also specify a path for downloading files in a custom location: paths that end with “/” are considered directories. All non-existent folders will be created automatically.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;in_memory&lt;/code&gt; (bool, optional) – Pass True to download the media in-memory. A binary file-like object with its attribute “.name” set will be returned. Defaults to False.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;block&lt;/code&gt; (bool, optional) – Blocks the code execution until the file has been downloaded. Defaults to True.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;progress&lt;/code&gt; (Callable, optional) – Pass a callback function to view the file transmission progress. The function must take (current, total) as positional arguments (look at Other Parameters below for a detailed description) and will be called back each time a new file chunk has been successfully transmitted.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;progress_args&lt;/code&gt; (tuple, optional) – Extra custom arguments for the progress callback function. You can pass anything you need to be available in the progress callback scope; for example, a Message object or a Client instance in order to edit the message with the updated progress status.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Referrer: &lt;a href="https://telegramtracker.com/" rel="noopener noreferrer"&gt;Telegram Tracker&lt;/a&gt;&lt;br&gt;
Follow me on &lt;a href="https://devpost.com/software/telegram-tracker-cts5j0" rel="noopener noreferrer"&gt;Devpost&lt;/a&gt;&lt;/p&gt;

</description>
      <category>gratitude</category>
    </item>
    <item>
      <title>Python download telegram media</title>
      <dc:creator>Telegram Tracker</dc:creator>
      <pubDate>Mon, 12 Dec 2022 16:32:32 +0000</pubDate>
      <link>https://forem.com/telegramtracker/python-download-telegram-media-18ao</link>
      <guid>https://forem.com/telegramtracker/python-download-telegram-media-18ao</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Download from Message
await app.download_media(message)

# Download from file id
await app.download_media(message.photo.file_id)

# Keep track of the progress while downloading
async def progress(current, total):
    print(f"{current * 100 / total:.1f}%")

await app.download_media(message, progress=progress)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Parameters:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;message&lt;/code&gt; (Message | str) – Pass a Message containing the media, the media itself (message.audio, message.video, …) or a file id as string.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;file_name&lt;/code&gt; (str, optional) – A custom file_name to be used instead of the one provided by Telegram. By default, all files are downloaded in the downloads folder in your working directory. You can also specify a path for downloading files in a custom location: paths that end with “/” are considered directories. All non-existent folders will be created automatically.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;in_memory&lt;/code&gt; (bool, optional) – Pass True to download the media in-memory. A binary file-like object with its attribute “.name” set will be returned. Defaults to False.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;block&lt;/code&gt; (bool, optional) – Blocks the code execution until the file has been downloaded. Defaults to True.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;progress&lt;/code&gt; (Callable, optional) – Pass a callback function to view the file transmission progress. The function must take (current, total) as positional arguments (look at Other Parameters below for a detailed description) and will be called back each time a new file chunk has been successfully transmitted.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;progress_args&lt;/code&gt; (tuple, optional) – Extra custom arguments for the progress callback function. You can pass anything you need to be available in the progress callback scope; for example, a Message object or a Client instance in order to edit the message with the updated progress status.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>python</category>
      <category>pyrogram</category>
      <category>telegram</category>
    </item>
  </channel>
</rss>
