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