main.Cancel_Shutdown()   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 6
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
# ------------------ Packages imported ---------------------------------------------
2
import pytube
3
from pytube import YouTube
4
from pytube import Playlist
5
import sys
6
import re
7
import requests as r
8
import wget
9
from tkinter import PhotoImage, Label, StringVar, Entry, Button, IntVar, \
10
     Radiobutton, messagebox, filedialog, Frame, X, Y, LEFT, RIGHT, \
11
         N, FLAT, CENTER, Canvas, Scrollbar, VERTICAL, BOTH, SUNKEN, SOLID
12
import tkinter as tk
13
from tkinter import ttk
14
import clipboard
15
import webbrowser
16
from tkinterhtml import HtmlFrame
17
from tkinter import Tk,Menu,Toplevel,Text,Spinbox
18
import pywhatkit
19
import time
20
import sys
21
import os
22
from youtubepy import Video
23
from PIL import Image, ImageTk
24
25
# ============================ Window Design ================================
26
27
top = Tk()
28
# - Top is Main Screen  Intialization
29
# - Menu bar Intialization
30
def Whatsapp_History():
31
    import whistory
32
def openweb():      # Software Update response
33
    webbrowser.open(url1, new=new)
34
35
def update_check():     # AutoCheck Software Update and Sub Screen
36
    response = r.get(res_url)
37
    response.raise_for_status()
38
    if messagebox.askyesno("Software Update",
39
            "New Update is Availabe, Click yes to install.") is True:
40
        openweb()
41
42
def find_update():              # Check Software Update - 2
43
    try:
44
        update_check()
45
        messagebox.showinfo("FYIT", "Thank You.")
46
    except r.ConnectionError as e:
47
        messagebox.showinfo("Connection Error",
48
                            "Check the Internet Connection")
49
    except r.exceptions.HTTPError as err:
50
        messagebox.showinfo("FYIT","No Update yet..")
51
52
def Cancel_Shutdown():
53
    try:
54
        pywhatkit.cancelShutdown()
55
        messagebox.showinfo("Shutdown Cancelled.", "Shutdown Scheduled time cancelled Successfully.")
56
    except NameError:
57
        messagebox.showwarning("No Schedule.", "Shutdown is not been Scheduled.")
58
59
# -----------Close Function--------------------------------------------------
60
61
def close_btn():
62
    if messagebox.askyesno("FYIT..", "Are you Sure you want to exit") is True:
63
        top.withdraw()
64
        top.destroy()
65
        top.exit()
66
67
# ---------------------------------------------------------------------------
68
69
if (1 ==1):
70
   try:
71
    import pywhatkit
72
   except Exception as e:
73
    messagebox.showwarning("No Internet or Internet is Slow", "Check Internet Connection")
74
else:
75
    messagebox.showwarning("No Internet or Internet is Slow", "Check Internet Connection")
76
77
menubar = Menu(top)
78
menubar.add_cascade(label="Whatsapp History", command=Whatsapp_History)
79
menubar.add_cascade(label="Cancel Shutdown", command=Cancel_Shutdown)
80
menubar.add_cascade(label="Check Update",command=find_update)
81
top.config(bg='black', menu=menubar)
82
83
# Styles and Designs Functions for Screens
84
# Color set for youtube for selectcolor, bg & activebackground #0B1D6F
85
yt_col = "#0B1D6F"  # Youtube bg Color
86
# Color set for facebook for selectcolor, bg & activebackground #075C90
87
fb_col = '#075C90' # Facebook bg Color
88
col_show = 'white'  # pure white fg
89
col_select = 'gray'  # gray for activeforeground
90
COLOR_1 = "#90B3DD" # TabControl Config Color
91
# Font Style and Size
92
large_font = font = ('Cascadia Mono', 16)  # style='my.head'
93
DisFont = font = ('', 14)  # style='my.default'
94
SubFont = font = ('Consolas', 12)  # style='my.sub'
95
tab_font = font = ('Consolas', 12)  # Tab font style
96
97
# Tab Control Style Config
98
tab_show = "#90B3DD"
99
tab_select = "#C8D9EE"
100
101
g_black = "#262626"
102
black = "#000000"
103
104
style = ttk.Style()
105
style.theme_create( "yummy", parent="alt", settings={
106
        "TNotebook": {"configure": { "tabmargins": [2, 5, 2, 0] } },
107
        "TNotebook.Tab": {
108
            "configure": {"padding": [15, 5], "foreground": 'gray', "background": black },
109
            "map":       {"background": [("selected", g_black)],
110
                          "foreground": [("selected", 'white')],
111
                          "expand": [("selected", [2, 3, 2, 0])] } } } )
