示例#1
0
 def analyze_browserecords(self):
     record = model_browser.Browserecord()
     pattern = re.compile('[\\x00-\\x08\\x0b-\\x0c\\x0e-\\x1f]')
     try:
         node = self.node.Parent.GetByPath('/database')
         self.db = SQLiteParser.Database.FromNode(node, canceller)
         if self.db is None:
             return
         ts = SQLiteParser.TableSignature('history')
         for rec in self.db.ReadTableRecords(ts, self.extractDeleted, True):
             canceller.ThrowIfCancellationRequested()
             record.id = rec['ID'].Value if 'ID' in rec else None
             record.name = rec['NAME'].Value if 'NAME' in rec and rec[
                 'NAME'].Value is not '' else None
             record.url = rec['URL'].Value if 'URL' in rec and rec[
                 'URL'].Value is not '' else None
             if not IsDBNull(rec['DATETIME'].Value):
                 record.datetime = self._timeHandler(
                     rec['DATETIME'].Value) if 'DATETIME' in rec else None
             record.deleted = rec.IsDeleted
             record.source = node.AbsolutePath
             self.mb.db_insert_table_browserecords(record)
         self.mb.db_commit()
     except Exception as e:
         traceback.print_exc()
         print(e)
示例#2
0
 def _save_to_br(_url_name, _date):
     browser_record = model_browser.Browserecord()
     browser_record.url = _url_name
     browser_record.datetime = _date
     browser_record.source = _mail.source
     browser_record.deleted = _mail.deleted
     self.model_browser.db_insert_table_browserecords(browser_record)
示例#3
0
    def parse_formurl(self, table_name):
        ''' FieldName	SQLType
            _id	        INTEGER
            url	        TEXT
        '''
        id_url_dict = {}
        for rec in self._read_table(table_name):
            try:
                if (self._is_duplicate(rec, '_id')
                        or not self._is_url(rec, 'url')):
                    continue
                id_url_dict[rec['_id'].Value] = rec['url'].Value

                browser_record = model_browser.Browserecord()
                if self._max_id:
                    browser_record.id = self._max_id
                    self._max_id += 1
                else:
                    browser_record.id = rec['_id'].Value
                browser_record.url = rec['url'].Value
                browser_record.source = self.cur_db_source
                browser_record.deleted = 1 if rec.IsDeleted else 0
                self.csm.db_insert_table_browserecords(browser_record)
            except:
                exc()
        self.csm.db_commit()
        return id_url_dict
示例#4
0
    def parse_Browserecord(self, table_name):
        ''' databases/browser2.db - history 浏览记录

            FieldName	SQLType	         	
            _id	            INTEGER
            title	        TEXT
            url	            TEXT
            created	        INTEGER   # lenovo: create_time
            date	        INTEGER
            visits	        INTEGER
            user_entered	INTEGER
        '''
        for rec in self._read_table(table_name):
            try:
                if (self._is_empty(rec, 'url', 'title')
                        or self._is_duplicate(rec, '_id')
                        or not self._is_url(rec, 'url')):
                    continue
                browser_record = model_browser.Browserecord()
                browser_record.id = rec['_id'].Value
                browser_record.name = rec['title'].Value
                browser_record.url = rec['url'].Value
                for data_field in ['created', 'create_time', 'date']:
                    if data_field in rec.Keys and rec[data_field].Value > 0:
                        browser_record.datetime = rec[data_field].Value
                        break
                browser_record.visit_count = rec[
                    'visits'].Value if rec['visits'].Value > 0 else 1
                browser_record.owneruser = self.cur_account_name
                browser_record.source = self.cur_db_source
                browser_record.deleted = 1 if rec.IsDeleted else 0
                self.csm.db_insert_table_browserecords(browser_record)
            except:
                exc()
        self.csm.db_commit()
