本文整理汇总了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
示例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)