112
style.theme_use("yummy")
113
114
# ------------------------ Screen and Tab -----------------------------------
115
116
style = ttk.Style(top)
117
style.configure('lefttab.TNotebook', tabposition='sw')
118
tabControl = ttk.Notebook(top, style='lefttab.TNotebook')
119
120
lb = 20
121
bd = 20
122
123
tabimg1 = Image.open("assets/wa.png")
124
tabimg1 = tabimg1.resize((lb,bd), Image.ANTIALIAS)
125
timg1 = ImageTk.PhotoImage(tabimg1)
126
127
tabimg2 = Image.open("assets/fs.png")
128
tabimg2 = tabimg2.resize((lb,bd), Image.ANTIALIAS)
129
timg2 = ImageTk.PhotoImage(tabimg2)
130
131
tabimg3 = Image.open("assets/yt.png")
132
tabimg3 = tabimg3.resize((lb,bd), Image.ANTIALIAS)
133
timg3 = ImageTk.PhotoImage(tabimg3)
134
135
tabimg4 = Image.open("assets/fb.png")
136
tabimg4 = tabimg4.resize((lb,bd), Image.ANTIALIAS)
137
timg4 = ImageTk.PhotoImage(tabimg4)
138
139
tabimg5 = Image.open("assets/i.png")
140
tabimg5 = tabimg5.resize((lb,bd), Image.ANTIALIAS)
141
timg5 = ImageTk.PhotoImage(tabimg5)
142
143
tab4 = ttk.Frame(tabControl)
144
tabControl.add(tab4, text='WhatsApp-MessageSender', image=timg1, compound='left')
145
146
tab5 = ttk.Frame(tabControl)
147
tabControl.add(tab5,text='Fast-YoutubeSearch', image=timg2, compound='left')
148
149
tab1 = ttk.Frame(tabControl)        # Tab1 - Youtube
150
tabControl.add(tab1, text='Youtube-Downloader', image=timg3, compound='left')
151
152
tab2 = ttk.Frame(tabControl)        # Tab2 - Facebook
153
tabControl.add(tab2, text='Facebook-Downloader', image=timg4, compound='left')
154
155
tab3 = ttk.Frame(tabControl)        # Tab3 - About
156
tabControl.add(tab3, text='About', image=timg5, compound='left')
157
158
tabControl.pack()
159
160
top.iconbitmap('assets/youtubedownloader.ico')  # Window Title Icon
161
top.title("FYIT Download Manager :")  # Title Label
162
top.geometry("800x520+100+100")  # Screen Size
163
164
photo = PhotoImage(file="assets/youtubebg.png")  # Tab1 Background
165
w = Label(tab1, image=photo)
166
w.pack()
167
168
photo2 = PhotoImage(file="assets/facebookbg.png")  # Tab2 Background
169
w2 = Label(tab2, image=photo2)
170
w2.pack()
171
172
top.resizable(0,  0)     # Disable the Maximize & Minimize option
173
174
var1 = StringVar()
175
# Entry Widget for Youtube Downloader Tab
176
url = Entry(tab1, textvariable=var1, font=large_font, fg='darkblue')
177
url.place(x=70, y=117, width=500, height=30)
178
179
# Entry Widget for Facebook Downloader Tab
180
url_fb = Entry(tab2, textvariable=var1, font=large_font, fg='darkblue')
181
url_fb.place(x=70, y=117, width=500, height=30)
182
183
# Quit_button placed in tab1
184
quit_button = Button(tab1,
185
                         text="Quit",
186
                         relief=SOLID,
187
                         font=SubFont,
188
                         cursor='hand2',
189
                         command=close_btn)
190
quit_button.place(x=60, y=400, width=200, height=30)
191
192
# ----------------------- Auto URL Paste Functions --------------------------
193
194
temp = clipboard.paste()
195
url.insert('end', temp)
196
url_fb.insert('end', temp)
197
var1.set(temp)
198
199
200
def paste():  # Paste text from Clipboard - Function
201
    variable = clipboard.paste()
202
    url.insert('end', variable)
203
    url_fb.insert('end', variable)
204
    var1.set(variable)
205
206
def e1_delete():  # Clear text from Entry - Function
207
    url.delete(0, 'end')
208
    url_fb.delete(0, 'end')
209
210
def toggle(tog=[0]):  # Toggle Button for clear and paste
211
    tog[0] = not tog[0]
212
    if tog[0]:
213
        t_btn.config(text='Paste')
214
        t_btn1.config(text='Paste')
215
        e1_delete()
216
    else:
217
        t_btn.config(text='Clear')
218
        t_btn1.config(text='Clear')
219
        paste()
220
221
# tab1 clear & paste
222
t_btn1 = ttk.Button(tab1, text="Clear", cursor='hand2', style='my.TButton', command=toggle)
223
t_btn1.place(x=571, y=118, width=45, height=29)
224
225
# tab2 clear & paste
226
t_btn = ttk.Button(tab2, text="Clear", cursor='hand2', style='my.TButton', command=toggle)
227
t_btn.place(x=571, y=118, width=45, height=29)
228
229
# ------------------ Fetching Part from Youtube ----------------------------
230
231
new = 1
232
url1 = "https://bit.ly/site-fyit"
233
res_url = "https://github.com/DeepakChakravarthy/YoutubeDownloader-FYI/releases/download/V3.0/FYI.DOWNLOAD.EXE"
234
235
# -------------------Youtube Function Call-----------------------------------
236
237
def get_fetch():
238
    resolution = Rvideo.get()
239
    Select = A_Video.get()
240
    Selection = A_Audio.get()
241
242
    try:
243
        update_check()
244
    except r.exceptions.HTTPError as err:
245
        # - No Updates
246
	    messagebox.showinfo("FYIT", "Select Location to Save the File.")
247
248
    except r.ConnectionError as e:
249
        messagebox.showinfo("Connection Error", "Check the Internet Connection")
250
251
    try:
252
        if var1 is None:
253
            print("error")
254
        dirname = filedialog.askdirectory(parent=tab1,
255
                                          initialdir="/",
256
                                          title='Please select a directory:')
257
258
        if dirname:
259
            try:
260
                # Youtube Video with Resolution
261
                if resolution <= 3:
262
                    yt = pytube.YouTube(var1.get())
263
264
                    if resolution == 1:
265
                        progress_bar = ttk.Progressbar(tab1,
266
                                                       orient='horizontal',
267
                                                       length=500,
268
                                                       mode='determinate')
269
                        progress_bar.place(x=70, y=160)
270
                        progress_bar.start()
271
                        messagebox.showinfo(
272
                            "Download",
273
                            "Downloading.. Please Wait for a Minute.")
274
                        video = yt.streams.get_by_itag(22)
275
                        video.download(dirname)
276
                        messagebox.showinfo("Downloaded. ", "Thank You..")
277
278
                    elif resolution == 2:
279
                        progress_bar = ttk.Progressbar(tab1,
280
                                                       orient='horizontal',
281
                                                       length=500,
282
                                                       mode='determinate')
283
                        progress_bar.place(x=70, y=160)
284
                        progress_bar.start()
285
                        messagebox.showinfo("Download", "Downloading...")
286
                        video = yt.streams.first()
287
                        video.download(dirname)
288
                        messagebox.showinfo("Downloaded. ", "Thank You..")
289
290
                    elif resolution == 3:
291
                        progress_bar = ttk.Progressbar(tab1,
292
                                                       orient='horizontal',
293
                                                       length=500,
294
                                                       mode='determinate')
295
                        progress_bar.place(x=70, y=160)
296
                        progress_bar.start()
297
                        messagebox.showinfo("Download", "Downloading...")
298
                        video = yt.streams.get_by_itag(36)
299
                        video.download(dirname)
300
                        messagebox.showinfo("Downloaded. ", "Thank You..")
301
302
                # Download Playlist
303
                if Select == 1:
304
                    playlist = pytube.Playlist(var1.get())
305
                    progress_bar = ttk.Progressbar(tab1,
306
                                                   orient='horizontal',
307
                                                   length=500,
308
                                                   mode='determinate')
309
                    progress_bar.place(x=70, y=160)
310
                    progress_bar.start()
311
                    playlist.populate_video_urls()  # To load bulk list
312
                    messagebox.showinfo("Download", "Downloading...")
313
                    playlist.download_all(dirname)
314
                    messagebox.showinfo("Downloaded. ", "Thank You..")
315
316
                # Audio files
317
                if Selection <= 2:
318
                    link = YouTube(var1.get())
319
                    format_a = link.streams.filter(only_audio=True).all()
320
321
                    if Selection == 1:  # mp4
322
                        progress_bar = ttk.Progressbar(tab1,
323
                                                       orient='horizontal',
324
                                                       length=500,
325
                                                       mode='determinate')
326
                        progress_bar.place(x=70, y=160)
327
                        progress_bar.start()
328
                        messagebox.showinfo("Download", "Downloading...")
329
                        format_a[0].download(dirname)
330
                        messagebox.showinfo("Downloaded. ", "Thank You..")
331
332
                    elif Selection == 2:  # webm
333
                        progress_bar = ttk.Progressbar(tab1,
334
                                                       orient='horizontal',
335
                                                       length=500,
336
                                                       mode='determinate')
337
                        progress_bar.place(x=70, y=160)
338
                        progress_bar.start()
339
                        messagebox.showinfo("Download", "Downloading...")
340
                        format_a[1].download(dirname)
341
                        messagebox.showinfo("Downloaded. ", "Thank You..")
342
                messagebox.showinfo("FYIT", "Please Select Valid option")
343
            except Exception as a:
344
                messagebox.showwarning(" FYIT.. ", "Failed")
345
        else:
346
            messagebox.showwarning(" FYIT. ", "Cancelled")
347
    except Exception as a:
348
        messagebox.showwarning(" FYIT. ", "Cancelled")
349
        sys.exit()
350
351
downbtn = Button(tab1,
352
                 text="Download",
353
                 relief=SOLID,
354
                 font=SubFont,
355
                 command=get_fetch,
356
                 cursor='hand2' )
357
downbtn.place(x=500, y=400, width=200, height=30)   # Download button Tab1
358
yt_label = Label(tab1,
359
                 text="Enter the Link to Download",
360
                 font=large_font,
361
                 bg="#0B1D6F",
362
                 fg="White")
363
yt_label.place(x=65, y=65)                          # Label placed in Tab1
364
365
# -----------------Radio button for video resolution-------------------------
366
367
Rvideo = IntVar()       # Variable Daclaraton for Youtube Video (options)
368
resolution_label = Label(tab1,
369
                         text="Video Resolution:",
370
                         font=DisFont,
371
                         bg="#0B1D6F",
372
                         fg="white")
373
resolution_label.place(x=75, y=200)
374
R1 = Radiobutton(tab1,
375
                 text="Mp4 720",
376
                 cursor='hand2',
377
                 font=SubFont,
378
                 variable=Rvideo,
379
                 value=1,
380
                 fg=col_show,
381
                 bg=yt_col,
382
                 activebackground=yt_col,
383
                 activeforeground=col_select,
384
                 selectcolor=yt_col)
