-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmegatools.py
More file actions
51 lines (36 loc) · 1.86 KB
/
megatools.py
File metadata and controls
51 lines (36 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python3
"""
Author: Jay Lux Ferro
Email: jayluxferro@sperixlabs.org, jay@ovond.com
Date: 23rd August, 2019
"""
import helper as hp
import os
class Mega:
# Default path on macOS
megaPath='/usr/local/bin/'
dir_path = os.path.dirname(os.path.realpath(__file__))
def __init__(self, megaPath=None, configPath=dir_path + '/mega.rc'):
if megaPath != None:
self.megaPath = megaPath if megaPath[-1] == '/' else megaPath + '/'
self.configPath = configPath
def df(self, f='g'):
f = '--mb' if f.lower() == 'm' else '--gb'
return hp.formatDf([self.megaPath + 'megadf', f, '--config', self.configPath])
def ls(self, path='/'):
return hp.ls([self.megaPath + 'megals', '--config', self.configPath, path if path[0] == '/' else '/' + path])
def put(self, fileName, serverPath='/Root'):
return hp.put([self.megaPath + 'megaput', '--config', self.configPath, '--path', serverPath, fileName])
def rm(self, filePath):
return hp.rm([self.megaPath + 'megarm', '--config', self.configPath, filePath])
def md(self, directoryPath):
return hp.md([self.megaPath + 'megamkdir', '--config', self.configPath, directoryPath])
def copy(self, localDirectoryPath, remoteDirectoryPath, download=False):
download = '' if not download else '--download'
return hp.copy([self.megaPath + 'megacopy', '--config', self.configPath, '--local', localDirectoryPath, '--remote', remoteDirectoryPath, download])
def get(self, remoteFile):
return hp.get([self.megaPath + 'megaget', '--config', self.configPath, remoteFile])
def url(self, remoteFile):
return hp.url([self.megaPath + 'megals', '--config', self.configPath, remoteFile, '--export'])
def dl(self, url):
return hp.dl([self.megaPath + 'megadl', '--config', self.configPath, url])