当前位置: 首页>>代码示例>>Python>>正文


Python Mega.download_url方法代码示例

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


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

示例1: main

# 需要导入模块: from mega import Mega [as 别名]
# 或者: from mega.Mega import download_url [as 别名]
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,代码行数:57,代码来源:animeDown.py

示例2: main

# 需要导入模块: from mega import Mega [as 别名]
# 或者: from mega.Mega import download_url [as 别名]
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,代码行数:57,代码来源:animeDown.py


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