This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if 'le.com' in sourceUrl and not isYougetParsed: # ykdl解析乐视 | |
videoUrls = re.search(r"Real URLs:\s*(?P<videoUrls>\S*)", parseResult, re.IGNORECASE).group('videoUrls').split() # 搜寻链接,因为有了download-url:,所以必须从Real URLs:后面搜寻,一个本地地址是连续不断的,所以用\S没问题 | |
else: | |
videoUrls = re.findall(r'''\s*[\[']*(?P<videoUrls>https?://\S*)['\]]*''', parseResult) # 因为url是连续不断的,所以用\S没问题,因为是贪婪模式,并且后面的']可选,所以结果里会有'] | |
videoUrls = list(map(lambda videoUrl: videoUrl.rstrip("']"), videoUrls)) | |
# videoUrlsMatch | |
# print('videoUrls----------', videoUrlsMatch.group('videoUrls')) | |
if not all([baseNameMatch, videoUrls]): # 有空结果 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#I write the slot of QClipboard::dataChanged() as this to avoid the bug, | |
@pyqtSlot() | |
def detectClipboardUrl(self): | |
clipboardText = self.clipboard.text() | |
if getattr(self.clipboard, 'lastClipboardUrl', None) != clipboardText: | |
url = clipboardText | |
setattr(self.clipboard, 'lastClipboardUrl', url) | |
#会造成不能连续复制同样的url | |
self.on_autodownloadEnable_triggered() # 立即断开 Clipboard的信号联系,# 为了防止chrome造成signal call twice的bug |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#I write the slot of QClipboard::dataChanged() as this to avoid the bug, | |
@pyqtSlot() | |
def detectClipboardUrl(self): | |
clipboardText = self.clipboard.text() | |
if getattr(self.clipboard, 'lastClipboardUrl', None) != clipboardText: | |
url = clipboardText | |
setattr(self.clipboard, 'lastClipboardUrl', url) | |
QTimer.singleShot(400, lambda:setattr(self.clipboard, 'lastClipboardUrl', None))#the interval of successive call of this slot is less than 400ms, after 400ms this line would allow you copy the same Text again |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# print('(QProcess)---------------',self.findChildren(QProcess)) | |
arguments = ['-f', 'concat', '-safe', '-1', '-i', fp.name, '-y', '-c', 'copy', absoluteFileName] | |
# print(os.path.join(os.getcwd(), 'ffmpeg'), ' '.join(arguments)) | |
# self.process.finished.connect(self.mergeFinished(self.process)) | |
# process.destroyed.connect(self.onProcessDestroyed) | |
if self.process.state()==QProcess.NotRunning: | |
self.process.start(os.path.join(os.getcwd(), 'ffmpeg'), arguments) | |
else: | |
self.process.tasks.add(sourceUrl) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from PyQt4.QtGui import * | |
from PyQt4.QtCore import * | |
class MyFileSystemModel(QFileSystemModel): | |
def __init__(self, h_align=Qt.AlignLeft, v_align=Qt.AlignLeft, parent=None): | |
super().__init__(parent) | |
self.alignments = {Qt.Horizontal: h_align, Qt.Vertical: v_align} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Credits go to the Qt Centre forum. | |
# import logging | |
# import sys | |
# logging.basicConfig(filename='LYYDownloader.log') | |
# def uncaughtExceptionHandler(type_, value, traceback): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def baiduTranslate(self, queryText): | |
queryUrl = 'http://fanyi.baidu.com/v2transapi' | |
response = requests.post(queryUrl, data={'from': 'en', 'to': 'zh', 'query': queryText, 'transtype': 'realtime', 'simple_means_flag': 3,'sign':'498118.235959','token':'40a25d2a0d533f7cc897a454a0a86812'}) | |
repliedJson = response.json() | |
print(repliedJson) | |
dictResult = repliedJson["dict_result"] | |
if not dictResult: # 句子的时候字典没结果,teaching posts也没有结果 | |
print('baiduTranslate 翻译', queryText) # , repliedJson["trans_result"]["data"][0]["dst"] | |
return repliedJson["trans_result"]["data"][0]["dst"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// console.log('tabTitle----onClicked----',tab.title,hostname); | |
fileExt = tabId2DownloadInfo[tab.id][1]; //{tabId:[targetUrl,fileExt]} ------->fileExt | |
np = nameParser[hostname]; | |
fileName = (np ? np(tabTitle) : tabTitle) + fileExt; //必须在三元运算符外加括号才会成为一个值,不然直接return | |
// console.log('downloadInfo fileName ' ,fileName.replace(/[\\/:*?"<>|]/g, '_')); | |
tabId2DownloadInfo[tabId][1] = fileName.replace(/[\\/:*?"<>|~]/g, '_'); //{tabId:[targetUrl,fileName]} 替换网页标题里不能包含于文件名(以Windows的文件命名为准)中的非法字符\/:*?"<>| | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PySide2.QtCore import * | |
from PySide2.QtWidgets import * | |
from PySide2.QtNetwork import * | |
class Window(QMainWindow): | |
def __init__(self, parent=None, **kwargs): | |
super().__init__(parent, **kwargs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from PIL import ImageGrab | |
from PyQt5.QtCore import * | |
from PyQt5.QtGui import * | |
from PyQt5.QtWidgets import * | |
app = QApplication(sys.argv) | |
btn = QPushButton() | |
btn.clicked.connect(lambda: ImageGrab.grab(bbox=(0, 0, 900, 900))) |
OlderNewer