-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmovie_website.py
More file actions
55 lines (41 loc) · 1.6 KB
/
movie_website.py
File metadata and controls
55 lines (41 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import media
import fresh_tomatoes
import xml.etree.ElementTree as ET
import json
def load_movie(movieElement):
# Creates a Movie object from an XML element
movie = media.Movie(movieElement.find("Title").text,
movieElement.find("Description").text,
movieElement.find("PosterURL").text,
movieElement.find("TrailerURL").text,
movieElement.find("IMDB").text,
movieElement.find("RT").text)
return movie
def load_related_sources():
sources_file = open("sources.dat")
sources_data = json.load(sources_file)
# Load the list of keywords from the JSON encoded file
keywords_file = open("keywords.dat")
search_keywords = json.load(keywords_file)
keywords_file.close()
related_sources = []
for source in sources_data.keys():
content_source = media.RelatedContentSource(source, sources_data[source], search_keywords)
related_sources.append(content_source)
return related_sources
def load_data():
# Load the list of source for related link material
related_sources = load_related_sources()
# Load the XML file containing movie details
tree = ET.parse("movielist.xml")
root = tree.getroot()
# Build the list of Movie objects, generating the related links as we go
movies = []
for child in root:
movie = load_movie(child)
movie.build_related_content(related_sources)
movies.append(movie)
return movies
def start_website():
fresh_tomatoes.open_movies_page(load_data())
start_website()