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

Main.py (1 issue)

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