Spaces:
Sleeping
Sleeping
romnatall
commited on
Commit
•
a625342
1
Parent(s):
5c8f992
deploy
Browse files- .gitattributes +1 -0
- app.py +110 -0
- data.csv +3 -0
- movies_data.csv +3 -0
- requirements.txt +3 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
*.csv filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import random
|
3 |
+
import streamlit as st
|
4 |
+
import pandas as pd
|
5 |
+
import numpy as np
|
6 |
+
|
7 |
+
movies = pd.read_csv('data.csv')
|
8 |
+
|
9 |
+
|
10 |
+
# name description link year imdb kp country age actors genres poster
|
11 |
+
# 0 Уэнсдэй В американской хоррор-комедии показана детект... https://www.lordfilm.bot/48211-ujensdjej-2022.... 2022.0 8.1 8.0 США 0 Дженна Ортега, Гвендолин Кристи, Рики Линдхоум... Сериалы, Фильмы про подростков https://www.lordfilm.bot/uploads/posts/2022-12.
|
12 |
+
|
13 |
+
def display_movie_card(df, index):
|
14 |
+
movie = df.iloc[index]
|
15 |
+
col1, col2 = st.columns([1, 3])
|
16 |
+
|
17 |
+
with col1:
|
18 |
+
st.image(movie['Image'], use_column_width=True)
|
19 |
+
button_id = f"button_{index}"
|
20 |
+
full=st.button('Показать полное описание', key=button_id, help='Click to expand')
|
21 |
+
|
22 |
+
with col2:
|
23 |
+
|
24 |
+
st.markdown(f"<h2 style='text-align: left;'>{movie['Name']}</h2>", unsafe_allow_html=True)
|
25 |
+
description = ' '.join(movie['Description'][:200].split(" ")[:-1]) + '...' if len(movie['Description']) > 200 else movie['Description']
|
26 |
+
if len(movie['Description']) > 200:
|
27 |
+
if full:
|
28 |
+
st.write(movie['Description'])
|
29 |
+
else:
|
30 |
+
st.write(description, unsafe_allow_html=True)
|
31 |
+
st.write(f"[{movie['Name']}]({movie['Link']})")
|
32 |
+
st.write("----------------------")
|
33 |
+
|
34 |
+
def display_rating(rating):
|
35 |
+
if np.isnan(rating): # Проверяем, является ли рейтинг NaN
|
36 |
+
return "(╥﹏╥)" # Смайлик, обозначающий отсутствие рейтинга
|
37 |
+
stars = int(rating / 2) # Переводим рейтинг из 0-10 в 0-5 и округляем до целого
|
38 |
+
remainder = rating % 2 # Доля рейтинга, которая не переводится в целое количество звезд
|
39 |
+
star_str = '🌕' * stars
|
40 |
+
if remainder >= 0.5:
|
41 |
+
star_str += '🌗' # Добавляем половину звезды в виде половины луны, если есть доля больше или равная 0.5
|
42 |
+
return star_str
|
43 |
+
|
44 |
+
|
45 |
+
|
46 |
+
def display_movie_card(df, index):
|
47 |
+
|
48 |
+
movie = df.iloc[index]
|
49 |
+
col1, col2 = st.columns([1, 3])
|
50 |
+
|
51 |
+
with col1:
|
52 |
+
st.image(movie['poster'], use_column_width=True)
|
53 |
+
|
54 |
+
st.write(f"Жанр: {movie['genres']}")
|
55 |
+
|
56 |
+
st.write(f"Страна: {movie['country']}")
|
57 |
+
st.write(f"рейтинг: {movie['age']}")
|
58 |
+
|
59 |
+
|
60 |
+
with col2:
|
61 |
+
year = str(int(movie['year'])) if not np.isnan(movie['year']) else ""
|
62 |
+
st.markdown(f"<h2 style='text-align: left;'>{movie['name']} ({year})</h2>", unsafe_allow_html=True)
|
63 |
+
|
64 |
+
|
65 |
+
description = ' '.join(movie['description'][:200].split(" ")[:-1]) + '...' if len(movie['description']) > 200 else movie['description']
|
66 |
+
|
67 |
+
k='num'+ str(index)
|
68 |
+
if k not in st.session_state:
|
69 |
+
st.session_state[k] = False
|
70 |
+
|
71 |
+
e = st.empty()
|
72 |
+
b=False
|
73 |
+
if movie['description'] !=description:
|
74 |
+
b = st.button("раскрыть описание",key=index,)
|
75 |
+
with e:
|
76 |
+
if b:
|
77 |
+
st.write(movie['description'])
|
78 |
+
else:
|
79 |
+
st.write(description)
|
80 |
+
st.write(f"Актеры: {movie['actors']}")
|
81 |
+
|
82 |
+
imdb,kp = st.columns([1,2])
|
83 |
+
with imdb:
|
84 |
+
st.write(f"IMDB: {display_rating(movie['imdb'])}")
|
85 |
+
with kp:
|
86 |
+
st.write(f"Кинопоиск: { display_rating(movie['kp'])}")
|
87 |
+
|
88 |
+
st.write(f"[смотреть]({movie['link']})")
|
89 |
+
st.write("----------------------")
|
90 |
+
|
91 |
+
|
92 |
+
reqs={}
|
93 |
+
@st.cache_data
|
94 |
+
def getnums(df,size=10,text=''):
|
95 |
+
if text in reqs:
|
96 |
+
return reqs[text]
|
97 |
+
else:
|
98 |
+
reqs[text]=list(np.random.randint(len(df), size=size))
|
99 |
+
return reqs[text]
|
100 |
+
|
101 |
+
|
102 |
+
input_search = st.text_input('Search')
|
103 |
+
|
104 |
+
for i in getnums(movies):
|
105 |
+
display_movie_card(movies, i)
|
106 |
+
|
107 |
+
|
108 |
+
|
109 |
+
|
110 |
+
|
data.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c9f8fc3da12290a08172ceddd079ad89a06d7e8041f7e800a61661a4fedcefa5
|
3 |
+
size 34501073
|
movies_data.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ddaf8ee5efd3af934ec0fb986a8e031c9d335e84dd545e931e72b814eec8b09d
|
3 |
+
size 74355
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
numpy
|
2 |
+
pandas
|
3 |
+
streamlit
|