Passed
Pull Request — master (#45)
by Ram
01:01
created

Main.py (4 issues)

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