• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python mega.Mega类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mega.Mega的典型用法代码示例。如果您正苦于以下问题:Python Mega类的具体用法?Python Mega怎么用?Python Mega使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Mega类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test

def test():
    # user details
    email = "[email protected]"
    password = "password"

    mega = Mega()

    # login
    m = mega.login(email, password)

    # get user details
    details = m.get_user()
    print(details)

    # get account files
    files = m.get_files()
    print(files)

    # upload file
    print(m.upload("test.py"))

    # trash a file, by id or url
    # print(m.delete('f14U0JhD'))
    # print(m.delete_url('https://mega.co.nz/#!f14U0JhD!S_2k-EvB5U1N3s0vm3I5C0JN2toHSGkVf0UxQsiKZ8A'))

    # download file, by id+key or url
    # m.download('6hBW0R4a','By7-Vjj5xal8K5w_IXH3PlGNyZ1VvIrjZkOmHGq1X00')
    m.download_url("https://mega.co.nz/#!6hBW0R4a!By7-Vjj5xal8K5w_IXH3PlGNyZ1VvIrjZkOmHGq1X00")
开发者ID:bussiere,项目名称:mega.py,代码行数:28,代码来源:test.py


示例2: __init__

    def __init__(self, *args, **kwargs):
        usuario, senha = settings.MEGA['email'], settings.MEGA['password']

        mega = Mega({'verbose': True})
        self.m = mega.login(usuario, senha)

        super(Command, self).__init__(*args, **kwargs)
开发者ID:gustavosf,项目名称:cdzforever.net,代码行数:7,代码来源:syncfiles.py


示例3: test

def test():
    #user details
    email = '[email protected]'
    password = 'password'

    mega = Mega()

    #login
    m =  mega.login(email, password)

    #get user details
    details = m.get_user()
    print(details)

    #get account files
    files = m.get_files()
    #example iterate over files
    for file in files:
        if files[file]['a'] != False:
            print files[file]

    #upload file
    print(m.upload('test.py'))

    #trash a file, by id or url
    #print(m.delete('f14U0JhD'))
    #print(m.delete_url('https://mega.co.nz/#!f14U0JhD!S_2k-EvB5U1N3s0vm3I5C0JN2toHSGkVf0UxQsiKZ8A'))

    #download file, by id+key or url
    #m.download('6hBW0R4a','By7-Vjj5xal8K5w_IXH3PlGNyZ1VvIrjZkOmHGq1X00')
    m.download_url('https://mega.co.nz/#!6hBW0R4a!By7-Vjj5xal8K5w_IXH3PlGNyZ1VvIrjZkOmHGq1X00')
开发者ID:si73,项目名称:mega.py,代码行数:31,代码来源:test.py


示例4: test

def test():
    """
    Enter your account details to begin
    comment/uncomment lines to test various parts of the API
    see readme.md for more information
    """

    #user details
    email = '[email protected]'
    password = 'password'

    mega = Mega()
    #mega = Mega({'verbose': True})  # verbose option for print output

    # login
    m = mega.login(email, password)

    # get user details
    details = m.get_user()
    print(details)

    # get account files
    files = m.get_files()

    # get account disk quota in MB
    print(m.get_quota())
    # get account storage space
    print(m.get_storage_space())

    # example iterate over files
    for file in files:
        print(files[file])

    # upload file
    print(m.upload('examples.py'))

    # search for a file in account
    file = m.find('examples.py')

    if file:
        # get public link
        link = m.get_link(file)
        print(link)

        # download file. by file object or url
        print m.download(file, '/tmp')
        #m.download_url(link)

        #delete or destroy file. by id or url
        print(m.delete(file[0]))
        #print(m.destroy(file[0]))
        #print(m.delete_url(link))
        #print(m.destroy_url(link))

    # empty trash
    print(m.empty_trash())
开发者ID:Ilgrim,项目名称:mega.py,代码行数:56,代码来源:examples.py


示例5: do_get

 def do_get(self,filel):
   mega = Mega()
   m = mega.login('[email protected]','raghavan')
   self.file=filel
   try:
     file1=m.find(self.file)
     m.download(file1)
   except:
     file1=m.find(self.file)
     m.download(file1)
开发者ID:koshikraj,项目名称:master-cloud,代码行数:10,代码来源:main.py


示例6: do_put

 def do_put(self,filel):
   mega = Mega()
   m = mega.login('[email protected]','raghavan')
   self.filel=filel
   for i in self.filel:
    try:
     file1 = m.upload(i)
    except:
     file1 = m.upload(i)
    os.remove(i)
开发者ID:koshikraj,项目名称:master-cloud,代码行数:10,代码来源:main.py


示例7: main

def main():
	#display search menu
	result = SearchInput()

	#show found series
	choice = DisplayResult(result)

	#get title and episode objects
	title = result[choice].name
	episodes = GetEpisodes(result[choice].url)
	numEpisodes = len(episodes)

	#create directory for saving anime

	w = Tkinter.Tk()
	w.withdraw()

	path = tkFileDialog.askdirectory()

	if not os.path.exists(path):
		print '[!] Error, quitting!'
		return

	#Bugfix for naming folders on windows
	folderName = title.translate(None, '"<>:/\\|?*')

	#Creating the folder
	savePath = os.path.join(path, folderName)
	if not os.path.exists(savePath):
		os.mkdir(savePath)

	#create Mega downloader object
	mega = Mega({'verbose': True})

	#Starting download...
	Clear()
	print version
	print '[*] Downloading ' + title + ' in ' + savePath
	print '[*] ' + str(numEpisodes) + ' episodes waiting for download...'

	#iterate through episodes list and download
	count = 0
	for episode in episodes:
		print '[*] Episode number ' + str(episode.num) + ' downloading...'
		try:
			mega.download_url(episode.url, savePath)
			print '[*] Episode ' + str(episode.num) + ' downloaded!'
			count = count + 1
		except:
			print '[!] Error! Could not download! Skipping!'

	#Finish and exit if no errors
	print '[*] ' + str(count) + ' chapters downloaded successfully!'
	raw_input()
	return
开发者ID:shakku,项目名称:animeDown,代码行数:55,代码来源:animeDown.py


示例8: main

def main():
	#display search menu
	result = SearchInput()

	#show found series
	choice = DisplayResult(result)

	#get title and episode objects
	title = GetTitle(result[choice].url)
	episodes = GetEpisodes(result[choice].url)
	numEpisodes = len(episodes)

	#create directory for saving anime

	w = Tkinter.Tk()
	w.withdraw()

	path = tkFileDialog.askdirectory()

	if not os.path.exists(path):
		print '[!] Error, quitting!'
		sys.exit(1)

	#Bugfix for naming folders on windows
	folderName = title.translate(None, '"<>:/\\|?*')

	#Creating the folder
	savePath = os.path.join(path, folderName)
	if not os.path.exists(savePath):
		os.mkdir(savePath)

	#create Mega downloader object
	mega = Mega({'verbose': True})

	#Starting download...
	Clear()
	print version
	print '[*] Descargando ' + title + ' en ' + savePath
	print '[*] ' + str(numEpisodes) + ' capitulos en cola...'

	#iterate through episodes list and download
	for episode in episodes:
		print '[*] Capitulo numero ' + str(episode.num) + ' descargando...'
		try:
			mega.download_url(episode.url, savePath)
		except:
			print '[!] Error! Saliendo!'
			exit(1)
		print '[*] Capitulo ' + str(episode.num) + ' descargado!'
	return

	#Finish and exit if no errors
	print '[*] Descarga terminada! Presiona enter para salir.'
	raw_input()
	sys.exit(0)
开发者ID:tamuraa,项目名称:animeDown,代码行数:55,代码来源:animeDown.py


示例9: mega_login

def mega_login(user=None, passwd=None):
    """ Login to mega.co.nz
    """

    global MEGA_OBJ

    try:
        mega = Mega({'verbose': True})
        MEGA_OBJ = mega.login(user, passwd)
    except Exception as error: #TODO: Find actual exception
        LOGGER.error('Failed to login to mega.co.nz '
                'check username or password.\n' + str(error))
        sys.exit(1)
开发者ID:peterfisher,项目名称:mega-sync,代码行数:13,代码来源:mega_sync.py


示例10: MegaBackend

class MegaBackend(duplicity.backend.Backend):
    """Connect to remote store using Mega.co.nz API"""

    def __init__(self, parsed_url):
        duplicity.backend.Backend.__init__(self, parsed_url)

        try:
            from mega import Mega
        except ImportError:
            raise BackendException('Mega.co.nz backend requires Mega.co.nz APIs Python Module'
                                   '(see https://github.com/richardasaurus/mega.py).')

        # Setup client instance.
        self.client = Mega()
        self.client.domain = parsed_url.hostname
        self.__authorize(parsed_url.username, self.get_password())

        # Fetch destination folder entry (and crete hierarchy if required).
        folder_names = parsed_url.path[1:].split('/')
        files = self.client.get_files()

        parent_folder = self.client.root_id
        for folder_name in folder_names:
            entries = self.__filter_entries(files, parent_folder, folder_name, 'folder')
            if len(entries):
                # use first matching folder as new parent
                parent_folder = entries.keys()[0]
            else:
                # create subfolder if folder doesn't exist and use its handle as parent
                folder_node = self.client.create_folder(folder_name, parent_folder)
                parent_folder = self.client.get_id_from_obj(folder_node)
                # update filelist after creating new folder
                files = self.client.get_files()

        self.folder = parent_folder

    @retry
    def put(self, source_path, remote_filename=None, raise_errors=False):
        """Transfer source_path to remote_filename"""
        # Default remote file name.
        if not remote_filename:
            remote_filename = source_path.get_filename()

        try:
            # If remote file already exists in destination folder, remove it.
            files = self.client.get_files()
            entries = self.__filter_entries(files, self.folder, remote_filename, 'file')

            for entry in entries:
                self.client.delete(entry)

            self.client.upload(source_path.get_canonical(), self.folder, dest_filename=remote_filename)

        except Exception, e:
            self.__handle_error("Failed to upload file '%s' to remote folder '%s': %s"
                                % (source_path.get_canonical(), self.__get_node_name(self.folder), str(e)), raise_errors)
开发者ID:hurlebouc,项目名称:GDuplicity,代码行数:56,代码来源:megabackend.py


示例11: mega_upload_files

def mega_upload_files(root, files, dest=None):
    mega = Mega()
    m = mega.login(config.get_username(), config.get_password())

    for filename in files:
        current = os.path.join(root, filename)
        print("Uploading: " + str(current))
        uploaded = m.upload(current)
        print(m.get_upload_link(uploaded))

        if dest != None:
            fileRef = m.find(filename)
            folder = m.find(dest)
            m.move(fileRef[0], folder)
开发者ID:jorgarga,项目名称:megauploader,代码行数:14,代码来源:megauploader.py


示例12: test

def test():
    #user details
    email = '[email protected]'
    password = 'password'

    mega = Mega()

    #login
    m = mega.login(email, password)

    #get user details
    details = m.get_user()
    print(details)

    #get account files
    files = m.get_files()

    #get account disk quota in MB
    print(m.get_quota())

    #example iterate over files
    for file in files:
        print(files[file])

    #upload file
    print(m.upload('tests.py'))

    #search for a file in account
    file = m.find('tests.py')


    if file:
        #get public link
        link = m.get_link(file)
        print(link)

        #download file. by file object or url
        m.download(file, '/tmp')
        #m.download_url(link)

        #delete or destroy file. by id or url
        print(m.delete(file[0]))
        #print(m.destroy(file[0]))
        #print(m.delete_url(link))
        #print(m.destroy_url(link))

    #empty trash
    print(m.empty_trash())
开发者ID:SigmoidFreud,项目名称:mega.py,代码行数:48,代码来源:tests.py


示例13: get_api

 def get_api(self) :
     if (self._api is None) :
         if (self._sid != '') :
             self._api = Mega()
             self._api.sid = self._sid
             self._api.master_key = self._master_key
             self._api.sequence_num = self._sequence_num
             self._api.users_keys = {}
         elif self._login is not None and self._password is not None :
             self._api = Mega()
             try :
                 self._api.login(self._login, self._password)
             except Exception :
                 self.errorexit(_('login failled'))
             
     return self._api
开发者ID:ToX82,项目名称:megacl,代码行数:16,代码来源:commandline.py


示例14: login

    def login(self,args,kwargs) :
        """login to mega"""
        if 'email' in kwargs :
            self._email = kwargs['email']
            self.save_config()
        elif len(args) > 0 :
            self._email = args[0]
            self.save_config()
        if self._email is None :
            self.errorexit(_('need email to login'))
        sys.stdout.write('Login : [%s]\n' % (self._email,))
        password = getpass.getpass()
        if len(password) == 0 :
            self.errorexit(_('need a password to login'))
            
        self._api = Mega()
        try :
            self._api.login(self._email,password)
        except Exception :
            self.errorexit(_('login failled'))
        self._sid = self._api.sid
        self._master_key = self._api.master_key
        self.save_config()

        self.status('login success')
开发者ID:ToX82,项目名称:megacl,代码行数:25,代码来源:commandline.py


示例15: __init__

    def __init__(self, parsed_url):
        duplicity.backend.Backend.__init__(self, parsed_url)

        try:
            from mega import Mega
        except ImportError:
            raise BackendException('Mega.co.nz backend requires Mega.co.nz APIs Python Module'
                                   '(see https://github.com/richardasaurus/mega.py).')

        # Setup client instance.
        self.client = Mega()
        self.client.domain = parsed_url.hostname
        self.__authorize(parsed_url.username, self.get_password())

        # Fetch destination folder entry (and crete hierarchy if required).
        folder_names = parsed_url.path[1:].split('/')
        files = self.client.get_files()

        parent_folder = self.client.root_id
        for folder_name in folder_names:
            entries = self.__filter_entries(files, parent_folder, folder_name, 'folder')
            if len(entries):
                # use first matching folder as new parent
                parent_folder = entries.keys()[0]
            else:
                # create subfolder if folder doesn't exist and use its handle as parent
                folder_node = self.client.create_folder(folder_name, parent_folder)
                parent_folder = self.client.get_id_from_obj(folder_node)
                # update filelist after creating new folder
                files = self.client.get_files()

        self.folder = parent_folder
