mega-sdk 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mega-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A lightweight Python client library for interacting with the MEGA.nz API
|
|
5
|
+
Author: edward011
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/theUser0011/mega-sdk
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
Requires-Dist: requests>=2.25.0
|
|
14
|
+
Requires-Dist: pycryptodome>=3.10.0
|
|
15
|
+
|
|
16
|
+
# mega-sdk
|
|
17
|
+
|
|
18
|
+
A lightweight, reliable Python client library for interacting with the **MEGA.nz** API. `mega-sdk` provides simple abstractions for logging in, uploading/downloading files, managing folders, exporting public links, and handling rate limits with built-in retries.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Features
|
|
23
|
+
|
|
24
|
+
- **Flexible Login**: Support for full user accounts, salt v1/v2 login, and temporary anonymous user sessions.
|
|
25
|
+
- **File Management**: Upload, download, move, rename, delete, and empty the rubbish bin.
|
|
26
|
+
- **Folder Support**: Nested folder creation (`mkdir` / `create_folder`), path-based folder lookups, and target directory resolution.
|
|
27
|
+
- **Sharing & Links**: Generate public links for files and folders or import public file URLs directly into your cloud drive.
|
|
28
|
+
- **Built-in Backoff**: Automatic exponential backoff and retry handling for transient API failures (`EAGAIN` / rate limits).
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
Install `mega-sdk` directly from PyPI using `pip`:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install mega-sdk
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Quick Start
|
|
43
|
+
|
|
44
|
+
### 1. User Authentication
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from mega_sdk import Mega
|
|
48
|
+
|
|
49
|
+
# Initialize instance
|
|
50
|
+
mega = Mega()
|
|
51
|
+
|
|
52
|
+
# Login with email and password
|
|
53
|
+
mega.login("your_email@example.com", "your_password")
|
|
54
|
+
|
|
55
|
+
# Get user quota information (in MB)
|
|
56
|
+
remaining_quota = mega.get_quota()
|
|
57
|
+
print(f"Remaining quota: {remaining_quota:.2f} MB")
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### 2. Anonymous Login
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from mega_sdk import Mega
|
|
64
|
+
|
|
65
|
+
# Login as a temporary anonymous user session
|
|
66
|
+
mega = Mega()
|
|
67
|
+
mega.login() # Calling login with no arguments creates an anonymous session
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## File Operations
|
|
73
|
+
|
|
74
|
+
### Uploading a File
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
# Basic upload to root folder
|
|
78
|
+
uploaded_file = mega.upload("example.pdf")
|
|
79
|
+
|
|
80
|
+
# Upload with a progress callback
|
|
81
|
+
def on_progress(current_bytes, total_bytes):
|
|
82
|
+
percent = (current_bytes / total_bytes) * 100
|
|
83
|
+
print(f"Progress: {percent:.1f}% ({current_bytes}/{total_bytes} bytes)")
|
|
84
|
+
|
|
85
|
+
mega.upload("large_file.zip", progress_callback=on_progress)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Downloading a File
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
# Find a file in your cloud drive
|
|
92
|
+
file_info = mega.find("example.pdf")
|
|
93
|
+
|
|
94
|
+
# Download file to a local destination directory
|
|
95
|
+
if file_info:
|
|
96
|
+
mega.download(file_info, dest_path="./downloads")
|
|
97
|
+
|
|
98
|
+
# Download directly via a public MEGA URL
|
|
99
|
+
mega.download_url(
|
|
100
|
+
"https://mega.nz/#!file_handle!file_key",
|
|
101
|
+
dest_path="./downloads"
|
|
102
|
+
)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Creating Folders
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
# Create a single directory or nested path in your Cloud Drive
|
|
109
|
+
created_folders = mega.create_folder("Documents/Projects/2026")
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Generating Public Links
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
# Get a shareable link for a file object
|
|
116
|
+
file_info = mega.find("example.pdf")
|
|
117
|
+
public_link = mega.get_link(file_info)
|
|
118
|
+
print("Share link:", public_link)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## Exception Handling
|
|
124
|
+
|
|
125
|
+
`mega-sdk` exports structured exceptions for API errors:
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
from mega_sdk import Mega, RequestError, ValidationError
|
|
129
|
+
|
|
130
|
+
mega = Mega()
|
|
131
|
+
|
|
132
|
+
try:
|
|
133
|
+
mega.login("user@example.com", "wrong_password")
|
|
134
|
+
except RequestError as err:
|
|
135
|
+
print(f"API Error Code {err.code}: {err.message}")
|
|
136
|
+
except ValidationError as err:
|
|
137
|
+
print(f"Validation Error: {err}")
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## Requirements
|
|
143
|
+
|
|
144
|
+
- **Python**: `>= 3.8`
|
|
145
|
+
- **Dependencies**: `requests`, `pycryptodome`
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## License
|
|
150
|
+
|
|
151
|
+
This project is licensed under the **MIT License**.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
mega_sdk-0.1.0.dist-info/METADATA,sha256=ZVe03QZcduS6hgK4nTFRXuG0IYf-Iw_o9T2HLY356H0,3864
|
|
2
|
+
mega_sdk-0.1.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
3
|
+
mega_sdk-0.1.0.dist-info/top_level.txt,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
4
|
+
mega_sdk-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|