diff --git a/src/maimai_DX_CN_probe/models/maimai.py b/src/maimai_DX_CN_probe/models/maimai.py index e5763d0..6b57c8b 100644 --- a/src/maimai_DX_CN_probe/models/maimai.py +++ b/src/maimai_DX_CN_probe/models/maimai.py @@ -587,3 +587,51 @@ def save(self): def update(self): db.session.commit() return self + + +class musicInfo_2024(db.Model, HasId, HasTime): + __bind_key__ = 'maimai' + __tablename__ = 'musicinfo_Ver.CN1.40-A' + + name = db.Column(db.VARCHAR(50), nullable=False) + level_img_s = db.Column(db.VARCHAR(50), nullable=False) + dx_img_s = db.Column(db.VARCHAR(50)) + + music_genre = db.Column(db.VARCHAR(50)) + music_word = db.Column(db.VARCHAR(50)) + music_level = db.Column(db.VARCHAR(50), nullable=False) + music_version = db.Column(db.VARCHAR(50)) + + ver = db.Column(db.VARCHAR(50)) + + def __init__(self, name, level_img_s, dx_img_s, music_genre, music_word, music_level, music_version, ver): + self.name = name, + self.level_img_s = level_img_s, + self.dx_img_s = dx_img_s, + self.music_genre = music_genre, + self.music_word = music_word, + self.music_level = music_level, + self.music_version = music_version, + self.ver = ver + + def __repr__(self): + return '' % ( + self.id, self.name, self.level_img_s, self.dx_img_s, self.music_genre, self.music_word, self.music_level, + self.music_version, self.ver + ) + + def to_dict(self): + return {c.name: getattr(self, c.name, None) for c in self.__table__.columns} + + def save(self): + try: + db.session.add(self) + db.session.commit() + except Exception as e: + print(e) + db.session.rollback() + return self + + def update(self): + db.session.commit() + return self diff --git a/src/maimai_DX_CN_probe/plugins/music_genre.py b/src/maimai_DX_CN_probe/plugins/music_genre.py index ace831f..66bc450 100644 --- a/src/maimai_DX_CN_probe/plugins/music_genre.py +++ b/src/maimai_DX_CN_probe/plugins/music_genre.py @@ -13,7 +13,7 @@ import requests from lxml import etree -from maimai_DX_CN_probe.models.maimai import musicInfo_2023 +from maimai_DX_CN_probe.models.maimai import musicInfo_2024 session = requests.Session() @@ -39,6 +39,7 @@ def get_wx_data_musicGenre(cookies: Dict, version: str): 2: 'expert', 3: 'master', 4: 'remaster', + # 10: 'utage' } for diff in diff_dict: for genre in genre_dict: @@ -146,7 +147,8 @@ def update_wx_data_musicVersion(cookies: Dict): # 14: '其他', # 暂无铺面 15: '舞萌DX 2021', 17: '舞萌DX 2022', - 19: '舞萌DX 2023' + 19: '舞萌DX 2023', + 21: '舞萌DX 2024' } diff_dict = { 0: 'basic', @@ -207,7 +209,7 @@ def get_music_info(raw: str, music_genre: str, version: str): music_word = None music_version = None - new_maimai_Record = musicInfo_2023(name, level_img_s, dx_img_s, music_genre, music_word, music_level, + new_maimai_Record = musicInfo_2024(name, level_img_s, dx_img_s, music_genre, music_word, music_level, music_version, version) r = new_maimai_Record.save() print(r) @@ -237,7 +239,7 @@ def update_music_info_musicWord(raw: str, music_word: str): print(f'{name},{level_img_s},{dx_img_s},{music_level} skipped') continue else: - old_maimai_Record = musicInfo_2023.query.filter_by(name=name, level_img_s=level_img_s, dx_img_s=dx_img_s, + old_maimai_Record = musicInfo_2024.query.filter_by(name=name, level_img_s=level_img_s, dx_img_s=dx_img_s, music_level=music_level).first() if old_maimai_Record is not None: old_maimai_Record.music_word = music_word @@ -265,7 +267,7 @@ def update_music_info_musicVersion(raw: str, music_version: str, music_diff: str name = selector.xpath(f'/html/body/div[2]/div[{i}]/form/div[3]/text()')[0] # 容错 +1 - if music_version in ['舞萌DX', '舞萌DX 2021', '舞萌DX 2022', '舞萌DX 2023']: + if music_version in ['舞萌DX', '舞萌DX 2021', '舞萌DX 2022', '舞萌DX 2023', '舞萌DX 2024']: # DX only dx_img_s = 'music_dx' else: @@ -275,7 +277,7 @@ def update_music_info_musicVersion(raw: str, music_version: str, music_diff: str print(f'{name},{level_img_s},{dx_img_s},{music_level} skipped') continue else: - old_maimai_Record = musicInfo_2023.query.filter_by(name=name, level_img_s=level_img_s, dx_img_s=dx_img_s, + old_maimai_Record = musicInfo_2024.query.filter_by(name=name, level_img_s=level_img_s, dx_img_s=dx_img_s, music_level=music_level).first() if old_maimai_Record is not None: old_maimai_Record.music_version = music_version @@ -312,7 +314,7 @@ def update_music_info_musicVersion(raw: str, music_version: str, music_diff: str 'userId': '', '_t': '32113aae470309d076209bb0d9ea66fa' } - ver = 'Ver.CN1.32-H' + ver = 'Ver.CN1.40-A' # get_wx_data_musicGenre(cookies, ver) # update_wx_data_musicWord(cookies) # update_wx_data_musicVersion(cookies) diff --git a/src/maimai_DX_CN_probe/views/main.py b/src/maimai_DX_CN_probe/views/main.py index a480727..5b0f00b 100644 --- a/src/maimai_DX_CN_probe/views/main.py +++ b/src/maimai_DX_CN_probe/views/main.py @@ -8,7 +8,7 @@ """ import flask -from maimai_DX_CN_probe.models.maimai import HOME, PlayerData, album, Record, playlogDetail, musicInfo_2023 +from maimai_DX_CN_probe.models.maimai import HOME, PlayerData, album, Record, playlogDetail, musicInfo_2024 from maimai_DX_CN_probe.plugins.wechat_saver import save_home, save_playerData, save_playerData_album, save_record, \ save_record_playlogDetail, save_to_aqua @@ -204,7 +204,7 @@ def record(): Record.play_dt <= _play_dt).order_by( Record.achievement.desc()).all() - _lv = musicInfo_2023.query.filter_by(name=_name, level_img_s=_level_img_s, + _lv = musicInfo_2024.query.filter_by(name=_name, level_img_s=_level_img_s, dx_img_s=_dx_img_s).first() if _lv: _lv = _lv.music_level @@ -235,34 +235,34 @@ def info(): filters = [] name = flask.request.form.get('name') if name: - filters.append(musicInfo_2023.name.like('%' + name + '%')) + filters.append(musicInfo_2024.name.like('%' + name + '%')) level_img_s = flask.request.form.get('level_img_s') if level_img_s: - filters.append(musicInfo_2023.level_img_s == level_img_s) + filters.append(musicInfo_2024.level_img_s == level_img_s) dx_img_s = flask.request.form.get('dx_img_s') if dx_img_s: - filters.append(musicInfo_2023.dx_img_s == dx_img_s) + filters.append(musicInfo_2024.dx_img_s == dx_img_s) music_genre = flask.request.form.get('music_genre') if music_genre: - filters.append(musicInfo_2023.music_genre == music_genre) + filters.append(musicInfo_2024.music_genre == music_genre) music_word = flask.request.form.get('music_word') if music_word: - filters.append(musicInfo_2023.music_word == music_word) + filters.append(musicInfo_2024.music_word == music_word) music_level = flask.request.form.get('music_level') if music_level: - filters.append(musicInfo_2023.music_level == music_level) + filters.append(musicInfo_2024.music_level == music_level) music_version = flask.request.form.get('music_version') if music_version: - filters.append(musicInfo_2023.music_version == music_version) + filters.append(musicInfo_2024.music_version == music_version) ver = flask.request.form.get('ver') if ver: - filters.append(musicInfo_2023.ver == ver) + filters.append(musicInfo_2024.ver == ver) filters_fmt = [str(each) for each in filters] flask.flash(f'筛选:{filters_fmt}', 'success') - record_musicGenre_data = musicInfo_2023.query.filter(*filters).order_by(musicInfo_2023.id.asc()).all() + record_musicGenre_data = musicInfo_2024.query.filter(*filters).order_by(musicInfo_2024.id.asc()).all() return flask.render_template('maimai/info/list.html', record_musicGenre_data=record_musicGenre_data, size=len(record_musicGenre_data)) @@ -284,7 +284,7 @@ def rating(): for music_record in music_record_data: if music_record.name == 'FREEDOM DiVE (tpz Overcute Remix)': continue - _music_info = musicInfo_2023.query.filter_by(name=music_record.name, + _music_info = musicInfo_2024.query.filter_by(name=music_record.name, level_img_s=music_record.level_img_s, dx_img_s=music_record.dx_img_s).first() print(_music_info) @@ -316,7 +316,7 @@ def rating(): if music_dx_record.id in [279, 313, 521, 568, 622]: # 手动去重 continue - _music_dx_info = musicInfo_2023.query.filter_by(name=music_dx_record.name, + _music_dx_info = musicInfo_2024.query.filter_by(name=music_dx_record.name, level_img_s=music_dx_record.level_img_s, dx_img_s='music_dx').first() # TODO:曲名有重复 @@ -336,7 +336,7 @@ def rating(): if music_standard_record.id in [175, 182, 201, 205, 213, 310, 453, 245, 554, 578, 696, 713, 717, 719, 744]: # 手动去重 continue - _music_standard_info = musicInfo_2023.query.filter_by(name=music_standard_record.name, + _music_standard_info = musicInfo_2024.query.filter_by(name=music_standard_record.name, level_img_s=music_standard_record.level_img_s, dx_img_s='music_standard').first() # TODO:曲名有重复 @@ -358,23 +358,4 @@ def rating(): @bp.route('/test') def test(): - return '1' - from maimai_DX_CN_probe.plugins.music_genre import get_wx_data_musicGenre, update_wx_data_musicWord, \ - update_wx_data_musicVersion - cookies = { - 'userId': '', - '_t': 'f3349161266657b57ffb0b565e3eb39f' - } - ver = 'Ver.CN1.32-H' - get_wx_data_musicGenre(cookies, ver) - update_wx_data_musicWord(cookies) - update_wx_data_musicVersion(cookies) - # new_info = musicInfo.query.all() - # for info in new_info: - # old_info = musicInfo_old.query.filter_by(name=info.name, level_img_s=info.level_img_s, dx_img_s=info.dx_img_s, - # music_genre=info.music_genre, music_level=info.music_level).first() - # print(info) - # if old_info: - # info.ver = old_info.ver - # info.cache_dt = old_info.cache_dt - # info.update() + return 'OK'