Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import sys
- import os
- def get_n(i_str, pattern1):
- n=""
- for x in xrange((i_str.find(pattern1)+len(pattern1)),len(i_str)):
- if(i_str[x] != "\""):
- n+=i_str[x]
- else:
- break
- return n
- def download():
- os.system("bash list.txt")
- os.system("rm -f list.txt")
- return 0
- def screen(input, level):
- output=""
- if level == "1":
- special="# ;.\"',\/`:!*@?${}[]()><|&-=+%~^"
- else:
- special="()"
- for x in xrange(0,len(input)):
- if(special.find(input[x]) != -1):
- output+="\\"
- output+=input[x]
- return output
- if len(sys.argv) < 2:
- sys.exit('Usage: %s Input file' % sys.argv[0])
- if not os.path.exists(sys.argv[1]):
- sys.exit('ERROR: Input file %s was not found!' % sys.argv[1])
- os.system("iconv -f WINDOWS-1251 -t UTF-8 " + sys.argv[1] + " > tmp.html")
- f = open("tmp.html", 'r')
- of = open("list.txt", "w")
- tmp = f.readline()
- while (tmp != None and tmp != ""):
- if ((tmp.find("mp3") != -1) and (tmp.find("actdown") != -1)):
- d_line=( "wget -c --output-document=\"" + screen(get_n(tmp, "download=\""), 1) + "\" " + screen(get_n(tmp, "http://") , 0) + "\n")
- of.write(d_line)
- tmp = f.readline()
- if ((len(sys.argv) == 3) and (sys.argv[2] == "prep")):
- print "Just prepared file \"list.txt\""
- else:
- download()
- os.system("rm -f tmp.html")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement