Skip to content

Commit e3c42ec

Browse files
Add files via upload
1 parent 47b6050 commit e3c42ec

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

AddVideo.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ def get_video_title(url):
2727
except:
2828
return None
2929

30+
def video_already_exists(html_content, video_title):
31+
pattern = re.compile(r'<p>\s*{}\s*</p>'.format(re.escape(video_title)), re.IGNORECASE)
32+
return pattern.search(html_content) is not None
33+
3034
def add_video_to_html():
3135
video_url = url_entry.get()
3236

@@ -43,6 +47,10 @@ def add_video_to_html():
4347
with open('index.html', 'r') as file:
4448
html_content = file.read()
4549

50+
if video_already_exists(html_content, video_title):
51+
messagebox.showerror("Error", "The video already exists.")
52+
return
53+
4654
video_section_start = html_content.find('<section>\n <h2>Videos</h2>')
4755
video_section_end = html_content.find('</section>', video_section_start) + len('</section>')
4856

index.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ <h2>Videos</h2>
5151
</div>
5252
<p>SML Movie: Chef Pee Pee Quits Part 2</p>
5353
</section>
54+
<section>
55+
<div class="video-container">
56+
<iframe src="https://www.youtube.com/embed/IgKmdnHF5S4" frameborder="0" allowfullscreen></iframe>
57+
</div>
58+
<p>SML Movie: Chef Pee Pee Quits Part 3 [REUPLOADED] - YouTube</p>
59+
</section>
60+
5461
<section>
5562
<div class="video-container">
5663
<iframe src="https://www.youtube.com/embed/isKIo2qUS0Y" frameborder="0" allowfullscreen></iframe>

0 commit comments

Comments
 (0)