Skip to content

v1.0.1

Latest
Compare
Choose a tag to compare
@aratakileo aratakileo released this 29 Oct 18:51

Structure refactoring

Requirements

  • python >= 3.10

Install

pip install git+https://github.com/aratakileo/mailru-cloud-guest-api.git
for windows
py -m pip install git+https://github.com/aratakileo/mailru-cloud-guest-api.git
for unix/macos
python3 -m pip install git+https://github.com/aratakileo/mailru-cloud-guest-api.git

Quick how to use

You can easily get a link to stream a file download by writing the following code, which will output the streaming link to the console:

from mailru_cloud_guest_api import FileStreamGenerator

# replace `https://cloud.mail.ru/public/file_id` with your public link
print(FileStreamGenerator.of('https://cloud.mail.ru/public/file_id').generate().stream_link)

How to use

This library offers a special object for generating a file stream link. You can create it as follows:

from mailru_cloud_guest_api import FileStreamGenerator

# replace `https://cloud.mail.ru/public/file_id` with your public link
streamGenerator = FileStreamGenerator.of('https://cloud.mail.ru/public/file_id')

Before generating the file stream link, you can configure the generator using the following methods:

# set request email
streamGenerator.setMail('your_mail@mail.ru')

# set file stream link in seconds
streamGenerator.set_lifetime_in_seconds(10)

# set file stream link in minutes
streamGenerator.set_lifetime_in_minutes(5)

# set file stream link in hours
streamGenerator.set_lifetime_in_hours(1)

After configuring the generator, you can get a special object that stores the file stream link:

container = streamGenerator.generate()

# print file stream link
print(container.stream_link)

# download file (replace `my_file.zip` with the filename as which the downloaded file will be saved)
container.download('my_file.zip')