echorev 0.0.8__zip
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- echorev-0.0.8/LICENSE +674 -0
- echorev-0.0.8/PKG-INFO +9 -0
- echorev-0.0.8/README.md +28 -0
- echorev-0.0.8/echorev/__init__.py +251 -0
- echorev-0.0.8/echorev/get.png +0 -0
- echorev-0.0.8/echorev/getB.py +60 -0
- echorev-0.0.8/echorev/github.png +0 -0
- echorev-0.0.8/echorev/icon.png +0 -0
- echorev-0.0.8/echorev/quit.png +0 -0
- echorev-0.0.8/echorev/setup.py +33 -0
- echorev-0.0.8/echorev/test.py +255 -0
- echorev-0.0.8/echorev/tmp.py +58 -0
- echorev-0.0.8/echorev/update.png +0 -0
- echorev-0.0.8/echorev.egg-info/PKG-INFO +9 -0
- echorev-0.0.8/echorev.egg-info/SOURCES.txt +18 -0
- echorev-0.0.8/echorev.egg-info/dependency_links.txt +1 -0
- echorev-0.0.8/echorev.egg-info/requires.txt +1 -0
- echorev-0.0.8/echorev.egg-info/top_level.txt +1 -0
- echorev-0.0.8/setup.cfg +4 -0
- echorev-0.0.8/setup.py +33 -0
echorev-0.0.8/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# EchoRev
|
|
2
|
+
|
|
3
|
+
a GUI tool to help you reverse your input text.
|
|
4
|
+
|
|
5
|
+
这个小工具是让你可以正常从左往右输入,然后文字变成从右往左的。就是为了玩。
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
## Installation and Usage
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
```Bash
|
|
13
|
+
pip install requests
|
|
14
|
+
pip install pyqt5.sip
|
|
15
|
+
pip install pyqt5
|
|
16
|
+
pip install echorev
|
|
17
|
+
python -c "import echorev;echorev.main()"
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
OR adding `--user` to avoid the `EnvironmentError`
|
|
21
|
+
|
|
22
|
+
```Bash
|
|
23
|
+
pip install requests --user
|
|
24
|
+
pip install pyqt5.sip --user
|
|
25
|
+
pip install pyqt5 --user
|
|
26
|
+
pip install echorev --user
|
|
27
|
+
python -c "import echorev;echorev.main()"
|
|
28
|
+
```
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
#!/usr/bin/python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
|
|
4
|
+
version = '0.0.8'
|
|
5
|
+
date = '2024-10-17'
|
|
6
|
+
|
|
7
|
+
dpi = 128
|
|
8
|
+
# coding:utf-8
|
|
9
|
+
|
|
10
|
+
from PySide6.QtWidgets import QMainWindow, QWidget, QTextEdit, QMessageBox, QApplication, QHBoxLayout, QVBoxLayout, QStatusBar, QMenu, QMenuBar, QLabel, QSlider
|
|
11
|
+
from PySide6.QtGui import QPixmap, QIcon, QAction
|
|
12
|
+
from PySide6.QtCore import Qt, QTranslator
|
|
13
|
+
import sys, os, re, webbrowser, requests
|
|
14
|
+
|
|
15
|
+
LocationOfMySelf = os.path.dirname(__file__)
|
|
16
|
+
|
|
17
|
+
class GrowingTextEdit(QTextEdit):
|
|
18
|
+
|
|
19
|
+
def __init__(self, *args, **kwargs):
|
|
20
|
+
super(GrowingTextEdit, self).__init__(*args, **kwargs)
|
|
21
|
+
self.document().contentsChanged.connect(self.sizeChange)
|
|
22
|
+
|
|
23
|
+
self.heightMin = 0
|
|
24
|
+
self.heightMax = 8
|
|
25
|
+
|
|
26
|
+
def sizeChange(self):
|
|
27
|
+
docHeight = self.document().size().height()
|
|
28
|
+
if self.heightMin <= docHeight <= self.heightMax:
|
|
29
|
+
self.setMinimumHeight(docHeight)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class echorev(QMainWindow):
|
|
33
|
+
|
|
34
|
+
targetversion = '0'
|
|
35
|
+
def __init__(self):
|
|
36
|
+
|
|
37
|
+
super(echorev, self).__init__()
|
|
38
|
+
self.setObjectName('MainWindow')
|
|
39
|
+
self.resize(800, 600)
|
|
40
|
+
|
|
41
|
+
self.setWindowTitle('EchoRev')
|
|
42
|
+
self.setWindowIcon(QIcon(LocationOfMySelf + '/icon.png'))
|
|
43
|
+
self.setAcceptDrops(True)
|
|
44
|
+
self.main_widget = QWidget(self)
|
|
45
|
+
|
|
46
|
+
self.main_frame = QWidget()
|
|
47
|
+
self.textbox_input = GrowingTextEdit(self)
|
|
48
|
+
self.textbox_input.textChanged.connect(self.Magic)
|
|
49
|
+
self.textbox_output = GrowingTextEdit(self)
|
|
50
|
+
|
|
51
|
+
self.slider_label = QLabel('Horizontal Reverse')
|
|
52
|
+
self.slider = QSlider(Qt.Horizontal)
|
|
53
|
+
self.slider.setRange(0, 2)
|
|
54
|
+
self.slider.setValue(0)
|
|
55
|
+
self.slider.setTracking(True)
|
|
56
|
+
self.slider.setTickPosition(QSlider.TicksBothSides)
|
|
57
|
+
self.slider.valueChanged.connect(self.Magic) # int
|
|
58
|
+
|
|
59
|
+
self.hbox = QHBoxLayout()
|
|
60
|
+
self.vbox = QVBoxLayout()
|
|
61
|
+
self.hbox.addWidget(self.slider_label)
|
|
62
|
+
self.hbox.addWidget(self.slider)
|
|
63
|
+
self.vbox.addWidget(self.textbox_input)
|
|
64
|
+
self.vbox.addWidget(self.textbox_output)
|
|
65
|
+
|
|
66
|
+
self.vbox.addLayout(self.hbox)
|
|
67
|
+
|
|
68
|
+
self.main_widget.setLayout(self.vbox)
|
|
69
|
+
self.setCentralWidget(self.main_widget)
|
|
70
|
+
|
|
71
|
+
self.actionWeb = QAction(QIcon(LocationOfMySelf + '/github.png'), u'GitHub', self)
|
|
72
|
+
self.actionWeb.setObjectName('actionWeb')
|
|
73
|
+
|
|
74
|
+
self.actionVersionCheck = QAction(QIcon(LocationOfMySelf + '/update.png'), u'Version', self)
|
|
75
|
+
self.actionVersionCheck.setObjectName('actionVersionCheck')
|
|
76
|
+
|
|
77
|
+
self.actionQuit = QAction(QIcon(LocationOfMySelf + '/quit.png'), u'Quit', self)
|
|
78
|
+
self.actionQuit.setObjectName('actionQuit')
|
|
79
|
+
self.actionQuit.setShortcut('Ctrl+Q')
|
|
80
|
+
|
|
81
|
+
self.actionWeb.triggered.connect(self.goGitHub)
|
|
82
|
+
self.actionVersionCheck.triggered.connect(self.checkVersion)
|
|
83
|
+
self.actionQuit.triggered.connect(QApplication.quit)
|
|
84
|
+
|
|
85
|
+
self.menubar = self.menuBar()
|
|
86
|
+
self.menuHelp = self.menubar.addMenu('&Help')
|
|
87
|
+
|
|
88
|
+
self.menuHelp.addAction(self.actionWeb)
|
|
89
|
+
self.menuHelp.addAction(self.actionVersionCheck)
|
|
90
|
+
self.menuHelp.addAction(self.actionQuit)
|
|
91
|
+
self.statusbar = QStatusBar(self)
|
|
92
|
+
self.statusbar.setObjectName('statusbar')
|
|
93
|
+
self.statusbar.showMessage('The version is ' + version + '. Released at ' + date)
|
|
94
|
+
self.setStatusBar(self.statusbar)
|
|
95
|
+
|
|
96
|
+
w = self.width()
|
|
97
|
+
h = self.height()
|
|
98
|
+
self.slider.setFixedWidth(w / 10)
|
|
99
|
+
|
|
100
|
+
self.show()
|
|
101
|
+
|
|
102
|
+
def is_Chinese(self, word):
|
|
103
|
+
for ch in word:
|
|
104
|
+
if '\u4e00' <= ch <= '\u9fff':
|
|
105
|
+
return True
|
|
106
|
+
return False
|
|
107
|
+
|
|
108
|
+
def goGitHub(self):
|
|
109
|
+
webbrowser.open('https://github.com/cycleuser/EchoRev')
|
|
110
|
+
self.statusbar.showMessage('The version is ' + version + '. Released at ' + date)
|
|
111
|
+
|
|
112
|
+
def checkVersion(self):
|
|
113
|
+
self.statusbar.showMessage('The version is ' + version + '. Released at ' + date)
|
|
114
|
+
# reply = QMessageBox.information(self, 'Version', self.talk)
|
|
115
|
+
|
|
116
|
+
url = 'https://raw.githubusercontent.com/cycleuser/EchoRev/master/echorev/__init__.py'
|
|
117
|
+
|
|
118
|
+
r = 0
|
|
119
|
+
try:
|
|
120
|
+
r = requests.get(url, allow_redirects=True)
|
|
121
|
+
r.raise_for_status()
|
|
122
|
+
NewVersion = 'self.target' + r.text.splitlines()[0]
|
|
123
|
+
|
|
124
|
+
except requests.exceptions.ConnectionError as err:
|
|
125
|
+
# print(err)
|
|
126
|
+
r = 0
|
|
127
|
+
buttonReply = QMessageBox.information(self, u'NetWork Error', 'You are using EchoRev ' + version + '\n' + 'Net work unavailable.')
|
|
128
|
+
NewVersion = "targetversion = '0'"
|
|
129
|
+
|
|
130
|
+
except requests.exceptions.HTTPError as err:
|
|
131
|
+
# print(err)
|
|
132
|
+
r = 0
|
|
133
|
+
buttonReply = QMessageBox.information(self, u'NetWork Error', 'You are using EchoRev ' + version + '\n' + 'Net work unavailable.')
|
|
134
|
+
NewVersion = "targetversion = '0'"
|
|
135
|
+
|
|
136
|
+
exec(NewVersion)
|
|
137
|
+
# print('web is', self.targetversion)
|
|
138
|
+
# print(NewVersion)
|
|
139
|
+
|
|
140
|
+
self.talk = 'Version Online is ' + self.targetversion + '\n' + 'You are using EchoRev ' + version + '\n' + 'released on ' + date + '\n'
|
|
141
|
+
|
|
142
|
+
if r != 0:
|
|
143
|
+
|
|
144
|
+
# print('now is', version)
|
|
145
|
+
if (version < self.targetversion):
|
|
146
|
+
|
|
147
|
+
buttonReply = QMessageBox.question(self, u'Version',
|
|
148
|
+
self.talk + 'New version available.\n Download and update?',
|
|
149
|
+
QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
|
|
150
|
+
if buttonReply == QMessageBox.Yes:
|
|
151
|
+
# print('Yes clicked.')
|
|
152
|
+
# qApp.quit
|
|
153
|
+
# pip.main(['install', 'geopytool', '--upgrade --no-cache-dir'])
|
|
154
|
+
|
|
155
|
+
# self.UpDate
|
|
156
|
+
|
|
157
|
+
webbrowser.open('https://github.com/cycleuser/EchoRev')
|
|
158
|
+
else:
|
|
159
|
+
pass
|
|
160
|
+
# print('No clicked.')
|
|
161
|
+
else:
|
|
162
|
+
buttonReply = QMessageBox.information(self, u'Version',
|
|
163
|
+
self.talk + 'This is the latest version.')
|
|
164
|
+
|
|
165
|
+
def Magic(self):
|
|
166
|
+
result = ''
|
|
167
|
+
|
|
168
|
+
slider_value = int(self.slider.value())
|
|
169
|
+
|
|
170
|
+
if slider_value == 0:
|
|
171
|
+
self.slider_label.setText('Horizontal Reverse')
|
|
172
|
+
elif slider_value == 1:
|
|
173
|
+
self.slider_label.setText('Vertical Reverse')
|
|
174
|
+
else:
|
|
175
|
+
self.slider_label.setText('Traditional Chinese')
|
|
176
|
+
|
|
177
|
+
if (self.textbox_input.toPlainText() != ''):
|
|
178
|
+
str = (self.textbox_input.toPlainText())
|
|
179
|
+
# print(str)
|
|
180
|
+
str_list = list(str)
|
|
181
|
+
# print(str_list)
|
|
182
|
+
|
|
183
|
+
raw_list = str.split('\n')
|
|
184
|
+
# print(raw_list)
|
|
185
|
+
rev_list = []
|
|
186
|
+
out_list = []
|
|
187
|
+
|
|
188
|
+
if slider_value == 0:
|
|
189
|
+
for i in raw_list:
|
|
190
|
+
rev_list.append(i[::-1])
|
|
191
|
+
# print(rev_list)
|
|
192
|
+
pass
|
|
193
|
+
else:
|
|
194
|
+
max_lenth = 0
|
|
195
|
+
for i in raw_list:
|
|
196
|
+
if len(i) > max_lenth:
|
|
197
|
+
max_lenth = len(i)
|
|
198
|
+
|
|
199
|
+
for i in range(max_lenth):
|
|
200
|
+
tmp_str = ''
|
|
201
|
+
for j in raw_list:
|
|
202
|
+
try:
|
|
203
|
+
tmp_str = tmp_str + ''.join(j[i])
|
|
204
|
+
|
|
205
|
+
except(IndexError):
|
|
206
|
+
if self.is_Chinese(raw_list):
|
|
207
|
+
tmp_str = tmp_str + ''.join('\u3000')
|
|
208
|
+
else:
|
|
209
|
+
tmp_str = tmp_str + ''.join('\u0020')
|
|
210
|
+
|
|
211
|
+
print(tmp_str)
|
|
212
|
+
|
|
213
|
+
print(tmp_str)
|
|
214
|
+
if slider_value == 1:
|
|
215
|
+
pass
|
|
216
|
+
out_list.append(''.join(tmp_str))
|
|
217
|
+
elif slider_value == 2:
|
|
218
|
+
out_list.append(''.join(tmp_str)[::-1])
|
|
219
|
+
else:
|
|
220
|
+
pass
|
|
221
|
+
|
|
222
|
+
print('raw is', raw_list)
|
|
223
|
+
print('\n out is', out_list)
|
|
224
|
+
|
|
225
|
+
rev_list = out_list
|
|
226
|
+
|
|
227
|
+
for k in rev_list:
|
|
228
|
+
result = result + ''.join(k) + '\n'
|
|
229
|
+
|
|
230
|
+
# result= ''.join(rev_list)
|
|
231
|
+
# print(result)
|
|
232
|
+
|
|
233
|
+
self.textbox_output.setText(result)
|
|
234
|
+
self.statusbar.showMessage('The version is ' + version + '. Released at ' + date)
|
|
235
|
+
self.show()
|
|
236
|
+
|
|
237
|
+
def main():
|
|
238
|
+
import sys
|
|
239
|
+
|
|
240
|
+
app = QApplication(sys.argv)
|
|
241
|
+
trans = QTranslator()
|
|
242
|
+
# trans.load('cn') # 没有后缀.qm
|
|
243
|
+
app.installTranslator(trans)
|
|
244
|
+
mainWin = echorev()
|
|
245
|
+
# mainWin.retranslateUi()
|
|
246
|
+
mainWin.show()
|
|
247
|
+
sys.exit(app.exec())
|
|
248
|
+
|
|
249
|
+
if __name__ == '__main__':
|
|
250
|
+
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
|
|
251
|
+
sys.exit(main())
|
|
Binary file
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# 下载 geckodriver 后加入到PATH路径下
|
|
2
|
+
# pip install selenium
|
|
3
|
+
|
|
4
|
+
from selenium import webdriver # 从selenium导入webdriver
|
|
5
|
+
from selenium.webdriver.firefox.options import Options
|
|
6
|
+
f = open("./result.txt", "w+") # 这就是结果要存储的文件,在当前目录
|
|
7
|
+
origin_url = 'https://space.bilibili.com/486009552/video' # 这个 url 就是你要获取链接UP主的B站页面地址
|
|
8
|
+
tail_url = 15 # 这个 url 就是你要获取链接UP主的B站页面的页数
|
|
9
|
+
middle_url = '?tid=0&page='
|
|
10
|
+
url_list = []
|
|
11
|
+
for i in range(tail_url):
|
|
12
|
+
url_list.append(origin_url+middle_url+str(i+1))
|
|
13
|
+
|
|
14
|
+
html = ''
|
|
15
|
+
for url in url_list:
|
|
16
|
+
options = Options() # 浏览器选项
|
|
17
|
+
options.add_argument("--headless")
|
|
18
|
+
browser = webdriver.Firefox(options= options)
|
|
19
|
+
browser.get(url) # 获取页面
|
|
20
|
+
html= html + browser.page_source
|
|
21
|
+
browser.close()
|
|
22
|
+
|
|
23
|
+
html=html.replace('href','\n')
|
|
24
|
+
html=html.replace('target','\n')
|
|
25
|
+
html=html.replace('''><''','')
|
|
26
|
+
html=html.replace('''=''','')
|
|
27
|
+
html=html.replace('''_''','')
|
|
28
|
+
html=html.replace('''blank''','')
|
|
29
|
+
html=html.replace('''title''','')
|
|
30
|
+
html=html.replace('''meta''','')
|
|
31
|
+
html=html.replace('''play''','')
|
|
32
|
+
html=html.replace('''class''','')
|
|
33
|
+
html=html.replace('''icon''','')
|
|
34
|
+
html=html.replace('''span''','')
|
|
35
|
+
html=html.replace('''></i>''','')
|
|
36
|
+
html=html.replace('''><i''','')
|
|
37
|
+
html=html.replace('''<''','')
|
|
38
|
+
html=html.replace('''>''','')
|
|
39
|
+
html_content = html.splitlines()
|
|
40
|
+
video_list = []
|
|
41
|
+
for i in html_content:
|
|
42
|
+
if('''www.bilibili.com/video/BV''' in i):
|
|
43
|
+
i=i.replace('"','\n')
|
|
44
|
+
i=i.replace('''//''','''https://''')
|
|
45
|
+
print(len(i))
|
|
46
|
+
video_list.append(i)
|
|
47
|
+
video_str = ''.join(video_list)
|
|
48
|
+
video_str = ''.join([s for s in video_str.splitlines(True) if s.strip()])
|
|
49
|
+
tmp_list = video_str.splitlines()
|
|
50
|
+
print(len(tmp_list))
|
|
51
|
+
new_list = []
|
|
52
|
+
for i in tmp_list:
|
|
53
|
+
if('''www.bilibili.com/video/BV''' in i):
|
|
54
|
+
print(len(i))
|
|
55
|
+
if i not in new_list:
|
|
56
|
+
new_list.append(i)
|
|
57
|
+
f.write(i+"\n")
|
|
58
|
+
result= ''.join(new_list)
|
|
59
|
+
print(result)
|
|
60
|
+
f.close()
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
#coding:utf-8
|
|
3
|
+
import os
|
|
4
|
+
from distutils.core import setup
|
|
5
|
+
from echorev import *
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
here = os.path.abspath(os.path.dirname(__file__))
|
|
9
|
+
|
|
10
|
+
try:
|
|
11
|
+
README = open(os.path.join(here, 'README.md')).read()
|
|
12
|
+
except:
|
|
13
|
+
README = 'https://github.com/cycleuser/EchoRev/blob/master/README.md'
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
setup(name='echorev',
|
|
17
|
+
version=version,
|
|
18
|
+
description='a GUI tool to help you reverse your input text',
|
|
19
|
+
longdescription=README,
|
|
20
|
+
author='cycleuser',
|
|
21
|
+
author_email='cycleuser@cycleuser.org',
|
|
22
|
+
url='https://github.com/cycleuser/EchoRev',
|
|
23
|
+
packages=['echorev'],
|
|
24
|
+
package_data={
|
|
25
|
+
'echorev': ['*.py','*.png','*.qm','*.ttf','*.ini','*.md'],
|
|
26
|
+
},
|
|
27
|
+
include_package_data=True,
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
install_requires=[
|
|
31
|
+
'PySide6',
|
|
32
|
+
],
|
|
33
|
+
)
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
# !/usr/bin/python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
version = '0.0.8'
|
|
6
|
+
date = '2022-03-30'
|
|
7
|
+
|
|
8
|
+
dpi = 128
|
|
9
|
+
# coding:utf-8
|
|
10
|
+
from PyQt5.QtWidgets import QWidget, QToolTip,QPushButton, QMainWindow, QWidget, QTextEdit, QMessageBox, QApplication, QHBoxLayout, QVBoxLayout, QStatusBar, QMenu, QMenuBar, QAction, qApp, QLabel ,QSlider
|
|
11
|
+
from PyQt5.QtGui import QPixmap, QIcon
|
|
12
|
+
from PyQt5.QtCore import Qt, QTranslator
|
|
13
|
+
import time, sys, os, re, webbrowser, requests, urllib, bs4, csv
|
|
14
|
+
from bs4 import BeautifulSoup
|
|
15
|
+
import urllib.request
|
|
16
|
+
import http.cookiejar
|
|
17
|
+
from selenium import webdriver # 从selenium导入webdriver
|
|
18
|
+
from selenium.webdriver.firefox.options import Options
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
LocationOfMySelf=os.path.dirname(__file__)
|
|
22
|
+
|
|
23
|
+
class GrowingTextEdit(QTextEdit):
|
|
24
|
+
|
|
25
|
+
def __init__(self, *args, **kwargs):
|
|
26
|
+
super(GrowingTextEdit, self).__init__(*args, **kwargs)
|
|
27
|
+
self.document().contentsChanged.connect(self.sizeChange)
|
|
28
|
+
|
|
29
|
+
self.heightMin = 0
|
|
30
|
+
self.heightMax = 8
|
|
31
|
+
|
|
32
|
+
def sizeChange(self):
|
|
33
|
+
docHeight = self.document().size().height()
|
|
34
|
+
if self.heightMin <= docHeight <= self.heightMax:
|
|
35
|
+
self.setMinimumHeight(docHeight)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class echograb(QMainWindow):
|
|
39
|
+
linkLists=[]
|
|
40
|
+
targetversion = '0'
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def __init__(self):
|
|
44
|
+
super(echograb, self).__init__()
|
|
45
|
+
self.setObjectName('MainWindow')
|
|
46
|
+
self.resize(800, 600)
|
|
47
|
+
self.setWindowTitle('echograb')
|
|
48
|
+
self.setWindowIcon(QIcon(LocationOfMySelf+'/icon.png'))
|
|
49
|
+
self.setAcceptDrops(True)
|
|
50
|
+
self.main_widget = QWidget(self)
|
|
51
|
+
|
|
52
|
+
self.main_frame = QWidget()
|
|
53
|
+
self.textbox_input = GrowingTextEdit(self)
|
|
54
|
+
self.textbox_input.textChanged.connect(self.Magic)
|
|
55
|
+
|
|
56
|
+
self.get_button = QPushButton('&GetLinks')
|
|
57
|
+
self.get_button .clicked.connect(self.getLinks)
|
|
58
|
+
|
|
59
|
+
self.textbox_output = GrowingTextEdit(self)
|
|
60
|
+
|
|
61
|
+
self.hbox = QHBoxLayout()
|
|
62
|
+
self.vbox = QVBoxLayout()
|
|
63
|
+
self.vbox.addWidget(self.textbox_input)
|
|
64
|
+
self.vbox.addWidget(self.get_button)
|
|
65
|
+
self.vbox.addWidget(self.textbox_output)
|
|
66
|
+
|
|
67
|
+
self.vbox.addLayout(self.hbox)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
self.main_widget.setLayout(self.vbox)
|
|
71
|
+
self.setCentralWidget(self.main_widget)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
self.actionGetLinks = QAction(QIcon(LocationOfMySelf+'/get.png'), u'GitHub',self)
|
|
75
|
+
self.actionGetLinks.setObjectName('actionGetLinks')
|
|
76
|
+
self.actionGetLinks.triggered.connect(self.getLinks)
|
|
77
|
+
|
|
78
|
+
self.actionWeb = QAction(QIcon(LocationOfMySelf+'/github.png'), u'GitHub',self)
|
|
79
|
+
self.actionWeb.setObjectName('actionWeb')
|
|
80
|
+
self.actionWeb.triggered.connect(self.goGitHub)
|
|
81
|
+
|
|
82
|
+
self.actionVersionCheck = QAction(QIcon(LocationOfMySelf+'/update.png'), u'Version',self)
|
|
83
|
+
self.actionVersionCheck.setObjectName('actionVersionCheck')
|
|
84
|
+
self.actionVersionCheck.triggered.connect(self.getVersion)
|
|
85
|
+
|
|
86
|
+
self.actionQuit = QAction(QIcon(LocationOfMySelf+'/quit.png'), u'Quit',self)
|
|
87
|
+
self.actionQuit.setObjectName('actionQuit')
|
|
88
|
+
self.actionQuit.setShortcut('Ctrl+Q')
|
|
89
|
+
self.actionQuit.triggered.connect(qApp.quit)
|
|
90
|
+
|
|
91
|
+
self.menubar = self.menuBar()
|
|
92
|
+
self.menubar.addAction(self.actionGetLinks)
|
|
93
|
+
self.menubar.addAction(self.actionWeb)
|
|
94
|
+
self.menubar.addAction(self.actionVersionCheck)
|
|
95
|
+
self.menubar.addAction(self.actionQuit)
|
|
96
|
+
self.statusbar = QStatusBar(self)
|
|
97
|
+
self.statusbar.setObjectName('statusbar')
|
|
98
|
+
self.statusbar.showMessage('The version is '+version+ '. Released at '+date)
|
|
99
|
+
self.setStatusBar(self.statusbar)
|
|
100
|
+
|
|
101
|
+
w=self.width()
|
|
102
|
+
h=self.height()
|
|
103
|
+
self.show()
|
|
104
|
+
|
|
105
|
+
def getLinks(self,word):
|
|
106
|
+
# url = 'https://space.bilibili.com/872462/video'
|
|
107
|
+
url = self.textbox_input.toPlainText()
|
|
108
|
+
print(url)
|
|
109
|
+
options = Options()
|
|
110
|
+
options.add_argument("--headless")
|
|
111
|
+
browser = webdriver.Firefox(options= options)
|
|
112
|
+
browser.get(url) # 获取页面
|
|
113
|
+
# self.statusbar.setText('Sleep for 1 second')
|
|
114
|
+
html = browser.page_source
|
|
115
|
+
browser.close()
|
|
116
|
+
html=html.replace('href','\n')
|
|
117
|
+
html=html.replace('target','\n')
|
|
118
|
+
html=html.replace('''><''','')
|
|
119
|
+
html=html.replace('''=''','')
|
|
120
|
+
html=html.replace('''_''','')
|
|
121
|
+
html=html.replace('''blank''','')
|
|
122
|
+
html=html.replace('''title''','')
|
|
123
|
+
html=html.replace('''meta''','')
|
|
124
|
+
html=html.replace('''play''','')
|
|
125
|
+
html=html.replace('''class''','')
|
|
126
|
+
html=html.replace('''icon''','')
|
|
127
|
+
html=html.replace('''span''','')
|
|
128
|
+
html=html.replace('''></i>''','')
|
|
129
|
+
html=html.replace('''><i''','')
|
|
130
|
+
html=html.replace('''<''','')
|
|
131
|
+
html=html.replace('''>''','')
|
|
132
|
+
|
|
133
|
+
html_content = html.splitlines()
|
|
134
|
+
video_list = []
|
|
135
|
+
f = open("./result.txt", "w+")
|
|
136
|
+
for i in html_content:
|
|
137
|
+
if('''www.bilibili.com/video/BV''' in i):
|
|
138
|
+
i=i.replace('"','\n')
|
|
139
|
+
i=i.replace('''//''','''https://''')
|
|
140
|
+
print(len(i))
|
|
141
|
+
video_list.append(i)
|
|
142
|
+
video_str = ''.join(video_list)
|
|
143
|
+
video_str = ''.join([s for s in video_str.splitlines(True) if s.strip()])
|
|
144
|
+
tmp_list = video_str.splitlines()
|
|
145
|
+
print(len(tmp_list))
|
|
146
|
+
new_list = []
|
|
147
|
+
for i in tmp_list:
|
|
148
|
+
if('''www.bilibili.com/video/BV''' in i):
|
|
149
|
+
print(len(i))
|
|
150
|
+
if i not in new_list:
|
|
151
|
+
new_list.append(i)
|
|
152
|
+
f.write(i+"\n")
|
|
153
|
+
result= ''.join(new_list)
|
|
154
|
+
print(result)
|
|
155
|
+
f.close()
|
|
156
|
+
# self.statusbar.setText('Done')
|
|
157
|
+
# self.textbox_output.setText(result)
|
|
158
|
+
|
|
159
|
+
def goGitHub(self):
|
|
160
|
+
webbrowser.open('https://github.com/cycleuser/')
|
|
161
|
+
self.statusbar.showMessage('The version is ' + version + '. Released at ' + date)
|
|
162
|
+
pass
|
|
163
|
+
|
|
164
|
+
def getVersion(self):
|
|
165
|
+
self.statusbar.showMessage('The version is ' + version + '. Released at ' + date)
|
|
166
|
+
# reply = QMessageBox.information(self, 'Version', self.talk)
|
|
167
|
+
|
|
168
|
+
url = 'https://raw.githubusercontent.com/cycleuser/EchoRev/master/echorev/test.py'
|
|
169
|
+
|
|
170
|
+
r= 0
|
|
171
|
+
try:
|
|
172
|
+
r = requests.get(url, allow_redirects=True)
|
|
173
|
+
r.raise_for_status()
|
|
174
|
+
NewVersion = 'self.target' + r.text.splitlines()[0]
|
|
175
|
+
|
|
176
|
+
except requests.exceptions.ConnectionError as err:
|
|
177
|
+
#print(err)
|
|
178
|
+
r=0
|
|
179
|
+
buttonReply = QMessageBox.information(self, u'NetWork Error', 'You are using echograb ' + version +'\n'+'Net work unavailable.')
|
|
180
|
+
NewVersion ="targetversion = '0'"
|
|
181
|
+
|
|
182
|
+
except requests.exceptions.HTTPError as err:
|
|
183
|
+
#print(err)
|
|
184
|
+
r=0
|
|
185
|
+
buttonReply = QMessageBox.information(self, u'NetWork Error', 'You are using echograb '+ version +'\n'+'Net work unavailable.')
|
|
186
|
+
NewVersion ="targetversion = '0'"
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
exec(NewVersion)
|
|
190
|
+
#print('web is', self.targetversion)
|
|
191
|
+
#print(NewVersion)
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
self.talk= 'Version Online is '+ self.targetversion +'\n'+'You are using echograb '+ version +'\n'+ 'released on '+ date + '\n'
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
if r != 0:
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
#print('now is',version)
|
|
202
|
+
if (version < self.targetversion):
|
|
203
|
+
|
|
204
|
+
buttonReply = QMessageBox.question(self, u'Version' ,
|
|
205
|
+
self.talk + 'New version available.\n Download and update?' ,
|
|
206
|
+
QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
|
|
207
|
+
if buttonReply == QMessageBox.Yes:
|
|
208
|
+
#print('Yes clicked.')
|
|
209
|
+
#qApp.quit
|
|
210
|
+
#pip.main(['install', 'geopytool', '--upgrade --no-cache-dir'])
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
#self.UpDate
|
|
214
|
+
|
|
215
|
+
webbrowser.open('https://github.com/cycleuser/echograb')
|
|
216
|
+
else:
|
|
217
|
+
pass
|
|
218
|
+
#print('No clicked.')
|
|
219
|
+
else:
|
|
220
|
+
buttonReply = QMessageBox.information(self, u'Version' ,
|
|
221
|
+
self.talk + 'This is the latest version.')
|
|
222
|
+
|
|
223
|
+
def Magic(self):
|
|
224
|
+
self.statusbar.showMessage('The version is ' + version + '. Released at ' + date)
|
|
225
|
+
result = ''
|
|
226
|
+
|
|
227
|
+
if (self.textbox_input.toPlainText() != ''):
|
|
228
|
+
str = (self.textbox_input.toPlainText())
|
|
229
|
+
self.linkLists = str.split('\n')
|
|
230
|
+
|
|
231
|
+
'''
|
|
232
|
+
if __name__ == '__main__':
|
|
233
|
+
app = QApplication(sys.argv)
|
|
234
|
+
ex = echograb()
|
|
235
|
+
sys.exit(app.exec_())
|
|
236
|
+
'''
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
def main():
|
|
240
|
+
import sys
|
|
241
|
+
|
|
242
|
+
app = QApplication(sys.argv)
|
|
243
|
+
trans = QTranslator()
|
|
244
|
+
# trans.load('cn') # 没有后缀.qm
|
|
245
|
+
app.installTranslator(trans)
|
|
246
|
+
mainWin = echograb()
|
|
247
|
+
#mainWin.retranslateUi()
|
|
248
|
+
mainWin.show()
|
|
249
|
+
sys.exit(app.exec_())
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
if __name__ == '__main__':
|
|
254
|
+
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
|
|
255
|
+
sys.exit(main())
|