def scan_dirs(location): for d in location: movies = [i for i in os.listdir(d) if os.path.isdir(os.path.join(d, i))] movies.sort() for m in movies: if os.path.exists(os.path.join(d,m,"nfo.pickle")): print "\n\nNFO already found: %s" % m nfo = open(os.path.join(d,m,"nfo.pickle"), 'rb') info = pickle.load(nfo) nfo.close() (imdb_url, imdb_title, imdb_cover, imdb_date, imdb_rating, imdb_plot) = imdb_info(info['imdb_url']) else: print "\n\nSearching imdb info for: %s" % m (imdb_url, imdb_title, imdb_cover, imdb_date, imdb_rating, imdb_plot) = movie_info(m) if imdb_url == "": print "IMDB info not found for: %s" % m continue if imdb_cover == "": imdb_cover = "nocover" print "Searching youtube trailers for: %s" % imdb_title trailers = search_trailers(unescape(imdb_title) + " Official Trailer ") store_info(imdb_url, imdb_title, imdb_cover, imdb_date, imdb_rating, imdb_plot, trailers, os.path.join(d, m))
info = pickle.load(nfo) nfo.close() (imdb_url, imdb_title, imdb_cover, imdb_date, imdb_rating, imdb_plot) = imdb_info(info['imdb_url']) else: print "\n\nSearching imdb info for: %s" % m (imdb_url, imdb_title, imdb_cover, imdb_date, imdb_rating, imdb_plot) = movie_info(m) if imdb_url == "": print "IMDB info not found for: %s" % m continue if imdb_cover == "": imdb_cover = "nocover" print "Searching youtube trailers for: %s" % imdb_title trailers = search_trailers(unescape(imdb_title) + " Official Trailer ") store_info(imdb_url, imdb_title, imdb_cover, imdb_date, imdb_rating, imdb_plot, trailers, os.path.join(d, m)) if len(sys.argv) == 3: folder = sys.argv[1] imdb_url = sys.argv[2] (imdb_url, imdb_title, imdb_cover, imdb_date, imdb_rating, imdb_plot) = imdb_info(imdb_url) trailers = search_trailers(unescape(imdb_title) + " Official Trailer ") store_info(imdb_url, imdb_title, imdb_cover, imdb_date, imdb_rating, imdb_plot, trailers, folder) else: scan_dirs(dirs)