Passed
Pull Request — master (#43)
by Ram
43s
created

Main.py (1 issue)

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