Skip to main content

Decode and encode telegram file_id and file_unique_id and convert between those.

Project description

tg_file_id

Parse and construct Telegram file_ids and unique_file_ids. Even generate a unique_file_id from a file_id.

Examples below

Install

pip install tg-file-id

Parse file_ids

from tg_file_id.file_id import FileId

file_id = FileId.from_file_id('CAACAgIAAxkBAAIEol9yQhBqFnT4HXldAh31a-hYXuDIAAIECwACAoujAAFFn1sl9AABHbkbBA')

Now the file_id variable is an object like this:

DocumentFileId(
    file_id='CAACAgIAAxkBAAIEol9yQhBqFnT4HXldAh31a-hYXuDIAAIECwACAoujAAFFn1sl9AABHbkbBA',
    type_id=8,
    type_generic='document',
    type_detailed='sticker',
    dc_id=2,
    id=46033261910035204,
    access_hash=-5107925353769492667,
    version=4,
    sub_version=27,
)

Parse file_unique_ids

from tg_file_id.file_unique_id import FileUniqueId

unique_id = FileUniqueId.from_unique_id('AgADBAsAAgKLowAB')

Now the unique_id variable is an object like this:

FileUniqueId(
    unique_id='AgADBAsAAgKLowAB',
    type_id=2,
    id=46033261910035204
)

Convert file_ids to file_unique_ids

from tg_file_id.file_unique_id import FileUniqueId

unique_id = FileUniqueId.from_file_id('CAACAgIAAxkBAAIEol9yQhBqFnT4HXldAh31a-hYXuDIAAIECwACAoujAAFFn1sl9AABHbkbBA')
calculated_file_unique_id = unique_id.to_unique_id()

Now calculated_file_unique_id is

'AgADBAsAAgKLowAB'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tg_file_id-0.0.4.tar.gz (11.8 kB view details)

Uploaded Source

File details

Details for the file tg_file_id-0.0.4.tar.gz.

File metadata

  • Download URL: tg_file_id-0.0.4.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for tg_file_id-0.0.4.tar.gz
Algorithm Hash digest
SHA256 dc4f89f4acac4a67117c82bd7e40a0be93eaf63870da9dee8ce4cd1860f2e6bb
MD5 f67da77a07c80505b48a2a721f0d6004
BLAKE2b-256 a1f60133161c967207d78fc3e1e9fb8324afa7e5cea4e7b68c693ae9581779f2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page