Advertisement
stream13

vk dum.py

Jun 16th, 2013
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.29 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import sys
  4. import os
  5.  
  6. def get_n(i_str, pattern1):
  7.     n=""
  8.     for x in xrange((i_str.find(pattern1)+len(pattern1)),len(i_str)):
  9.         if(i_str[x] != "\""):
  10.             n+=i_str[x]
  11.         else:
  12.             break
  13.     return n
  14.  
  15. def download():
  16.     os.system("bash list.txt")
  17.     os.system("rm -f list.txt")
  18.     return 0
  19.  
  20. def screen(input, level):
  21.     output=""
  22.     if level == "1":
  23.         special="# ;.\"',\/`:!*@?${}[]()><|&-=+%~^"
  24.     else:
  25.         special="()"
  26.     for x in xrange(0,len(input)):
  27.         if(special.find(input[x]) != -1):
  28.             output+="\\"
  29.         output+=input[x]
  30.     return output
  31.  
  32. if len(sys.argv) < 2:
  33.     sys.exit('Usage: %s Input file' % sys.argv[0])
  34.  
  35. if not os.path.exists(sys.argv[1]):
  36.     sys.exit('ERROR: Input file %s was not found!' % sys.argv[1])
  37.  
  38. os.system("iconv -f WINDOWS-1251 -t UTF-8 " + sys.argv[1] + " > tmp.html")
  39. f = open("tmp.html", 'r')
  40. of = open("list.txt", "w")
  41. tmp = f.readline()
  42. while (tmp != None and tmp != ""):
  43.     if ((tmp.find("mp3") != -1) and (tmp.find("actdown") != -1)):
  44.         d_line=( "wget -c --output-document=\"" + screen(get_n(tmp, "download=\""), 1) + "\" " + screen(get_n(tmp, "http://") , 0) + "\n")
  45.         of.write(d_line)
  46.     tmp = f.readline()
  47.  
  48. if ((len(sys.argv) == 3) and (sys.argv[2] == "prep")):
  49.     print "Just prepared file \"list.txt\""
  50. else:
  51.     download()
  52.  
  53. os.system("rm -f tmp.html")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement