-
Notifications
You must be signed in to change notification settings - Fork 0
/
moosik.py
108 lines (83 loc) · 2.7 KB
/
moosik.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import sys
import subprocess
import tkinter as tk
from tkinter import *
from tkinter.ttk import *
from subprocess import Popen, PIPE, STDOUT
import scripts.playlistDownloader as PlaylistDownloader
def install(package):
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
def runCommand(commandArray):
result = subprocess.run(
commandArray,
stdout=subprocess.PIPE
)
result = result.stdout.splitlines()
result = result[-2]
result = result.decode('utf-8')
return result
def dependencies():
try:
import pytube
except ImportError:
install("pytube")
import pytube
try:
import colorama
except ImportError:
install("colorama")
import colorama
try:
import youtube_dl
except ImportError:
install("youtube_dl")
import youtube_dl
try:
import spotdl
except ImportError:
install("spotdl")
import spotdl
try:
import requests
except ImportError:
install("requests")
import requests
try:
import bs4
except ImportError:
install("bs4")
import bs4
try:
import moviepy
except ImportError:
install("moviepy")
import moviepy
p = Popen(["spotdl", "--download-ffmpeg"], stdout=PIPE, stdin=PIPE, stderr=PIPE)
p.communicate(input='N'.encode(encoding="utf-8"))
print("Booting up...")
dependencies()
class GUI():
window = tk.Tk()
playlistPhoto = PhotoImage(file = r"assets\playlist.png").subsample(5, 5)
returnImage = PhotoImage(file = r"assets\return.png").subsample(15, 15)
def insertBanner(self, title, targetMethod):
Button(self.window, width='25', image=self.returnImage, command=targetMethod).place(anchor='nw')
Label(self.window, text =title, font =('Verdana', 15)).pack(side=TOP)
def openPlaylistDownloader(self):
downloader = PlaylistDownloader.PlaylistDownloader()
downloader.guiStart(self)
def createBtn(self, title, image, command):
Button(self.window, text = title, image = image,compound = BOTTOM, command= command).pack(side = TOP)
def clearWindow(self):
for widget in self.window.winfo_children():
widget.destroy()
def openMainMenu(self):
self.clearWindow()
Label(self.window, text = 'Playlist Downloader', font =('Verdana', 15)).pack(side = TOP)
self.createBtn("Playlist Downloader", gui.playlistPhoto, gui.openPlaylistDownloader)
print("Launching GUI...")
gui = GUI()
gui.window.title = "Moosik"
gui.openMainMenu()
gui.window.mainloop()
print("Closing...")