Esempio n. 1
0
 def run(self):
     url = (
         f"https://api.bilibili.com/medialist/gateway/base/spaceDetail?media_id={self.media_id}&"
         "pn=1&ps=20&keyword=&order=mtime&type=0&tid=0&jsonp=jsonp")
     try:
         data = json.loads(urlopen(url).read())
         # load thumbnail image
         pixmap = QPixmap()
         pixmap.loadFromData(
             urlopen(str(data["data"]["info"]["cover"])).read())
         # emitting the response signal
         #
         self.worker_response.emit(
             WorkerRespnose(
                 pixmap,
                 data["data"]["info"]["title"],
                 data["data"]["info"]["upper"]["name"],
                 data["data"]["medias"],
                 data["data"]["info"]["media_count"],
                 data["data"]["info"]["ctime"],
             ))
     except Exception as e:
         print(e)
         # emitting the error signal
         self.worker_err_response.emit()
Esempio n. 2
0
 def icon_url_changed(self, url):
     dc = QApplication.instance().disk_cache.data(url)
     if dc is not None:
         with closing(dc):
             raw = dc.readAll()
             p = QPixmap()
             p.loadFromData(raw)
             if not p.isNull():
                 ic = QIcon()
                 ic.addPixmap(p)
                 self.set_data(DECORATION_ROLE, ic)
Esempio n. 3
0
 def icon(self):
     if self._icon is None:
         self._icon = QIcon()
         url = places.favicon_url(self.place_id)
         if url is not None:
             f = QApplication.instance().disk_cache.data(QUrl(url))
             if f is not None:
                 with closing(f):
                     raw = f.readAll()
                 p = QPixmap()
                 p.loadFromData(raw)
                 if not p.isNull():
                     self._icon.addPixmap(p)
     return self._icon
Esempio n. 4
0
 def run(self):
     try:
         yt = YouTube(self.url)
         # load thumbnail image
         pixmap = QPixmap()
         pixmap.loadFromData(urlopen(str(yt.thumbnail_url)).read())
         # emitting the response signal
         self.worker_response.emit((
             yt,
             pixmap,
             yt.title,
             yt.author,
             yt.length,
             yt.publish_date,
             # populate a list of progressive mp4 resolutions for the download options
             [f'{res.resolution} - {round(res.filesize/1.049e+6, 1)}MB' for res in yt.streams.filter(progressive='true', file_extension='mp4').order_by('resolution')]
         ))
     except:
         # emitting the error signal
         self.worker_err_response.emit()
Esempio n. 5
0
 def show_qr(self, qr: bytes):
     title_label = QLabel("请使用微信扫描小程序码完成登陆")
     title_label.setStyleSheet(
         "QLabel{color:#ffe3ed;border:none;background-color:transparent;border-radius:5px;}"
     )
     title_label.setAlignment(Qt.Alignment.AlignCenter)
     title_label.setFixedHeight(20)
     qr_label = QLabel()
     pixmap = QPixmap()
     pixmap.loadFromData(qr)
     qr_label.setPixmap(pixmap)
     qr_label.setStyleSheet(
         "QLabel{color:#ffe3ed;border:none;background-color:transparent;border-radius:5px;}"
     )
     layout_ = QVBoxLayout()
     layout_.addWidget(title_label, 1)
     layout_.addWidget(qr_label, 9)
     self.qr_dialog = QWidget(self)
     self.qr_dialog.setLayout(layout_)
     self.main_layout.addWidget(self.qr_dialog, 1, 1,
                                Qt.Alignment.AlignCenter)
     self.qr_dialog.show()