385
R1.place(x=80, y=240)
386
R2 = Radiobutton(tab1,
387
                 text="Mp4 360px",
388
                 cursor='hand2',
389
                 font=SubFont,
390
                 variable=Rvideo,
391
                 value=2,
392
                 fg=col_show,
393
                 bg=yt_col,
394
                 activebackground=yt_col,
395
                 activeforeground=col_select,
396
                 selectcolor=yt_col)
397
R2.place(x=80, y=280)
398
R3 = Radiobutton(tab1,
399
                 text="3gp 144px",
400
                 cursor='hand2',
401
                 font=SubFont,
402
                 variable=Rvideo,
403
                 value=3,
404
                 fg=col_show,
405
                 bg=yt_col,
406
                 activebackground=yt_col,
407
                 activeforeground=col_select,
408
                 selectcolor=yt_col)
409
R3.place(x=80, y=320)
410
411
# -----------------Radio button for video to Audio----------------------------
412
413
A_Audio = IntVar()      # Variable Daclaraton for Youtube Audio (options)
414
format_label = Label(tab1,
415
                     text="Only Audio:",
416
                     font=DisFont,
417
                     bg="#0B1D6F",
418
                     fg="white")
419
format_label.place(x=260, y=200)
420
R4 = Radiobutton(tab1,
421
                 text="Mp4 Audio",
422
                 cursor='hand2',
423
                 font=SubFont,
424
                 variable=A_Audio,
425
                 value=1,
426
                 fg=col_show,
427
                 bg=yt_col,
428
                 activebackground=yt_col,
429
                 activeforeground=col_select,
430
                 selectcolor=yt_col)
431
R4.place(x=265, y=240)
432
R5 = Radiobutton(tab1,
433
                 text="webm",
434
                 cursor='hand2',
435
                 font=SubFont,
436
                 variable=A_Audio,
437
                 value=2,
438
                 fg=col_show,
439
                 bg=yt_col,
440
                 activebackground=yt_col,
441
                 activeforeground=col_select,
442
                 selectcolor=yt_col)
443
R5.place(x=265, y=280)
444
445
# -----------------Radio button for Playlist video --------------------------
446
447
A_Video = IntVar()      # Variable Daclaraton for Youtube Playlist (options)
448
list_label = Label(tab1,
449
                   text="Download Playlist:",
450
                   font=DisFont,
451
                   bg="#0B1D6F",
452
                   fg="white")
453
list_label.place(x=415, y=200)
454
R7 = Radiobutton(tab1,
455
                 text="High (Default)",
456
                 cursor='hand2',
457
                 font=SubFont,
458
                 variable=A_Video,
459
                 value=1,
460
                 fg=col_show,
461
                 bg=yt_col,
462
                 activebackground=yt_col,
463
                 activeforeground=col_select,
464
                 selectcolor=yt_col)
465
R7.place(x=420, y=240)
466
467
# ======================= Facebook Control ==================================
468
469
quit_button = Button(tab2,
470
                         text="Quit",
471
                         relief=SOLID,
472
                         font=SubFont,
473
                         cursor='hand2',
474
                         command=close_btn)
475
quit_button.place(x=60, y=400, width=200, height=30)    # Quit_button placed in tab2
476
fb_label = Label(tab2,
477
                 text="Enter the Link to Download",
478
                 font=large_font,
479
                 bg="#075C90",
480
                 fg="White")
481
fb_label.place(x=65, y=65)      # Label placed in Tab2
482
483
def FacebookDownload():         # FacebookDownloader Main Fuction
484
    try:
485
        update_check()
486
    except r.exceptions.HTTPError as err:
487
	    messagebox.showinfo("FYIT", "Select Location to Download.")
488
    except r.ConnectionError as e:
489
        messagebox.showinfo("Connection Error",
490
                            "Check the Internet Connection")
491
492
    try:
493
        html = r.get(var1.get())
494
        dirname = filedialog.askdirectory(parent=tab2,
495
                                          initialdir="/",
496
                                          title='Please select a directory:')
497
498
        if dirname:
