alikayh commited on
Commit
d884b91
·
verified ·
1 Parent(s): 774fb35

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +87 -0
app.py ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import re
3
+ import time
4
+
5
+ # Language Selection
6
+ language = st.sidebar.selectbox("Select Language", ["English", "فارسی"])
7
+
8
+ # Define text content for both languages
9
+ if language == "English":
10
+ title = "Stream and Watch Youtube videos Online"
11
+ info = "Developed by Alikay_h --> github.com/kayhgng"
12
+ subheader = "Watch Youtube videos without annoying Comments and Ads, Just Be relax"
13
+ url_input_label = "Video URL"
14
+ url_input_placeholder = "Enter Youtube video URL"
15
+ button_label = "Lets Go!"
16
+ spinner_label = "Loading"
17
+ error_message = "Your video address is invalid dude!"
18
+ additional_info = """
19
+ <div style="text-align: left;">
20
+ You are looking to watch youtube online without any comments and annoying other contents, We developed This Application for you!
21
+ </div>
22
+ """
23
+ else:
24
+ title = "دیدن ویدیو یوتیوب آنلاین"
25
+ subheader = "ویدیو یوتیوبو ببین بدون تبلیغ و کامنت فقط تمرکز کن"
26
+ info = "توسعه دهنده: Alikay_h --> github.com/kayhgng"
27
+ url_input_label = "آدرس ویدیو"
28
+ url_input_placeholder = "یه آدرس ویدیو وارد کن"
29
+ button_label = "بزن بریم!"
30
+ spinner_label = "در حال بارگذاری ویدیو..."
31
+ error_message = "آدرست اشتباهه عزیز"
32
+ additional_info = """
33
+ <div style="text-align: right;">
34
+ آیا به دنبال راهی برای افزایش تجربه تماشای یوتیوب هستید؟
35
+ <br>
36
+ بیش از این نگاه نکنید! این اپلیکیشن رابط کاربری تمیز و مینیمالی را برای تجربه ای بدون حواس پرتی ارائه می دهد.
37
+ <br>
38
+ <br>
39
+ فرقی نمی کند معلم، استاد، دانش آموز یا سازمان دهنده باشید، می توانید از اپلیکیشن ما برای حذف تبلیغات، نظرات و ویدیوهای ناخواسته و نامناسب که ممکن است در نوار کناری ظاهر شوند، استفاده کنید.
40
+ <br>
41
+ شما می توانید اطمینان حاصل کنید که دانش آموزان شما تنها محتوایی را که می خواهید ببینند، در حالی که تجربه خود را عاری از حواس پرتی نگه دارید.
42
+ </div>
43
+ """
44
+
45
+ # Title and Description
46
+ st.title(title)
47
+ st.subheader(subheader)
48
+ st.info(info)
49
+
50
+ # Function to extract video ID from URL
51
+ def extract_video_id(url):
52
+ regex = re.compile(r'(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})', re.IGNORECASE)
53
+ match = regex.search(url)
54
+ return match.group(1) if match else None
55
+
56
+ # Function to display the video
57
+ def display_video(video_id):
58
+ st.markdown(
59
+ f'<div class="video-container" style="position: relative; width: 100%; max-width: 1024px; margin: 2rem auto; padding-bottom: 56.25%; border-radius: 10px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); background-color: #fff;">'
60
+ f'<iframe src="https://www.youtube-nocookie.com/embed/{video_id}" frameborder="0" allow="autoplay; encrypted-media; picture-in-picture" allowfullscreen style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border-radius: 10px;"></iframe>'
61
+ f'</div>',
62
+ unsafe_allow_html=True
63
+ )
64
+ st.write("---")
65
+
66
+ # Form for entering YouTube URL
67
+ video_url = st.text_input(url_input_label, placeholder=url_input_placeholder)
68
+
69
+ # Button to play the video
70
+ if st.button(button_label):
71
+ with st.spinner(spinner_label):
72
+ time.sleep(5) # Wait for 5 seconds
73
+ st.success("Have Fun! - Alikay_h")
74
+ video_id = extract_video_id(video_url)
75
+ if video_id:
76
+ display_video(video_id)
77
+ else:
78
+ st.error(error_message)
79
+
80
+ # Additional Information
81
+ st.markdown(additional_info, unsafe_allow_html=True)
82
+
83
+ # Footer
84
+ st.write("---")
85
+ st.write("YouTube is the source of content")
86
+ st.write("[Made with 🖤 in KayHGNG](https://github.com/kayhgng) | This website **does not store** any data such as cookies to enable essential site functionality.")
87
+ st.markdown("---", unsafe_allow_html=True)