Lonami / grammers

(tele)gramme.rs - use Telegram's API from Rust
https://t.me/gramme_rs
Apache License 2.0
554 stars 113 forks source link

Some helpful functions for `Media::Photo`, `Media::Document` and `PhotoSize`. #251

Closed hlf20010508 closed 3 months ago

hlf20010508 commented 3 months ago
hlf20010508 commented 3 months ago

Ok, I've completely migrated download methods in PhotoSize to download_media and iter_download.

The usage is the same as other media

let downloadable = Downloadable::PhotoSize(photo_size);
let mut download = client.iter_download(&downloadable);

I also implemented download for PhotoSize::Progressive. It's actually the same as PhotoSize::Size. Now users can use largest() to get the largest thumb(for photos it's usually progressive) and download it.

And there was a bug in the download() of PathSize, that the param path was shadowed by the variable mut path. But it's not needed anymore.

hlf20010508 commented 3 months ago

The new function DownloadIter::new_from_photo_size is ugly, since request is not needed, I have to fake a useless one. If you think it's ok to make request to Option<tl::functions::upload::GetFile>, I'll do that.

Lonami commented 3 months ago

From a quick look, as long as it gets the job done, then it's fine.