-
Notifications
You must be signed in to change notification settings - Fork 0
/
YTube_GUI.py
155 lines (102 loc) · 4.67 KB
/
YTube_GUI.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 18 11:33:59 2020
@author: fbasatemur
"""
from PyQt5.QtWidgets import QMainWindow, QLineEdit, QLabel, QComboBox, QRadioButton, QPushButton, QProgressBar
from PyQt5.QtGui import QIcon, QPixmap, QFont
from PyQt5.QtCore import Qt
from YTube_downloader import Downloader
class Window(QMainWindow):
def __init__(self):
super().__init__()
# main window
self.width = 640
self.height = 480
self.setWindowTitle("YTube Downloader")
self.setGeometry(200, 200, self.width, self.height)
self.setWindowIcon(QIcon("YTube_image.jpg"))
self.entry()
self.labelURL()
self.radioButton()
self.infoButton()
self.downloadButton()
self.imageShow()
self.labelInfo()
self.labelInfoResult()
self.comboBoxShow()
self.downloadBar()
self.show()
def entry(self):
self.textbox = QLineEdit(self)
self.textbox.move(50, 65)
self.textbox.resize(300,25)
def labelURL(self):
self.labelURLText = QLabel("URL Address: ", self)
self.labelURLText.move(50,35)
self.labelURLText.setFont(QFont("Arial", 9, QFont.Bold))
def labelInfo(self):
self.labelTitle = QLabel("Title: ", self)
self.labelTitle.move(50,270)
self.labelTitle.setFont(QFont("Arial", 9, QFont.Bold))
self.labelAuthor = QLabel("Author: ", self)
self.labelAuthor.move(50,290)
self.labelAuthor.setFont(QFont("Arial", 9, QFont.Bold))
def labelInfoResult(self):
self.labelTitleResult = QLabel(" __ ", self)
self.labelTitleResult.move(110,270)
self.labelTitleResult.resize(500,30)
self.labelAuthorResult = QLabel(" __ ", self)
self.labelAuthorResult.move(110,290)
self.labelAuthorResult.resize(500,30)
def imageShow(self):
self.image = QLabel(self)
self.image.resize(240, 240)
self.image.move(370, 20)
def comboBoxShow(self):
self.combo = QComboBox(self)
self.combo.move(140,120)
def radioButton(self):
self.radioBtnVideo = QRadioButton("Video", self)
self.radioBtnAudio = QRadioButton("Audio", self)
self.radioBtnVideo.move(50,120)
self.radioBtnAudio.move(50,145)
self.radioBtnVideo.setChecked(True)
def infoButton(self):
self.infoBtn = QPushButton("info", self)
self.infoBtn.move(250,120)
self.infoBtn.clicked.connect(self.infoBtnFunc)
def downloadButton(self):
self.downloadBtn = QPushButton("Download", self)
self.downloadBtn.move(250,160)
self.downloadBtn.clicked.connect(self.downloadBtnFunction)
def infoBtnFunc(self):
self.pbar.setValue(0)
self.down = Downloader(self.textbox.text())
self.down.dataInfo()
if(self.radioBtnVideo.isChecked()):
self.down.downloadInfoVideo()
else:
self.down.downloadInfoAudio()
self.down.downloadThumbImage()
self.setPixmap()
self.infoShow()
self.comboBoxAddItems()
def infoShow(self):
self.labelTitleResult.setText(self.down.title)
self.labelAuthorResult.setText(self.down.author)
def setPixmap(self):
pixmap = QPixmap('thumbnail.jpg')
smaller_pixmap = pixmap.scaled(240, 240, Qt.KeepAspectRatio, Qt.FastTransformation)
self.image.setPixmap(smaller_pixmap)
def comboBoxAddItems(self):
self.combo.clear()
self.combo.addItems(self.down.resList)
def downloadBtnFunction(self):
resIndex = self.down.resList.index(self.combo.currentText())
self.down.download(self.down.itagList[resIndex])
self.pbar.setValue(100)
def downloadBar(self):
self.pbar = QProgressBar(self)
self.pbar.setGeometry(50, 340, 300, 28)
self.pbar.setValue(0)