示例#5
0
    def parse_Browserecord_SearchHistory(self, db_path, table_name):
        ''' databases/history - history 浏览记录

            FieldName	    SQLType	    	
            id	            INTEGER
            name	        TEXT
            url	            TEXT
            original_url    TEXT
            visited_time    INTEGER
            host	        TEXT
            visited_count	INTEGER
            state	        INTEGER
            media_type	    INTEGER
            url_hashcode	INTEGER
            from_type	    INTEGER
            source	        TEXT
            daoliu_type	    INTEGER
            article_id	    TEXT
            channel_id	    INTEGER
            icon_url	    TEXT
            temp_1	        TEXT
            temp_2	        TEXT
            temp_3	        TEXT
        '''
        if not self._read_db(db_path):
            return
        for rec in self._read_table(table_name):
            try:
                if (self._is_empty(rec, 'url', 'name') or
                    self._is_duplicate(rec, 'id') or
                        not self._is_url(rec, 'url')):
                    continue
                browser_record = model_browser.Browserecord()
                browser_record.id          = rec['id'].Value
                browser_record.name        = rec['name'].Value
                browser_record.url         = rec['url'].Value
                browser_record.datetime    = rec['visited_time'].Value
                browser_record.visit_count = rec['visited_count'].Value if rec['visited_count'].Value > 0 else 1
                browser_record.owneruser   = self.cur_account_name
                browser_record.source      = self.cur_db_source
                browser_record.deleted     = 1 if rec.IsDeleted else 0
                self.csm.db_insert_table_browserecords(browser_record)

                if browser_record.name.startswith('网页搜索_'):
                    search_history           = model_browser.SearchHistory()
                    search_history.id        = rec['id'].Value
                    search_history.name      = rec['name'].Value.replace('网页搜索_', '')
                    search_history.url       = rec['url'].Value
                    search_history.datetime  = rec['visited_time'].Value
                    search_history.owneruser = self.cur_account_name
                    search_history.source    = self.cur_db_source
                    search_history.deleted   = 1 if rec.IsDeleted else 0
                    self.csm.db_insert_table_searchhistory(search_history)
            except:
                exc()
        self.csm.db_commit()
示例#6
0
    def parse_Browserecord_SearchHistory(self, URLID_KEYWORD, table_name):
        ''' Default/History - urls

            FieldName	    SQLType     	        	
            id	            INTEGER
            url	            LONGVARCHAR
            title	            LONGVARCHAR
            visit_count	        INTEGER
            typed_count	        INTEGER
            last_visit_time	    INTEGER
            hidden	            INTEGER
        '''
        for rec in self._read_table(table_name):
            try:
                if (self._is_empty(rec, 'url', 'last_visit_time') or
                    self._is_duplicate(rec, 'id') or
                    not self._is_url(rec, 'url')):
                    continue
                browser_record = model_browser.Browserecord()
                browser_record.id          = rec['id'].Value
                browser_record.name        = rec['title'].Value
                browser_record.url         = rec['url'].Value
                browser_record.datetime    = self._convert_webkit_ts(rec['last_visit_time'].Value)
                browser_record.visit_count = rec['visit_count'].Value if rec['visit_count'].Value > 0 else 1
                browser_record.owneruser   = self.cur_account_name
                browser_record.source      = self.cur_db_source
                browser_record.deleted     = 1 if rec.IsDeleted else rec['hidden'].Value
                self.csm.db_insert_table_browserecords(browser_record)

                # 补充 keyword_search_terms 表中漏掉的搜索关键字
                if not URLID_KEYWORD.has_key(rec['id'].Value):
                    _search_item = self._search_item_from_browser_record(rec['title'].Value)
                else:
                    _search_item = ''

                if URLID_KEYWORD.has_key(rec['id'].Value) or _search_item:
                    search_history = model_browser.SearchHistory()
                    search_history.name = _search_item if _search_item else URLID_KEYWORD.get(rec['id'].Value, None)
                    search_history.id        = rec['id'].Value
                    search_history.url       = rec['url'].Value
                    search_history.datetime  = browser_record.datetime
                    search_history.owneruser = self.cur_account_name
                    search_history.source    = self.cur_db_source
                    search_history.deleted   = browser_record.deleted              
                    self.csm.db_insert_table_searchhistory(search_history)
            except:
                exc()
        self.csm.db_commit()
示例#7
0
 def _parse_browser_record(self, rec):
     try:
         browser_record = model_browser.Browserecord()
         browser_record.id = rec['_id'].Value
         browser_record.name = rec['title'].Value
         browser_record.url = rec['url'].Value
         for data_field in ['created', 'create_time', 'date']:
             if data_field in rec.Keys and rec[data_field].Value > 0:
                 browser_record.datetime = rec[data_field].Value
                 break
         browser_record.owneruser = self.cur_account_name
         browser_record.visit_count = rec[
             'visits'].Value if rec['visits'].Value > 0 else 1
         browser_record.source = self.cur_db_source
         browser_record.deleted = 1 if rec.IsDeleted else 0
         self.csm.db_insert_table_browserecords(browser_record)
     except:
         exc()
示例#8
0
    def parse_Browserecord(self, db_path, table_name):
        """ dbbrowser.db - history - 浏览记录

            RecNo FieldName	    SQLType	Size
            1	  create_time     INTEGER
            2	  date	          INTEGER
            3	  _id	          INTEGER
            4	  reserve	      TEXT
            5	  should_ask_icon INTEGER
            6	  title	          TEXT
            7	  url	          TEXT
            8	  visits	          INTEGER			    
        """
        if not self._read_db(db_path):
            return
        for rec in self._read_table(table_name):
            if canceller.IsCancellationRequested:
                return
            if self._is_empty(rec, 'url',
                              'create_time') or not self._is_url(rec, 'url'):
                continue
            if self._is_duplicate(rec, 'create_time'):
                continue
            browser_record = model_browser.Browserecord()
            browser_record.id = rec['_id'].Value
            browser_record.name = rec['title'].Value
            browser_record.url = rec['url'].Value
            browser_record.datetime = rec['date'].Value
            browser_record.visit_count = rec[
                'visits'].Value if rec['visits'].Value > 0 else 1
            browser_record.source = self.cur_db_source
            browser_record.deleted = 1 if rec.IsDeleted else 0
            try:
                self.csm.db_insert_table_browserecords(browser_record)
            except:
                exc()
        try:
            self.csm.db_commit()
        except:
            exc()
