Skip to content

Instantly share code, notes, and snippets.

@doitian
Created December 17, 2010 14:00
Show Gist options
  • Save doitian/744969 to your computer and use it in GitHub Desktop.
Save doitian/744969 to your computer and use it in GitHub Desktop.
Batch import ED2K links to amule
#!/usr/bin/env python
amule_dir = "~/.aMule"
# Usage:
#
# Update amule_dir to your real location.
#
# The file or stdin must have one ED2K link per line.
#
# 1. Import file
#
# $ amimport file
#
# 2. Import from stdin
#
# $ amimport
#
# // paste links here, ending with Ctrl-D
import fileinput
import urllib
import tempfile
import os
import shutil
fd, path = tempfile.mkstemp()
for line in fileinput.input():
os.write(fd, urllib.unquote(line))
os.close(fd)
shutil.move(path, os.path.join(os.path.expanduser(amule_dir), "ED2KLinks"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment