Created
December 17, 2010 14:00
-
-
Save doitian/744969 to your computer and use it in GitHub Desktop.
Batch import ED2K links to amule
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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