示例#9
0
    def parse_Browserecord(self, db_path, table_name):
        ''' 浏览记录 databases\box_visit_history.db 
                                _ visit_feed_history
                                - visit_history
                                - visit_search_history
                                - visit_swan_history

            - visit_search_history
            RecNo	    
            1	_id	            INTEGER     
            2	ukey	            TEXT        
            3	serverid	            TEXT        
            4	tplid	            TEXT        
            5	status	            TEXT        
            6	title	            TEXT	    
            7	desc	            TEXT        
            8	img	            TEXT        
            9	url	            TEXT        
            10	cmd	            TEXT        
            11	opentype	        TEXT        
            12	feature	            TEXT        
            13	datatype	        TEXT	    
            14	parent	            TEXT        
            15	visible	            TEXT        
            16	enable	            TEXT        
            17	createtime	            TEXT        
            18	modifytime	            TEXT        
            19	visittime	            TEXT        
            20	visits	            INTEGER     
            21	extra1	            TEXT        
            22	extra2	            TEXT        
            23	isfavored	        INTEGER     
            24	uid	            TEXT        
        '''
        if not self._read_db(db_path):
            return
        if not self.cur_db.GetTable(table_name):
            # lite box_visit_history.db  has no 'visit_search_history' table
            table_name = 'visit_history'
        for rec in self._read_table(table_name):
            if canceller.IsCancellationRequested:
                return
            if self._is_empty(rec, 'title',
                              'url') or not self._is_url(rec, 'url'):
                continue
            if self._is_duplicate(rec, '_id'):
                continue
            browser_record = model_browser.Browserecord()
            browser_record.id = rec['_id'].Value
            browser_record.name = rec['title'].Value
            browser_record.url = rec['url'].Value
            browser_record.datetime = rec['createtime'].Value
            browser_record.visit_count = rec[
                'visits'].Value if rec['visits'].Value > 0 else 1
            # browser_record.owneruser   = rec['date'].Value
            browser_record.source = self.cur_db_source
            browser_record.deleted = 1 if rec.IsDeleted else 0
            try:
                self.csm.db_insert_table_browserecords(browser_record)
            except:
                exc()
        try:
            self.csm.db_commit()
        except:
            exc()
示例#10
0
    def parse_model(self):
        '''  WebBookmark
                Title
                Url
                Path
                # TimeStamp
                # Position
                # PositionAddress 
                # LastVisited (timestamp)
                Deleted
                Source.Value

            VisitedPage
                Title.Value
                Url.Value
                VisitCount.Value
                LastVisited.Value 

            SearchedItem
                TimeStamp
                Value

                # Position
                # PositionAddress
                # ItemType
                # SearchResultCount
                # OwnerUserID
                # SearchResults
        '''
        for item in self.results_model:
            if item.I18N == "书签":  # WebBookmark
                bookmark = model_browser.Bookmark()
                bookmark.id = self.bookmark_id
                self.bookmark_id += 1
                # bookmark.owneruser  =
                # bookmark.time       =
                bookmark.title = item.Title.Value
                bookmark.url = item.Url.Value
                bookmark.source = item.Source.Value
                bookmark.deleted = 0 if item.Deleted == DeletedState.Intact else 1
                self.mb.db_insert_table_bookmarks(bookmark)

            elif item.I18N == "浏览记录":  # VisitedPage
                browser_record = model_browser.Browserecord()
                # browser_record.id       =
                browser_record.name = item.Title.Value
                browser_record.url = item.Url.Value
                browser_record.datetime = self._convert_2_timestamp(
                    item.LastVisited)
                browser_record.source = item.Source.Value
                browser_record.deleted = 0 if item.Deleted == DeletedState.Intact else 1

                self.mb.db_insert_table_browserecords(browser_record)

            elif item.I18N == "搜索项":  # SearchedItem
                search_history = model_browser.SearchHistory()
                # search_history.id       =
                search_history.name = item.Value
                # search_history.url      =
                search_history.datetime = self._convert_2_timestamp(
                    item.TimeStamp)
                search_history.source = item.Source.Value
                search_history.deleted = 0 if item.Deleted == DeletedState.Intact else 1

                self.mb.db_insert_table_searchhistory(search_history)