MCPcopy Create free account
hub / github.com/PyQt5/PyQt / _makeItem

Method _makeItem

QFlowLayout/HotPlaylist.py:100–126  ·  view source on GitHub ↗
(self, lis)

Source from the content-addressed store, hash-verified

98 self._makeItem(lis)
99
100 def _makeItem(self, lis):
101 for li in lis:
102 a = li.find('.//div/a')
103 play_url = "https://music.163.com" + a.get("href") # 歌单播放地址
104 img = li.find(".//div/img")
105 cover_url = img.get("src") # 封面图片
106 playlist_title = a.get("title") # 歌单名
107 # 歌手
108 author_info = li.xpath(".//p[2]/a")[0]
109 playlist_author = "<span style=\"font-size: 12px;\"作者:{}</span>".format(
110 Actor.format(href="https://music.163.com" +
111 author_info.get("href"),
112 title=author_info.get("title")))
113 # 播放数
114 play_count = (li.xpath(".//div/div/span[2]/text()") or [""])[0]
115 path = "cache/{0}.jpg".format(
116 os.path.splitext(os.path.basename(cover_url).split('?')[0])[0])
117 cover_path = "Data/pic_v.png"
118 if os.path.isfile(path):
119 cover_path = path
120
121 # print(cover_path, playlist_title,
122 # playlist_author, play_count, play_url, cover_url, path)
123 iwidget = CoverItemWidget(self, manager=self._manager)
124 iwidget.init(cover_path, playlist_title, playlist_author,
125 play_count, play_url, cover_url, path)
126 self._layout.addWidget(iwidget)
127
128
129class Window(QScrollArea):

Callers 1

_parseHtmlMethod · 0.95

Calls 3

initMethod · 0.95
CoverItemWidgetClass · 0.90
addWidgetMethod · 0.80

Tested by

no test coverage detected