开发者ID:hurlebouc,项目名称:GDuplicity,代码行数:32,代码来源:megabackend.py


示例16: __init__

	def __init__(self, storage):
		self.storage = storage
		self.admins = {}
		self.bot = None

		sys.stdout.write(' (logging in to mega.co.nz) ')
		self.mega = Mega({'verbose': True})
		self.mega.login_anonymous()
开发者ID:HarHar,项目名称:NiNiModules,代码行数:8,代码来源:megaconz.py


示例17: megaUpload

def megaUpload(userName, password, fileName, destination, error=0):
    if error <> 0:
        print "Upload try n°" + str(error)
        print "Failed will try again in " + str(error*5) + " seconds"
    try:
        #Si on en est pas au premier essai on att 5 sec * le nombre d'essais
        time.sleep(5*error)
        mega = Mega()
        m = mega.login(userName, password)
        file = m.upload(fileName, m.find(destination)[0])
        return m.get_upload_link(file)
    except Exception, e:
        mega = Mega()
        m = mega.login(userName, password)
        file = m.find(fileName)
        if (file <> None):
            return m.get_upload_link(file)
        else:
            print "error : " , e
            megaUpload(userName, password, fileName, destination, error+1)
开发者ID:sidewinder94,项目名称:downloadFromItEbooks,代码行数:20,代码来源:downloadFromItEbooks.py


示例18: test

def test():
    #user details
    email = '[email protected]'
    password = 'password'

    mega = Mega()

    ##login
    m = mega.login(email, password)

    ##get user details
    details = m.get_user()
    print(details)

    ##get account files
    files = m.get_files()
    #example iterate over files
    for file in files:
        if files[file]['a'] != False:
            print files[file]

    ##upload file
    print(m.upload('test.py'))

    ##get file's public link
    #NOTE: if passing upload() function response use get_upload_link()
    file = m.find('test.py')
    #print(m.get_upload_link(file))
    print(m.get_link(file))

    ##trash a file, by id or url
    #print(m.delete('f14U0JhD'))
    #print(m.delete_url('https://mega.co.nz/#!f14U0JhD!S_2k-EvB5U1N3s0vm3I5C0JN2toHSGkVf0UxQsiKZ8A'))

    ##search for a file in account
    file = m.find('somefile.doc')
    if file:
        #trash a file by it's id
        print(m.delete(file[1]['k']))
开发者ID:carlesso,项目名称:mega.py,代码行数:39,代码来源:test.py


示例19: BotModule

class BotModule(object):
	def __init__(self, storage):
		self.storage = storage
		self.admins = {}
		self.bot = None

		sys.stdout.write(' (logging in to mega.co.nz) ')
		self.mega = Mega({'verbose': True})
		self.mega.login_anonymous()
	def event(self, ev):
		if ev['name'] == 'msg':
			split = ev['msg'].split(' ')

			for word in split:
				if (word.lower().find('https://mega.co.nz/#!') == 0) or (word.lower().find('http://mega.co.nz/#!') == 0):
					try:
						info = self.mega.get_public_url_info(word)
						assert(info.get('name') != None)
						assert(info.get('size') != None)
					except Exception, e:
						ev['to'].msg('There was an error fetching Mega info from that link, it may be private or there may have happened a communication error. Sorry.')
						return

					ev['to'].msg(chr(3)+ '5Mega| ' + chr(15) +chr(2) + info['name'] + chr(15) + ' [' + fmt(info['size']) + ']')
开发者ID:HarHar,项目名称:NiNiModules,代码行数:24,代码来源:megaconz.py


示例20: __init__

    def __init__(self, params):
        '''
        Connects to Mega with the provided credentials

        Arguments
        ---------
        params: A dict with the params to be passed to the initialised object
        '''

        self.logger = logging.getLogger('clouddump')
        self.logger.info("Connecting to Mega...")
        self.params = params
        self.mega = Mega()
        try:
            self.mega.login(params['user_name'], params['password'])
            self.logger.info("Sucessfully logged in to Mega.")
        except Exception:
            self.logger.error(
                "Authentication to Mega failed. Please check user / password.")
            sys.exit(errno.EPERM)
开发者ID:svera,项目名称:clouddump,代码行数:20,代码来源:driver_mega.py



注:本文中的mega.Mega类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python server.listen函数代码示例发布时间:2022-05-27
下一篇:
Python meetup.meetup_day函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap