Ejemplo n.º 1
0
    async def __get_video_list(self, url):
        """Get video's HASH id list

        Base on the url to fetch the response body and get the key data by pyquery


        Demo: https://v.qq.com/x/cover/p69wlzli02uqwms/d0023ka5gj7.html    

        Args:
            url: target video' url 
        """
        try:
            info(f"Url: {url}")
            response = await self.__async_session.get(url)
            self.__list_info, self.__cover_info, self.__video_info = Parser.get_details(
                response)
            self.__root_path = f'{self.__root_path}/{self.__cover_info["title"]}'
            info(f"Name: [{self.__root_path}]")
            initPath(self.__root_path)
            create_json(self.__list_info, f"{self.__root_path}/list_info.json")
            create_json(self.__cover_info,
                        f"{self.__root_path}/cover_info.json")
            create_json(self.__video_info,
                        f"{self.__root_path}/video_info.json")
        except Exception as e:
            raise e
Ejemplo n.º 2
0
 def create_danmu_xlsx(self, title):
     xlsx_path = f"{self.__root_path}/xlsx"
     initPath(xlsx_path)
     tmp_data = []
     data_length = len(self.__results.keys())
     tmp_data.append(title)
     for did, item in self.__results.items():
         tmp_data_bottom = []
         for tid, titem in item["datas"].items():
             tmp_data_bottom.append([titem[_] for _ in title])
         tmp_data.extend(tmp_data_bottom)
         if data_length > 2:
             create_xlsx(tmp_data_bottom, title,
                         f"{xlsx_path}/{item['number']}.xlsx")
     create_xlsx(tmp_data, title,
                 f"{self.__root_path}/{self.__res_xlsx_name}")
Ejemplo n.º 3
0
    def create_word_clouds(self):
        """
        demo: {"n0023msdsmb": {
                "number": 29,
                "targetid": "1871591968",
                "datas": {
                    "6258341153647188912": {
                        "commentid": "6258341153647188912",
                        "content": "我来了,我困了",
                        "upcount": 2,
                        "isfriend": 0,
                        "isop": 0,
                        "isself": 0,
                        "timepoint": 15,
                        "headurl": "http://q4.qlogo.cn/g?b=qq&k=QAyiafGCYJbfG8lRKTsVTFQ&s=40",
                        "opername": "沉默Deheart",
                        "bb_bcolor": "0x985850",
                        "bb_head": "http://i.gtimg.cn/qqlive/images/20160602/pic_luhan.png",
                        "bb_level": "http://i.gtimg.cn/qqlive/images/20170104/i1483523275_1.jpg",
                        "content_style": ""
                    }}}}
        """
        image_path = f"{self.__root_path}/imgs"
        word_cloud_path = f"{self.__root_path}/words"
        initPath(image_path)
        initPath(word_cloud_path)

        img_array = get_pic_array(self.__cover_info["vertical_pic_url"],
                                  f"{image_path}/vertical_pic.png")

        all_words = ""
        for indexHash, item in self.__results.items():
            words = " ".join(
                map(lambda data: data[1]["content"],
                    list(item["datas"].items())))
            all_words += words
            create_singel_word_cloud(words,
                                     f"{word_cloud_path}/{item['number']}",
                                     img_array)
        create_singel_word_cloud(all_words,
                                 f"{self.__root_path}/{self.__res_png_name}",
                                 img_array)