-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
72 lines (56 loc) · 2.05 KB
/
main.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
from main_window import Ui_Form
import progress_window
import downloader, utils
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QFileDialog
import threading
import sys, os
app = QtWidgets.QApplication(sys.argv)
Form = QtWidgets.QWidget()
ui = Ui_Form()
ui.setupUi(Form)
#Main Code
def setDirectori():
'''Получаем путь к нужной директории'''
try:
dir_name = QFileDialog.getExistingDirectory()
ui.lineEdit_2.setText(dir_name)
except:
return 0
def getDirectory():
'''Возвращаем выбранный путь к директории, в которую хотим скачать файл'''
path_dir = ui.lineEdit_2.text()
return path_dir
def getRes():
'''Возвращаем выбранное качество медиафайла'''
index = ui.comboBox.currentIndex()
res = ui.comboBox.itemText(index)[0:3]
return res
def getURL():
'''Получаем введенный URL'''
URL = ui.lineEdit.text()
return URL
def getSizeTubeFile(URL, res):
'''Возвращаем полный размер медиафайла который пытаемся скачать'''
size = downloader.getSizeTubeObject(URL, res)
return size
def getSizeDownloadingFile():
'''Возвращаем текущий размер файла, который скачиваем'''
URL = getURL()
res = getRes()
filename = downloader.getTitleMediaFile(URL, res)
path_directory = getDirectory()
size_downloading_file_in_megabite = utils.getSizeFile(filename, path_directory)
return size_downloading_file_in_megabite
def downloadFile():
'''скачиваем видеофайл'''
URL = getURL()
res = getRes()
path_directory = getDirectory()
size_youtube_file_in_megabite = getSizeTubeFile(URL, res)
downloader.main(URL, res, path_directory)
progress_window.callDownloader(size_youtube_file_in_megabite)
ui.toolButton.clicked.connect(setDirectori)
ui.pushButton.clicked.connect(downloadFile)
Form.show()
sys.exit(app.exec_())