499
            hdvideo_url = re.search('hd_src:"(.+?)"', html.text)[1]
500
        try:
501
            hd_url = hdvideo_url.replace('hd_src:"', '')
0 ignored issues
show
introduced by
The variable hdvideo_url does not seem to be defined in case dirname on line 498 is False. Are you sure this can never be the case?
Loading history...
502
            messagebox.showinfo("FYIT", "[+] Video Started Downloading")
503
            progress_bar = ttk.Progressbar(tab2,
504
                                           orient='horizontal',
505
                                           length=500,
506
                                           mode='determinate')
507
            progress_bar.place(x=60, y=180)
508
            progress_bar.start()
509
            wget.download(hd_url, dirname)
510
            ERASE_LINE = '\x1b[2K'
511
            sys.stdout.write(ERASE_LINE)
512
            messagebox.showinfo("FYIT", "Video downloaded")
513
            progress_bar.stop()
514
        except r.ConnectionError as e:
515
            messagebox.showerror("FYIT", "ConnectionError")
516
        except r.Timeout as e:
517
            messagebox.showinfo("FYIT", "Tomeout")
518
        except r.RequestException as e:
519
            messagebox.showerror("FYIT", "General Error or Invalid URL")
520
        except (KeyboardInterrupt, SystemExit):
521
            messagebox.showinfo("FYIT", "SystemExit")
522
            sys.exit()
523
        except TypeError:
524
            messagebox.showerror("FYIT", "Video May Private or InvalidURL")
525
    except Exception as e:
526
        messagebox.showwarning("FYIT", "Cancelled")
527
528
downbtnfb = Button(tab2,
529
                   text="Download",
530
                   relief=SOLID,
531
                   font=SubFont,
532
                   command=FacebookDownload,
533
                   cursor='hand2')
534
downbtnfb.place(x=500, y=400, width=200, height=30)    # Download placed in Tab2
535
536
# ======================= About Tab Control ===================================
537
538
def check_it(hyper_link):
539
    # About tab Redirect Link (Frame1)
540
    webbrowser.open_new(hyper_link)
541
542
tab3_style = ttk.Style()
543
544
frame1 = tk.Frame(master=tab3, width=260)           # Tab3_Frame1
545
frame1.pack(fill=tk.BOTH, side=tk.LEFT, expand=True)
546
547
imge = PhotoImage(file='assets/sidebar.png')
548
pht = Label(frame1, image=imge)
549
pht.pack()
550
551
link_1 = Label(frame1,
552
                text="How to use..?",
553
                font=tab_font,
554
                fg="blue",
555
                bg="#90B3DD",
556
                activeforeground="red",
557
                activebackground="green",
558
                cursor="hand2",
559
                underline=0)
560
link_1.place(x=20, y=260)
561
link_1.bind("<Button-1>",
562
            lambda e: check_it())
563
564
link_2 = Label(frame1,
565
                text="Help..!",
566
                font=tab_font,
567
                fg="blue",
568
                bg="#90B3DD",
569
                activeforeground="red",
570
                activebackground="green",
571
                cursor="hand2",
572
                underline=0)
573
link_2.place(x=20, y=300)
574
link_2.bind("<Button-1>",
575
            lambda e: check_it("http://bit.ly/site-fyit"))
576
577
link_3 = Label(frame1,
578
               text="Contact us..",
579
               font=tab_font,
580
               fg="blue",
581
               bg="#90B3DD",
582
               activeforeground="red",
583
               activebackground="green",
584
               cursor="hand2",
585
               underline=0)
586
link_3.place(x=20, y=340)
587
link_3.bind("<Button-1>",
588
            lambda e: check_it("https://gitter.im/FYIT-DOWNLOADER/DEV-FYI?utm_source=share-link&utm_medium=link&utm_campaign=share-link"))
589
590
link_4 = Label(frame1,
591
                text="Visit us..",
592
                font=tab_font,
593
                fg="blue",
594
                bg="#90B3DD",
595
                activeforeground="red",
596
                activebackground="green",
597
                cursor="hand2",
598
                underline=0)
