Advertisement
Guest User

xxhds

a guest
Nov 22nd, 2008
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.15 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://host:port/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 6.0, with over 1000 votes
  30.     if re.compile("<b>6\.[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 download(report_id):
  36.     print time.strftime("%Y-%m-%d %H:%M:%S")+": "+ movie_title
  37.     #put your address for the api stuff here
  38.     urllib.urlopen("http://host:port/sabnzbd/api?mode=addurl&name="+msgid+"&cat=\"movies\"")
  39.  
  40.  
  41. #Put your own rss feed for movies here (from nzbs.org)
  42. dom=xml.dom.minidom.parse(urllib.urlopen("http://www.nzbs.org/rss.php?catid=2&i=XXXXX&h=XXXXXXXXXXXXXXX&dl=1"))
  43.  
  44. for node in dom.getElementsByTagName("item"):
  45.    
  46.     report_title=node.getElementsByTagName("title")[0].childNodes[0].data
  47.     movie_title = report_title
  48.  
  49.     report_description=node.getElementsByTagName("description")[0].childNodes[0].data
  50.     movie_desc = re.search("IMDB:.+\/\"\>", report_description)
  51.  
  52.     if movie_desc:
  53.         movie_link = re.search("http.+\/",movie_desc.group())
  54.         imdb_link=movie_link.group()
  55.         sock = urllib.urlopen(imdb_link)
  56.         htmlSource = sock.read()                    
  57.         sock.close()
  58.  
  59.         if (isGoodMovie(htmlSource) == 1) and (isMissing(movie_title) == 1) and (isInQueue(report_title) == 0):
  60.             msgid=node.getElementsByTagName("link")[0].childNodes[0].data
  61.             msgid=re.sub("\?", "%3F", msgid)
  62.             msgid=re.sub("=", "%3D", msgid)
  63.             msgid=re.sub("&", "%26", msgid)
  64.             download(msgid)
  65.  
  66.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement