本文整理匯總了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)