Skip to content

Commit 08070f7

Browse files
committed
making player site play more things than literally just despicable me
1 parent 3e51c14 commit 08070f7

File tree

3 files changed

+64
-16
lines changed

3 files changed

+64
-16
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
*.db
22
*.py[cod]
3+
.env
34
.web
45
__pycache__/
56
assets/external/
6-
.env

movie_streaming_site/movie_streaming_site.py

+40-14
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,16 @@ def index():
8787

8888

8989

90-
@rx.page(route="/movieplayer/[movieid]", on_load=State.on_load)
90+
@rx.page(route="/movieplayer/[movieid]")
9191
def movieplayer():
9292
return rx.box(
9393
search(),
94-
rx.text("Despicable Me 4", font_size="10.5vh", font_weight="800"),
94+
rx.text(State.current_movie["title"], font_size="10.5vh", font_weight="800"),
9595
rx.hstack(
9696
rx.html(
97-
State.movie_iframe
97+
State.movie_iframe,
98+
width="50vw",
99+
height="60vw"
98100
),
99101
#rx.box(width="960px", height="540px", bg="#D9D9D9"),
100102
rx.vstack(
@@ -105,10 +107,7 @@ def movieplayer():
105107
font_weight="800"
106108
),
107109
rx.text(
108-
"Gru and Lucy and their girls---Margo, Edith and Agnes---welcome a new "
109-
"member to the Gru family, Gru Jr., who is intent on tormenting his dad. "
110-
"Gru also faces a new nemesis in Maxime Le Mal and his femme fatale "
111-
"girlfriend Valentina, forcing the family to go on the run.",
110+
State.current_movie["description"],
112111
color="white",
113112
font_size="3vh",
114113
max_width="28vw"
@@ -117,20 +116,47 @@ def movieplayer():
117116
),
118117
rx.desktop_only(
119118
rx.vstack(
120-
movie_info_item("2024-06-20", "calendar"),
121-
movie_info_item("$100,000,000", "dollar-sign"),
122-
movie_info_item("94min", "clock"),
123-
movie_info_item("Site", "globe"),
124-
movie_info_item("IMDB", "clock"),
125-
movie_info_item(State.movie_id, "clock"),
119+
movie_info_item(State.current_movie["date"], "calendar"),
120+
movie_info_item(State.current_movie["revenue"], "dollar-sign"),
121+
movie_info_item(State.current_movie["runtime"], "clock"),
122+
123+
rx.cond(
124+
State.current_movie["site"],
125+
rx.link(
126+
movie_info_item("Site", "globe"),
127+
href=State.current_movie["site"],
128+
is_external=True
129+
),
130+
),
131+
rx.cond(
132+
State.current_movie["tmdb_link"],
133+
rx.link(
134+
movie_info_item("TMDB", "clock"),
135+
href=State.current_movie["tmdb_link"],
136+
is_external=True
137+
),
138+
),
139+
rx.cond(
140+
State.current_movie["imdb_link"],
141+
rx.link(
142+
movie_info_item("IMDB", "clock"),
143+
href=State.current_movie["imdb_link"],
144+
is_external=True
145+
)
146+
)
147+
148+
149+
126150
),
127151
),
128152

129153
spacing="2vw",
130154
),
131155

132-
width="100%",
156+
157+
width = "100%",
133158
padding="5.5vh",
159+
on_mount=State.on_load
134160
)
135161

136162
def movie_info_item(text, icon):

movie_streaming_site/state.py

+23-1
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,33 @@
88
class State(rx.State):
99
now_playing:list[dict[str, str]]
1010
movie_iframe:str
11+
current_movie:dict[str, str]
1112

1213
@rx.var
1314
def movie_id(self) -> str:
1415

1516
return self.router.page.params.get("movieid", "519182")
1617

1718

19+
def get_current_movie(self):
20+
movie_id = self.movie_id
21+
data = self.get_movie_data(movie_id)
22+
result = {
23+
"site":data["homepage"],
24+
"imdb_link":f"https://www.imdb.com/title/{data["imdb_id"]}/",
25+
"tmdb_link":f"https://www.themoviedb.org/movie/{data["id"]}",
26+
"description":data["overview"],
27+
"runtime":f"{data['runtime']} min",
28+
"revenue":f"${data['revenue']}",
29+
"title":data["title"],
30+
"date":data["release_date"]
31+
}
32+
print(result)
33+
return result
34+
35+
36+
37+
1838
def get_movie_data(self, id):
1939
url = f"https://api.themoviedb.org/3/movie/{id}?language=en-US"
2040
response = requests.get(
@@ -36,6 +56,7 @@ def get_now_playing_movies(self):
3656
"Authorization": f"Bearer {auth}"
3757
}
3858
)
59+
3960
data = json.loads(response.text)
4061
results = data["results"]
4162

@@ -53,7 +74,8 @@ def get_now_playing_movies(self):
5374
)
5475
return result_list
5576
def on_load(self):
56-
self.movie_iframe = f""" <iframe src="https://moviesapi.club/movie/""" + self.router.page.params.get("movieid", "519182") + """"></iframe> """ #style="height:60vh; width:50vw"
77+
self.movie_iframe = f" <iframe src=\"https://moviesapi.club/movie/" + self.router.page.params.get("movieid", "519182") + "\" style=\"width:50vw;height:60vh;\"></iframe> " #style="height:60vh; width:50vw"
5778
self.now_playing = self.get_now_playing_movies()
79+
self.current_movie = self.get_current_movie()
5880

5981

0 commit comments

Comments
 (0)