telegram-upload

repository·master·Indexed 23 days ago

https://github.com/nekmo/telegram-upload

A tool that uses a personal Telegram account to upload and download files, effectively turning Telegram into a personal cloud storage service. It supports files up to 4 GiB for premium users and includes features for personalized file captions using variables, metadata extraction via hachoir, and detailed compatibility support for various audio and video file types.

Tokens
5.6K
Snippets
19
Records
37
Agent score
76%

What's inside telegram-upload

  1. Understand supported video file features

    master

    Telegram-upload supports any file type supported by Telegram, but specific video formats provide varying levels of feature support. Features include:

    • Metadata: Extraction of file metadata using Hachoir.
    • Video playback: The ability to play the video directly within Telegram.
    • Video streaming: The ability to stream the video while it is being downloaded.

    Note that results may vary across different platforms and Telegram clients.

  2. Install specific versions or development releases

    master

    You can install specific versions from PyPI or install development versions directly from GitHub using pip.

    To install a specific version from PyPI:

    $ pip install telegram-upload==<version>

    To install a development version from a specific git branch:

    $ pip install git+https://github.com/Nekmo/telegram-upload.git@<branch>#egg=telegram_upload

    If you do not have git installed, you can install from a branch zip archive:

    $ pip install https://github.com/Nekmo/telegram-upload/archive/<branch>.zip
  3. Test caption variables before sending

    master

    To verify your caption formatting and variable syntax without actually uploading files, use the telegram_upload.caption_formatter module via Python. This is the recommended way to debug complex captions.

    $ python -m telegram_upload.caption_formatter file.txt "{file.absolute}"
  4. Use the caption argument to personalize file messages

    master

    You can add a custom message to every file you send using the --caption "<message>" argument. This message can be personalized using variables inside braces ({}).

    Available top-level variables:

    • {file}: The file object, containing extensive metadata and attributes.
    • {now}: The current datetime.

    Note on syntax:

    • If a variable is invalid, it will remain unreplaced in the string.
    • If there is a syntax error in the braces, the entire caption will remain unreplaced.
    • To use literal braces in your caption, escape them by doubling them (e.g., {{ {file.name} }} becomes { file.txt }).
    $ telegram-upload --caption "This is a file with name {file.name}" file.txt
  5. Run telegram-upload using Docker

    master

    You can run telegram-upload without installing it on your system by using Docker. When using Docker, the commands telegram-upload and telegram-download are replaced by upload and download respectively.

    Use the following command structure:

    docker run -v <files_dir>:/files/ \
               -v <config_dir>:/config/ \
               -it nekmo/telegram-upload:master \
               <command> <args>

    Arguments:

    • <files_dir>: The directory containing the files you want to upload or download.
    • <config_dir>: The directory where the telegram-upload configuration will be stored. This directory is created automatically.
    • <command>: Use upload or download.
    • <args>: The arguments normally passed to telegram-upload or telegram-download.

    Example: To upload file_to_upload.txt from /media/data/ using a local ./config directory:

    docker run -v /media/data/:/files/ \
               -v $PWD/config:/config/ \
               -it nekmo/telegram-upload:master \
               upload file_to_upload.txt
  6. Use interactive mode for upload and download

    master

    Activate interactive mode using the -i or --interactive option. This launches a wizard to select files and conversations.

    Interactive Upload

    1. Step 1: Select local files to upload (use SPACE to select multiple).
    2. Step 2: Select the destination conversation (chat, channel, etc.).

    Interactive Download

    1. Step 1: Select the conversation to download from.
    2. Step 2: Select the files to download (use SPACE to select multiple).
    • Up/Down arrows: Navigate options.
    • Spacebar: Select/deselect the current option (marked with an asterisk).
    • Mouse click: Select an option (if supported by terminal).
    • Enter: Proceed to the next step.
    • PageUp/PageDown: Quick navigation through pages.