Advertisement
Guest User

xxhds

a guest
Nov 24th, 2008
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. import urllib
  2. import xml.dom.minidom
  3. import re
  4. import time
  5. import os
  6.  
  7. #Put your own movie directory here
  8. movie_dir="/var/raid/MOVIES"
  9.  
  10. ##########
  11. # MOVIES #
  12. ##########
  13. def isInQueue(download_title):
  14. #put your address for the api stuff here
  15. queue=xml.dom.minidom.parse(urllib.urlopen("http://192.168.7.144:7777/sabnzbd/api?mode=qstatus&output=xml"))
  16. for job in queue.getElementsByTagName("job"):
  17. filename=job.getElementsByTagName("filename")[0].childNodes[0].data
  18. if filename == download_title:
  19. return 1
  20. return 0
  21.  
  22. def isMissing(check_movie_title):
  23. if os.path.exists(movie_dir + "/" + check_movie_title + ".avi") or os.path.exists(movie_dir + "/" + check_movie_title):
  24. return 0
  25. else:
  26. return 1
  27.  
  28. def isGoodMovie(imdb_html):
  29. #This is set up to only get movies above an 8.0, with over 1000 votes
  30. if re.compile("<b>[6-9]\.[0-9]/10</b>").search(imdb_html) and re.compile(">[0-9]*,[0-9][0-9][0-9] votes<").search(imdb_html):
  31. return 1
  32. else:
  33. return 0
  34.  
  35. def isOldMovie(imdb_html):
  36. #This is set up download movies only 1995 and newer. obviously if a year is not in the title this check doesnt apply
  37. movie_year = re.compile("<title>.+</title>").search(imdb_html)
  38. if re.search("19[0-8][0-9]", movie_year.group()) or re.search("199[0-4]", movie_year.group()):
  39. return 1
  40. else:
  41. return 0
  42.  
  43.  
  44. def download(report_id):
  45. print time.strftime("%Y-%m-%d %H:%M:%S")+"\x1b[32;01m"+" Downloading: "+"\x1b[0m"+ movie_title
  46. #put your address for the api stuff here
  47. #urllib.urlretrieve(msgid,"/var/bigraid/put_nzbs_here/"+movie_title+".nzb")
  48. urllib.urlopen("http://192.168.7.144:7777/sabnzbd/api?mode=addurl&name="+msgid+"&cat=movies")
  49.  
  50.  
  51. #Put your own rss feed for movies here
  52. dom=xml.dom.minidom.parse(urllib.urlopen("http://www.nzbs.org/rss.php?catid=2&i=XXXXX&h=XXXXXXXXXXXXXXXXXXX&dl=1"))
  53.  
  54. for node in dom.getElementsByTagName("item"):
  55.  
  56. report_title=node.getElementsByTagName("title")[0].childNodes[0].data
  57. movie_title = re.sub("\;","\:",report_title)
  58. movie_title = re.sub("\s","\:",movie_title)
  59. #print("MOVIE: "+movie_title)
  60.  
  61. report_description=node.getElementsByTagName("description")[0].childNodes[0].data
  62. movie_desc = re.search("IMDB:.+\/\"\>", report_description)
  63.  
  64. if movie_desc:
  65. movie_link = re.search("http.+\/",movie_desc.group())
  66. imdb_link=movie_link.group()
  67. #print(imdb_link)
  68. sock = urllib.urlopen(imdb_link)
  69. htmlSource = sock.read()
  70. sock.close()
  71.  
  72. if (isGoodMovie(htmlSource) == 1) and (isMissing(movie_title) == 1) and (isInQueue(report_title) == 0) and (isOldMovie(htmlSource) == 0):
  73. msgid=node.getElementsByTagName("link")[0].childNodes[0].data
  74. msgid = urllib.quote(msgid)
  75. download(msgid)
  76. else:
  77. print time.strftime("%Y-%m-%d %H:%M:%S")+"\x1b[31;01m"+" SKIPPING: "+"\x1b[0m"+ movie_title
  78.  
  79.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement