-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgui-get-rss.py
More file actions
135 lines (111 loc) · 5.93 KB
/
gui-get-rss.py
File metadata and controls
135 lines (111 loc) · 5.93 KB
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
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'form2.ui'
#
# Created by: PyQt5 UI code generator 5.15.10
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
import get_rss
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(931, 241)
self.gridLayoutWidget = QtWidgets.QWidget(Form)
self.gridLayoutWidget.setGeometry(QtCore.QRect(10, 10, 911, 221))
self.gridLayoutWidget.setObjectName("gridLayoutWidget")
self.gridLayout = QtWidgets.QGridLayout(self.gridLayoutWidget)
self.gridLayout.setContentsMargins(0, 0, 0, 0)
self.gridLayout.setObjectName("gridLayout")
self.YouTubeUsernameLineEdit = QtWidgets.QLineEdit(self.gridLayoutWidget)
self.YouTubeUsernameLineEdit.setObjectName("YouTubeUsernameLineEdit")
self.gridLayout.addWidget(self.YouTubeUsernameLineEdit, 3, 1, 1, 1)
self.GetRSSLinkButton = QtWidgets.QPushButton(self.gridLayoutWidget)
self.GetRSSLinkButton.setObjectName("GetRSSLinkButton")
self.gridLayout.addWidget(self.GetRSSLinkButton, 4, 1, 1, 1)
self.textEdit = QtWidgets.QTextEdit(self.gridLayoutWidget)
self.textEdit.setReadOnly(True)
self.textEdit.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction)
self.textEdit.setObjectName("textEdit")
self.gridLayout.addWidget(self.textEdit, 8, 1, 1, 1)
self.ProgressText = QtWidgets.QLabel(self.gridLayoutWidget)
font = QtGui.QFont()
font.setPointSize(8)
font.setItalic(True)
self.ProgressText.setFont(font)
self.ProgressText.setAlignment(QtCore.Qt.AlignCenter)
self.ProgressText.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
self.ProgressText.setObjectName("ProgressText")
self.gridLayout.addWidget(self.ProgressText, 6, 1, 1, 1)
spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.gridLayout.addItem(spacerItem, 2, 1, 1, 1)
self.TitleLabel = QtWidgets.QLabel(self.gridLayoutWidget)
font = QtGui.QFont()
font.setPointSize(16)
font.setBold(True)
font.setUnderline(True)
self.TitleLabel.setFont(font)
self.TitleLabel.setTextFormat(QtCore.Qt.PlainText)
self.TitleLabel.setAlignment(QtCore.Qt.AlignCenter)
self.TitleLabel.setObjectName("TitleLabel")
self.gridLayout.addWidget(self.TitleLabel, 1, 1, 1, 1)
spacerItem1 = QtWidgets.QSpacerItem(20, 10, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed)
self.gridLayout.addItem(spacerItem1, 7, 1, 1, 1)
spacerItem2 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.gridLayout.addItem(spacerItem2, 9, 1, 1, 1)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Dontna's YouTube RSS Scraper GUI"))
self.YouTubeUsernameLineEdit.setPlaceholderText(_translate("Form", "Enter YouTube username or channel link here..."))
self.GetRSSLinkButton.setText(_translate("Form", "Get RSS Link"))
self.textEdit.setPlaceholderText(_translate("Form", "RSS Links will show here..."))
self.ProgressText.setText(_translate("Form", "Nothing to do."))
self.TitleLabel.setText(_translate("Form", "Dontna\'s YouTube RSS Scraper"))
self.GetRSSLinkButton.setShortcut(_translate("Form", "Return"))
self.GetRSSLinkButton.clicked.connect(self.getRSSButtonClicked)
def showPopupError(self, title, message):
msg = QtWidgets.QMessageBox()
msg.setIcon(QtWidgets.QMessageBox.Critical)
msg.setText(message)
msg.setWindowTitle(title)
msg.exec_()
def updateResultsBox(self, message):
self.textEdit.append(message)
self.textEdit.repaint()
def updateProgressText(self, message):
self.ProgressText.setText(QtCore.QCoreApplication.translate("Form", message))
def getRSSButtonClicked(self):
if self.YouTubeUsernameLineEdit.text() == "":
self.showPopupError("Error","Error: Cannot search for nothing, please enter a username!")
return
username_string = str(self.YouTubeUsernameLineEdit.text()).strip()
if username_string.__contains__("https://") and not username_string.__contains__("www.youtube.com"):
self.showPopupError("Error","Error: Link does not look like valid YouTube link, please try again.")
return
if username_string.__contains__("watch?v="):
self.showPopupError("Error", "Error: Link looks like a video link, please enter a channel link.")
return
if username_string.__contains__("https://www.youtube.com/"):
channel_link = username_string
username_string = username_string.replace('https://www.youtube.com/','')
else:
self.updateProgressText("Generating channel link, please wait...")
channel_link = get_rss.GenerateChannelLink(username_string)
self.updateProgressText("Getting RSS Link...")
RSS_link = get_rss.GetRSSLink(channel_link)
if RSS_link == 1:
self.showPopupError("Error", "Error: Invalid page, are you sure the username is correct?")
return
self.updateProgressText("Printing RSS Link...")
self.updateResultsBox(f"{username_string} RSS Link: {RSS_link}")
self.updateProgressText("Finished without error.")
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_Form()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())