A script for downloading files from mega.nz

Download them sequentially at one time with CLI

A tool for sequential downloads from mega.nz

Make sure you have mega.py installed, or install it with:

    $ pip install --user mega.py

Call this tool by:

    $ python mega_download.py mega_link_1,mega_link_2,etc (optional_output_path)

Here are the codes to be put into the mega_download.py file:

  #!/usr/bin/env python3
  import sys
  from mega import Mega

  def main():
      if len(sys.argv) > 3:
          print("Usage: python mega_download.py mega_link_1,mega_link_2,etc (optional_output_path)")
          sys.exit(1)

      mega_link_list = sys.argv[1].split(',')
      
      try:
          sys.argv[2]
      except IndexError:
          output_path = '/default/output/dir/'
      else:
          output_path = sys.argv[2]

      mega = Mega()
      m = mega.login()
      for mega_link in mega_link_list:
          print('In progress, downloading to ' + output_path)
          m.download_url(mega_link, output_path)
          print('Download complete for ' + mega_link)

  if __name__ == "__main__":
      main()

Now try this:

    $ python mega_download.py https://mega.nz/file/kuRhwSBL#lrhW3n0Lq6QjbGFrHIBZahdBZbdeA27Ffr_L6S8eFqo,https://mega.nz/file/s6QiHb4C#n2-eQ38Bg7Q2Oki6r5S3Iq_sLALlyz8M87YQqTzgdR0,https://mega.nz/file/VzJDBZ6Y#wi5M2LG27wpIIjOwpXH8geM1dM0JNQbXv_24pw2Y5m4,https://mega.nz/file/tnAwhZCC#_kUBco4uAAvo618_JZLqZtliHjjpSC0ZuxkIeehILdU,https://mega.nz/file/c3IUQTIK#JQDJs53l-uZDH6MvTU1YFk6FejjaP0s24vk2pAduEL0,https://mega.nz/file/JvYAWKBL#5-QXfzCFp5tb1YJLr7RZlBcnKjQws_g0StD01mdHUXk

This will download the following datasets to your default output directory and will take forever!

png

Anjie Le

I focus on applying my mathematical knowledge to the biomedical industry.