Skip to content

Instantly share code, notes, and snippets.

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]): # 有空结果
#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
#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
# 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)
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}
# Credits go to the Qt Centre forum.
# import logging
# import sys
# logging.basicConfig(filename='LYYDownloader.log')
# def uncaughtExceptionHandler(type_, value, traceback):
@redstoneleo
redstoneleo / invalid baiduTranslate
Created December 31, 2017 06:54
invalid baiduTranslate----
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"]
@redstoneleo
redstoneleo / MediaDownload
Created February 28, 2018 02:22
MediaDownload
// 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的文件命名为准)中的非法字符\/:*?"<>|
@redstoneleo
redstoneleo / gist:d18c575febd195034fec7bc3389fdb02
Created April 29, 2019 05:12
the expected behavior of QCompleter.UnfilteredPopupCompletion is so slow
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)
@redstoneleo
redstoneleo / PyQt5WithPIL.py
Created June 25, 2019 14:00
used to test Nuitka issues
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)))