599
link_4.place(x=20, y=380)
600
link_4.bind("<Button-1>",
601
            lambda e: check_it("http://bit.ly/site-fyit"))
602
603
link_5 = Button(frame1,
604
                text="Check Update..",
605
                font=tab_font,
606
                command=find_update,
607
                fg="blue",
608
                bg="#90B3DD",
609
                activeforeground="red",
610
                activebackground="#90B3DD",
611
                cursor="hand2",
612
                relief=FLAT,
613
                underline=0)
614
link_5.place(x=20, y=420)
615
link_5.config(highlightthickness=0)
616
617
frame2 = HtmlFrame(master=tab3, width=640, horizontal_scrollbar="auto")     # Tab3_Frame2
618
frame2.pack(fill=tk.BOTH, side=tk.LEFT, expand=True)
619
620
frame2.set_content(open("assets/help.html", "r").read())
621
622
# ----------------------------Fast Youtube Search ----------------
623
624
cust_font = font = ('Consolas', 16)
625
width = 800
626
height = 500
627
img1 = Image.open("assets/ytsearchbg.png")
628
img1 = img1.resize((width, height), Image.ANTIALIAS)
629
photoImg1 = ImageTk.PhotoImage(img1)
630
wb1 = Label(tab5, image=photoImg1)
631
wb1.pack()
632
633
Name_Label = Label(tab5, font=cust_font,
634
                   text="Fast Search in Youtube", bg='#232621', fg='#ffffff')
635
Name_Label.place(x=130, y=140,  width=280, height=30)
636
637
Search_Key = StringVar()
638
639
KeyEntry = Entry(tab5, font=cust_font, textvariable=Search_Key)
640
KeyEntry.place(x=130, y=200, width=550, height=30)
641
642
def Key():
643
    #pywhatkit.playonyt(Search_Key.get())
644
    #Search_Key Variable to check the Keyword
645
646
    Fs_Search = Video(Search_Key.get())
647
    Out = Fs_Search.search()
648
    webbrowser.open_new(Out)
649
650
651
Search_Button = Button(tab5, font=cust_font, text="Search", command=Key)
652
Search_Button.place(x=530, y=320, width=150, height=30)
653
tab5.update()
654
655
# ----------------------- Whatsapp Screen-----------------------------------
656
657
cust_font1 = font = ('Consolas', 14)
658
width1 = 800
659
height1 = 500
660
img = Image.open("assets/whatsappbg.png")
661
img = img.resize((width1, height1), Image.ANTIALIAS)
662
photoImg = ImageTk.PhotoImage(img)
663
wb = Label(tab4, image=photoImg)
664
wb.pack()
665
666
MobNum = StringVar()
667
Mob2msg = StringVar()
668
hour = IntVar()
669
minutes = IntVar()
670
671
Number = Label(tab4, text="Enter the Mobile No",
672
                    font=cust_font1, bg="#1B1B19", fg="#ffffff")
673
Number.place(x=100, y=70, width=200, height=30)
674
675
Message = Label(tab4, text="Enter the Message",
676
                    font=cust_font1, bg="#1B1B19", fg="#ffffff")
677
Message.place(x=100, y=120, width=185, height=30)
678
679
hourlabel = Label(tab4, text="Enter Schedule Time",
680
                    font=cust_font1, bg="#1B1B19", fg="#ffffff")
681
hourlabel.place(x=100, y=260, width=210, height=30)
682
683
Shutdown_label = Label(tab4, text="Enter Shutdown Timer",
684
                    font=cust_font1, bg="#1B1B19", fg="#ffffff")
685
Shutdown_label.place(x=100, y=310, width=220, height=30)
686
687
hrs_label = Label(tab4, text="hrs",
688
                    font=cust_font1, bg="#1B1B19", fg="#ffffff")
689
hrs_label.place(x=400, y=260, width=100, height=30)
690
691
mins_label = Label(tab4, text="mins.",
692
                     font=cust_font1, bg="#1B1B19", fg="#ffffff")
693
mins_label.place(x=560, y=260, width=100, height=30)
694
695
shut_label = Label(tab4, text="seconds.",
696
                   font=cust_font1, bg="#1B1B19", fg="#ffffff")
697
shut_label.place(x=430, y=310, width=100, height=30)
698
699
Entrynum = Entry(tab4, textvariable=MobNum, font=cust_font)
700
Entrynum.insert(0,"+91")
701
Entrynum.place(x=350, y=70, width=300, height=30)
702
703
Entrymsg = Text(tab4, font=cust_font)
704
Entrymsg.place(x=350, y=120, width=300, height=120)
705
706
hours = Spinbox(tab4, textvariable=hour, font=cust_font, from_=0, to=23)
707
hours.place(x=350, y=260, width=70, height=30)
708
709
mins = Spinbox(tab4, textvariable=minutes, font=cust_font, from_=0, to=59)
710
mins.place(x=500, y=260, width=70, height=30)
711
712
sleep = IntVar()
713
714
def shut_timer():
715
    sh_time = sleep.get()
716
717
    if sh_time == 0:
718
        try:
719
            pywhatkit.cancelShutdown()
720
            messagebox.showinfo("Shutdown Timer", "Shutdown timer is not fixed")
721
        except NameError:
722
            messagebox.showinfo("Shutdown Timer", "Shutdown timer is not fixed")
723
724
    elif sh_time <= 86400:
725
        messagebox.showinfo("Shutdown Timer", "When we sent WhatsApp message PC will shutdown after fixed timer")
726
        pywhatkit.shutdown(time=sh_time)
727
    else:
728
        messagebox.showinfo("Shutdown Timer", "Shutdown timer is Greater than 24hrs.")
729
730
def go():
731
    messagebox.showinfo("AutoWhatsappMessage",
732
    "Will open web.whatsapp.com at before 1 minute of Scheduled time and message \
733
    will be send Automatically at Scheduled time exactly Given")
734
735
    try:
736
        num = MobNum.get()
737
        msg = Entrymsg.get("1.0", "end-1c")
738
        hr = hour.get()
739
        mini = minutes.get()
740
741
        if (1 ==1):
742
            try:
743
                import pywhatkit
744
            except Exception as e:
745
                messagebox.showwarning("No Internet or Internet is Slow", "Check Internet Connection")
746
        else:
747
            messagebox.showwarning("No Internet or Internet is Slow", "Check Internet Connection")
748
        shut_timer()
749
        pywhatkit.sendwhatmsg(num, msg, hr, mini)
750
    except pywhatkit.CallTimeException:
751
        messagebox.showerror("AutoWhatsAppMessage",
752
                             "Set Schedule time More than 1 minute from Current Time")
753
    except pywhatkit.CountryCodeException:
754
        messagebox.showerror("AutoWhatsAppMessage",
755
                             "Please Ensure the mobile number & Coutry code.")
756
757
sleep_time = Spinbox(tab4, textvariable=sleep, font=cust_font, from_=0, to=86399)
758
sleep_time.place(x=350, y=310, height=30, width=80)
759
760
GoCheck = Button(tab4, text="Start Schedule", command=go, font=cust_font)
761
GoCheck.place(x=300, y=405)
762
763
764
765
766
label = Label(tab4,
767
        text="Time must be in 24 hours Format & Country Code is Must.",
768
        font=cust_font1, bg="#1B1B19", fg="#ffffff")
769
770
infinity = 1
771
while infinity == 1:
772
    for i in range(500):
773
        xpos = i
774
        label.place(x=xpos, y=20)
775
        time.sleep(0.01)
776
        if xpos == 500:
777
            xpos = 0
778
        tab4.update()
779
780
781
782
783
784
# ----------------------------- Close Function -------------------------------
785
786
top.config(bg='black')
787
788
top.mainloop()
789
790
def on_close():
791
    top.destroy()
792
    sys.exit()
793
794
top.protocol("WM_DELETE_WINDOW", on_close)
795