Commit f81a5642 authored by monkeyminer's avatar monkeyminer

Python 3.6 compatibiity, support for public folders

parent e28bee94
......@@ -15,3 +15,4 @@ twine
wheel
rope
pytest-mock
pytest-console-scripts
requests>=0.10
pycryptodome>=3.9.6,<4.0.0
pathlib==1.0.1
#pathlib==1.0.1
tenacity>=5.1.5,<6.0.0
......@@ -22,7 +22,7 @@ with open('HISTORY.rst', 'r', encoding='utf-8') as hist_file:
setup(
name='mega.py',
version='1.0.7.dev0',
version='1.0.7.dev1',
packages=find_packages('src', exclude=('tests', )),
package_dir={'': 'src'},
include_package_data=True,
......
......@@ -13,6 +13,8 @@ import binascii
import tempfile
import shutil
from typing import Dict, Tuple, Sequence, List
import requests
from tenacity import retry, wait_exponential, retry_if_exception_type
......@@ -143,13 +145,15 @@ class Mega:
retry=retry_if_exception_type(RuntimeError),
wait=wait_exponential(multiplier=2, min=2, max=60)
)
def _api_request(self, data):
def _api_request(self, data, additional_data:Tuple=None):
params = {'id': self.sequence_num}
self.sequence_num += 1
if self.sid:
params.update({'sid': self.sid})
if additional_data:
params.update(data)
# ensure input data is a list
if not isinstance(data, list):
data = [data]
......@@ -335,9 +339,10 @@ class Mega:
continue
return file
def get_files(self):
def get_files(self, public_folder_id=None):
logger.info('Getting all files...')
files = self._api_request({'a': 'f', 'c': 1, 'r': 1})
additional_data = {'n': public_folder_id} if public_folder_id else None
files = self._api_request({'a': 'f', 'c': 1, 'r': 1},additional_data=additional_data)
files_dict = {}
shared_keys = {}
self._init_shared_keys(files, shared_keys)
......
......@@ -121,6 +121,13 @@ def test_import_public_url(mega):
resp = mega.destroy(file_handle)
assert isinstance(resp, int)
def test_import_claymore(mega):
#resp = mega.import_public_url('https://mega.nz/#F!O4YA2JgD!n2b4iSHQDruEsYUvTQP5_w')
files = mega.get_files('O4YA2JgD')
print (str(files))
#file_handle = mega.get_id_from_obj(resp)
#resp = mega.destroy(file_handle)
#assert isinstance(resp, int)
class TestCreateFolder:
def test_create_folder(self, mega, folder_name):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment