|
| 1 | +# fmt: off |
1 | 2 | from datetime import datetime
|
2 |
| -from os import path as ospath, remove, rename |
| 3 | +from os import environ, getcwd, listdir |
| 4 | +from os import path as ospath |
| 5 | +from os import pathsep, remove, rename |
| 6 | +from platform import system |
3 | 7 | from sys import exit
|
4 | 8 | from threading import Thread
|
5 |
| -from tkinter import messagebox, Toplevel |
| 9 | +from tkinter import messagebox |
6 | 10 | from urllib import request
|
7 | 11 |
|
8 | 12 | from mutagen.flac import FLAC, Picture
|
|
18 | 22 | from youtube_search import YoutubeSearch
|
19 | 23 | from ytmusicapi import YTMusic
|
20 | 24 |
|
21 |
| -__version__ = "v1.67" |
| 25 | +# fmt: on |
| 26 | + |
| 27 | +__version__ = "v1.68" |
22 | 28 | __supported_filetypes__ = (".m4a", ".mp3", ".wav", ".flac")
|
23 | 29 |
|
24 |
| -response = ( |
25 |
| - get("https://api.github.com/repos/rickyrorton/spotify-downloader/releases/latest") |
26 |
| -).json() |
27 |
| -data = response["tag_name"] |
28 |
| -if data.lower() != __version__.lower(): |
29 |
| - ch = messagebox.askokcancel( |
30 |
| - "UPDATE APP", |
31 |
| - f"Press OK to update your app to the latest version {data} from the github repository", |
32 |
| - ) |
33 |
| - if ch: |
34 |
| - from webbrowser import open_new_tab |
35 | 30 |
|
36 |
| - open_new_tab("https://github.com/rickyrorton/spotify-downloader/releases") |
37 |
| - exit() |
| 31 | +def checkversion(): |
| 32 | + response = ( |
| 33 | + get( |
| 34 | + "https://api.github.com/repos/rickyrorton/spotify-downloader/releases/latest" |
| 35 | + ) |
| 36 | + ).json() |
| 37 | + data = response["tag_name"] |
| 38 | + if data.lower() != __version__.lower(): |
| 39 | + ch = messagebox.askokcancel( |
| 40 | + "UPDATE APP", |
| 41 | + f"Press OK to update your app to the latest version {data} from the github repository", |
| 42 | + ) |
| 43 | + if ch: |
| 44 | + from webbrowser import open_new_tab |
| 45 | + |
| 46 | + open_new_tab("https://github.com/rickyrorton/spotify-downloader/releases") |
| 47 | + elif __name__ != "__main__": |
| 48 | + exit() |
38 | 49 |
|
| 50 | + |
| 51 | +t = Thread(target=checkversion()) |
| 52 | +t.start() |
| 53 | +t.join() |
| 54 | + |
| 55 | + |
| 56 | +def checkffmpeg(): |
| 57 | + ffmpeg = ["ffmpeg.exe", "ffplay.exe", "ffprobe.exe"] |
| 58 | + dirs = environ["PATH"].split(pathsep)[0:-1] |
| 59 | + dirs.append(getcwd()) |
| 60 | + ffmpeg_present = False |
| 61 | + for i in dirs: |
| 62 | + if all(j in listdir(i) for j in ffmpeg) and len(listdir(i)) != 0: |
| 63 | + ffmpeg_present = True |
| 64 | + break |
| 65 | + |
| 66 | + if not ffmpeg_present: |
| 67 | + ch = messagebox.askokcancel( |
| 68 | + "DOWNLOAD FFMPEG", |
| 69 | + f"Download ffmpeg to use formats like mp3,press OK to download ffmpeg", |
| 70 | + ) |
| 71 | + if ch: |
| 72 | + if system() == "Windows": |
| 73 | + request.urlretrieve( |
| 74 | + "https://www.gyan.dev/ffmpeg/builds/ffmpeg-git-essentials.7z", |
| 75 | + ospath.join(getcwd(), "ffmpeg.7z"), |
| 76 | + ) |
| 77 | + messagebox.showinfo( |
| 78 | + "INSTALL FFMPEG", |
| 79 | + "FFMPEG has been downloaded,extract the contents of the bin folder and place them in the same directory as the downloader", |
| 80 | + ) |
| 81 | + |
| 82 | + |
| 83 | +try: |
| 84 | + checkffmpeg() |
| 85 | +except: |
| 86 | + messagebox.showinfo( |
| 87 | + "FFMPEG Check failed", |
| 88 | + "FFMPEG executables couldnt be found to download formats other than m4a ffmpeg has to be downloaded manually", |
| 89 | + ) |
39 | 90 | ytm = YTMusic()
|
40 | 91 |
|
41 | 92 |
|
|
0 commit comments