Пример #1
0
 def test_ImportListTxt(self):
     DB = PixivDBManager(root_directory=".", target="test.db.sqlite")
     DB.createDatabase()
     members = PixivListItem.parseList("test.list.txt", root_directory)
     result = DB.importList(members)
     # self.assertEqual(result, 0)
     assert result == 0
Пример #2
0
 def test_ImportListTxt(self):
     DB = PixivDBManager(target="test.db.sqlite")
     DB.createDatabase()
     l = PixivListItem.parseList("test.list.txt", config.rootDirectory)
     result = DB.importList(l)
     # self.assertEqual(result, 0)
     assert result == 0
Пример #3
0
 def test_SelectAllMember(self):
     DB = PixivDBManager(root_directory=".", target="test.db.sqlite")
     DB.createDatabase()
     result = DB.selectAllMember()
     # self.assertEqual(len(result), LIST_SIZE)
     assert len(result) == LIST_SIZE
     for item in result:
         print(item.memberId, item.path)
Пример #4
0
 def testSelectAllMember(self):
     DB = PixivDBManager(target="test.db.sqlite")
     DB.createDatabase()
     l = PixivListItem.parseList("test.list.txt", config.rootDirectory)
     result = DB.selectAllMember()
     self.assertEqual(len(result), LIST_SIZE)
     for item in result:
         print(item.memberId, item.path)
Пример #5
0
 def testSelectAllMember(self):
     DB = PixivDBManager(target="test.db.sqlite")
     DB.createDatabase()
     l = PixivListItem.parseList("test.list.txt", config.rootDirectory)
     result = DB.selectAllMember()
     self.assertEqual(len(result), LIST_SIZE)
     for item in result:
         print item.memberId, item.path
Пример #6
0
 def test_SelectMembersByLastDownloadDate(self):
     DB = PixivDBManager(target="test.db.sqlite")
     DB.createDatabase()
     l = PixivListItem.parseList("test.list.txt", config.rootDirectory)
     result = DB.selectMembersByLastDownloadDate(7)
     # self.assertEqual(len(result), LIST_SIZE)
     assert len(result) == LIST_SIZE
     for item in result:
         print(item.memberId, item.path)
Пример #7
0
    def parseBookmark(page, root_directory, db_path):
        '''Parse favorite artist page'''
        from PixivDBManager import PixivDBManager
        bookmarks = list()
        db = PixivDBManager(root_directory=root_directory, target=db_path)
        __re_member = re.compile(r'member\.php\?id=(\d*)')
        result = page.find(attrs={'class': 'members'}).findAll('a')

        # filter duplicated member_id
        d = collections.OrderedDict()
        for r in result:
            member_id = __re_member.findall(r['href'])
            if len(member_id) > 0:
                d[member_id[0]] = member_id[0]
        result2 = list(d.keys())

        for r in result2:
            item = db.selectMemberByMemberId2(r)
            bookmarks.append(item)

        return bookmarks
Пример #8
0
    def parseBookmark(page, root_directory, db_path, locale='', is_json=False):
        '''Parse favorite artist page'''
        from PixivDBManager import PixivDBManager
        bookmarks = list()
        result2 = list()
        db = PixivDBManager(root_directory=root_directory, target=db_path)

        if is_json:
            parsed = json.loads(page)
            for member in parsed["body"]["users"]:
                if "isAdContainer" in member and member["isAdContainer"]:
                    continue
                result2.append(member["userId"])
        else:
            # old method
            parse_page = BeautifulSoup(page, features="html5lib")
            __re_member = re.compile(locale + r'/users/(\d*)')

            member_list = parse_page.find(attrs={'class': 'members'})
            result = member_list.findAll('a')

            # filter duplicated member_id
            d = collections.OrderedDict()
            for r in result:
                member_id = __re_member.findall(r['href'])
                if len(member_id) > 0:
                    d[member_id[0]] = member_id[0]
            result2 = list(d.keys())

            parse_page.decompose()
            del parse_page

        for r in result2:
            item = db.selectMemberByMemberId2(r)
            bookmarks.append(item)

        return bookmarks
Пример #9
0
 def testImportListTxt(self):
     DB = PixivDBManager(target="test.db.sqlite")
     DB.createDatabase()
     l = PixivListItem.parseList("test.list.txt", config.rootDirectory)
     result = DB.importList(l)
     self.assertEqual(result, 0)