Ejemplo n.º 1
0
    def spls(self):
        from NXSpider.bin.models import playlist_mo

        if self.param_check(['playlist'],
                            sys._getframe().f_code.co_name) is False:
            return

        download_type = self.parse_download()
        playlists = self.app.pargs.playlist.split(',')  # type: list

        for pid in playlists:
            playlist_detail = api.get_playlist_detail(pid)
            if playlist_detail:
                log.print_info(u"<{}> author:{}".format(
                    playlist_detail['name'],
                    playlist_detail['creator']['nickname'],
                ))
                playlist_mo.parse_model(
                    playlist_detail,
                    download_type=download_type,
                    file_check=Config().get_file_check(),
                    shortcuts_stack=[] if Config().get_shortcut() else None)

        log.print_info("spider complete!~")
        pass
Ejemplo n.º 2
0
    def scls_pls(self):
        from NXSpider.bin.models import playlist_mo

        if self.param_check(['cls'], sys._getframe().f_code.co_name) is False:
            return

        download_type = self.parse_download()
        class_name = self.app.pargs.cls
        class_name = py2_decoding(class_name)

        if class_name != u"全部" and py2_encoding(
                class_name) not in api.ALL_CLASSES:
            log.print_err(
                "class name is wrong, pls check by run : nxspider sw-pl-classes"
            )
            return

        playlists = api.get_top_playlists(category=class_name,
                                          offset=self.app.pargs.offset or 0,
                                          limit=self.app.pargs.limit
                                          or 50)  # type: list

        for pl_obj in playlists:
            playlist_detail = api.get_playlist_detail(pl_obj['id'])
            if playlist_detail:
                log.print_info(u"<{}> author:{}".format(
                    playlist_detail['name'],
                    playlist_detail['creator']['nickname'],
                ))
                playlist_mo.parse_model(playlist_detail,
                                        download_type=download_type,
                                        file_check=Config().get_file_check())
        log.print_info("spider complete!~")
        pass
Ejemplo n.º 3
0
    def sur_pls(self):
        from NXSpider.bin.models import playlist_mo

        if self.param_check(['user'], sys._getframe().f_code.co_name) is False:
            return

        download_type = self.parse_download()
        user_id = self.app.pargs.user
        playlists = api.user_playlist(user_id,
                                      offset=self.app.pargs.offset or 0,
                                      limit=self.app.pargs.limit or 50)

        log.print_info("playlists bellow will be crawled")
        print_playlist(playlists)

        for pl_obj in playlists:
            playlist_detail = api.get_playlist_detail(pl_obj['id'])
            if playlist_detail:
                log.print_info(u"<{}> author:{}".format(
                    playlist_detail['name'],
                    playlist_detail['creator']['nickname'],
                ))
                playlist_mo.parse_model(
                    playlist_detail,
                    download_type=download_type,
                    file_check=Config().get_file_check(),
                    shortcuts_stack=[] if Config().get_shortcut() else None)
        log.print_info("spider complete!~")
        pass
Ejemplo n.º 4
0
    def sur_pls(self):
        from NXSpider.bin.models import playlist_mo

        if self.param_check(['user'], sys._getframe().f_code.co_name) is False:
            return

        download_type = self.parse_download()
        user_id = self.app.pargs.user
        playlists = api.user_playlist(user_id)

        from terminaltables import AsciiTable
        table = AsciiTable([["ID", "Name", "User", "PlayCount"]])
        table_data = [[
            str(item['id']),
            item['name'],
            item['creator']['nickname'],
            str(item['playCount']),
        ] for item in playlists]
        table.table_data.extend(table_data)
        log.print_info("playlists bellow will be crawled")
        print(table.table)

        for pl_obj in playlists:
            playlist_detail = api.get_playlist_detail(pl_obj['id'])
            if playlist_detail:
                log.print_info(u"<{}> author:{}".format(
                    playlist_detail['name'],
                    playlist_detail['creator']['nickname'],
                ))
                playlist_mo.parse_model(playlist_detail,
                                        download_type=download_type,
                                        file_check=Config().get_file_check())
        log.print_info("spider complete!~")
        pass
Ejemplo n.º 5
0
    def login_spls(self):
        if self.param_check(['lu', 'lp'],
                            sys._getframe().f_code.co_name) is False:
            return

        from NXSpider.bin.models import playlist_mo

        plaintext_pwd = self.app.pargs.lp or None
        if plaintext_pwd is None:
            import getpass
            plaintext_pwd = getpass.getpass("Please input your password:"******"none")))
            exit()

        user_id = res['account']['id']
        download_type = self.parse_download()
        playlists = api.user_playlist(user_id,
                                      offset=self.app.pargs.offset or 0,
                                      limit=self.app.pargs.limit or 1000)

        log.print_info("playlists bellow will be crawled")
        print_playlist(playlists)

        for pl_obj in playlists:
            playlist_detail = api.get_playlist_detail(pl_obj['id'])
            if playlist_detail:
                log.print_info(u"<{}> author:{}".format(
                    playlist_detail['name'],
                    playlist_detail['creator']['nickname'],
                ))
                playlist_mo.parse_model(
                    playlist_detail,
                    download_type=download_type,
                    file_check=Config().get_file_check(),
                    shortcuts_stack=[] if Config().get_shortcut() else None)
        log.print_info("spider complete!~")
        pass