File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,10 @@ def get_video_title(url):
27
27
except :
28
28
return None
29
29
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
+
30
34
def add_video_to_html ():
31
35
video_url = url_entry .get ()
32
36
@@ -43,6 +47,10 @@ def add_video_to_html():
43
47
with open ('index.html' , 'r' ) as file :
44
48
html_content = file .read ()
45
49
50
+ if video_already_exists (html_content , video_title ):
51
+ messagebox .showerror ("Error" , "The video already exists." )
52
+ return
53
+
46
54
video_section_start = html_content .find ('<section>\n <h2>Videos</h2>' )
47
55
video_section_end = html_content .find ('</section>' , video_section_start ) + len ('</section>' )
48
56
Original file line number Diff line number Diff line change @@ -51,6 +51,13 @@ <h2>Videos</h2>
51
51
</ div >
52
52
< p > SML Movie: Chef Pee Pee Quits Part 2</ p >
53
53
</ 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
+
54
61
< section >
55
62
< div class ="video-container ">
56
63
< iframe src ="https://www.youtube.com/embed/isKIo2qUS0Y " frameborder ="0 " allowfullscreen > </ iframe >
You can’t perform that action at this time.
0 commit comments