def newList(self, data): if not isinstance(data, list): Util.error('Data must be a list') return False requireFields = ['setId', 'name', 'summary', 'link', 'img'] # assert common.checkRequire(data, requireFields) requireCheckRe = Util.checkRequire(data, requireFields) if True != requireCheckRe: Util.error('{} Require field {} not found'.format( 'saveVideoList', requireCheckRe)) return False data = Util.removeUnsafeFields(data, self.videoListFields.keys(), self.videoListFields) return self._db.insert_many(data)
def newSet(self, data, platform): if not isinstance(data, dict): Util.error('Data must be a dict') return False requireFields = [ 'title', 'link', 'summary', 'link', 'img', 'episode_over', 'is_vip', 'area', 'lang' ] # assert common.checkRequire(data, requireFields) requireCheckRe = Util.checkRequire(data, requireFields) if True != requireCheckRe: Util.error('{} Require field {} not found'.format( 'saveVideoSet', requireCheckRe)) return False data = Util.removeUnsafeFields(data, self.videoSetFields.keys(), self.videoSetFields) # 哪个平台的 data['platform'] = int(platform) setId = self._db.insert(data) return setId