本文整理匯總了Python中movie.Movie.path方法的典型用法代碼示例。如果您正苦於以下問題:Python Movie.path方法的具體用法?Python Movie.path怎麽用?Python Movie.path使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類movie.Movie
的用法示例。
在下文中一共展示了Movie.path方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: from movie import Movie [as 別名]
# 或者: from movie.Movie import path [as 別名]
def main():
args = process_arguments()
movies_list = []
os.path.dirname(os.path.realpath(__file__))
# Single file should be checked
if args.path[0] == "single":
movies_list = get_list_of_files(args.path[1], "single")
# Folder should be scanned recusrivly
elif args.path[0] == "folder" and args.recursive:
movies_list = get_list_of_files(args.path[1], "recursive")
# Folder
else:
movies_list = get_list_of_files(args.path[1], "folder")
print "Working..."
# Obtain imdb id for each movie file
movie_dict = {}
movie_dict = OpenSubtitles.get_movie_data(movies_list)
del movies_list
# Create movies database which contains movie objects
movies_database = []
for element in movie_dict.items():
movie_obj = Movie()
movie_obj.imdb_id = element[1]
movie_obj.path = element[0]
movies_database.append(movie_obj)
del movie_dict
# For movies which has not imdb id detected try to obtain title
# from the file name
# File name must be in such format: mobie_title_year(4 digits)_extension
for movie in movies_database:
if movie.imdb_id == None:
obtain_title_and_year(movie)
print "obtained! %s" % (movie.title)
# Obtain movie details from imdb.
unique_movies_dict = {}
for movie in movies_database:
# imdb id detected - take movie data from imdb.com
if movie.imdb_id != None:
movie.imdb_object = ImdbCom.get_movie_data_from_imdbcom(movie.imdb_id)
movie.prepare_data_from_imdb()
if movie.imdb_id not in unique_movies_dict.keys():
print '"%s" processed.' % movie.title
unique_movies_dict[movie.imdb_id] = movie
# imdb id is not known but title has been obtained from file name
elif movie.title != None:
movie.imdb_object, movie.imdb_id = ImdbCom.search_movie_by_title(movie)
if movie.imdb_object:
movie.prepare_data_from_imdb()
if movie.imdb_id not in unique_movies_dict.keys():
print '"%s" processed.' % movie.title
unique_movies_dict[movie.imdb_id] = movie
else:
print '"%s" not processed.' % movie.path
# Preapre list of not duplicated movies
# Each movie objact on this list contains data from imdb.com
unique_movies_list = unique_movies_dict.values()
# Finally render index.html file
# Prepare environment for jinja2
execution_path = os.path.dirname(os.path.realpath(__file__))
templates_path = os.path.join(execution_path, "templates")
static_path = os.path.join(execution_path, "static")
# Prepare path for copying static files to cwd
templates_cwd_path = os.path.join(os.getcwd(), "moview/templates")
static_cwd_path = os.path.join(os.getcwd(), "moview/static")
# Remove moview tmp files if already exists in cwd
try:
shutil.rmtree(os.path.join(os.getcwd(), "moview"))
except:
pass
# Copy static files to cwd under moview direcotry
shutil.copytree(templates_path, templates_cwd_path)
shutil.copytree(static_path, static_cwd_path)
# Prepare environment for jinja2
env = Environment(loader=FileSystemLoader(templates_path))
# Select template
template = env.get_template("index.html")
# Render results to index.html file
rendered_file = open("index.html", "w")
rendered_file.write(template.render(movielist=unique_movies_list).encode("utf-8"))
rendered_file.close()
# That's it!
print "index.html with movie list has been " + "generated in the current directory."
print "Thanks for using MoView!"
return sys.exit(0)