Skip to content

Instantly share code, notes, and snippets.

@mipsparc mipsparc/

Last active Apr 16, 2016
What would you like to do?
simultaneously download nicovideo
#!/usr/bin/env python3
import multiprocessing
import subprocess
accounts =[
{'id':'', 'pass':'password'},
{'id':'', 'pass':'password'},
def download(account, download_urls):
for url in download_urls:
url = url.strip()
cmd = './ {} {} {}'.format(url, account['id'], account['pass'])
print('{} started downloading from {}'.format(account['id'], url)), shell=True)
if __name__ == '__main__':
urls = open('list.txt','r').readlines()
url_num = len(urls)
accounts_num = len(accounts)
worksPerAccount = url_num//accounts_num
rest = url_num % accounts_num
jobs = []
for account in accounts:
if rest >= 1:
myworks = worksPerAccount + 1
rest -= 1
myworks = worksPerAccount
download_urls = urls[:myworks]
del urls[:myworks]
p = multiprocessing.Process(target=download, args=(account,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.