Skip to content

Commit

Permalink
πŸ—ƒ DB(models/maimai.py): ζ–°ε’ž musicInfo_2022 Model
Browse files Browse the repository at this point in the history
  • Loading branch information
yuangezhizao committed Jan 11, 2024
1 parent 1c91f57 commit 82ed391
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 36 deletions.
55 changes: 51 additions & 4 deletions src/maimai_DX_CN_probe/models/maimai.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def update(self):

class musicInfo(db.Model):
__bind_key__ = 'maimai'
__tablename__ = 'musicinfo_Ver.CH1.11-E'
__tablename__ = 'musicinfo_Ver.CH1.11'

id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.VARCHAR(50), nullable=False)
Expand Down Expand Up @@ -424,9 +424,9 @@ def __init__(self, name, level_img_s, dx_img_s, music_genre, music_word, music_l
self.cache_dt = cache_dt

def __repr__(self):
return '<musicInfo (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s,)>' % (
return '<musicInfo (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)>' % (
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, self.cache_dt)
self.music_version, self.ver, self.constant, self.cache_dt)

def to_dict(self):
return {c.name: getattr(self, c.name, None) for c in self.__table__.columns}
Expand Down Expand Up @@ -459,7 +459,6 @@ class musicInfo_2021(db.Model, HasId, HasTime):
music_version = db.Column(db.VARCHAR(50))

ver = db.Column(db.VARCHAR(50))
constant = db.Column(db.FLOAT(2))

def __init__(self, name, level_img_s, dx_img_s, music_genre, music_word, music_level, music_version, ver):
self.name = name,
Expand Down Expand Up @@ -492,3 +491,51 @@ def save(self):
def update(self):
db.session.commit()
return self


class musicInfo_2022(db.Model, HasId, HasTime):
__bind_key__ = 'maimai'
__tablename__ = 'musicinfo_Ver.CH1.20-H'

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 '<musicInfo_2022 (%s, %s, %s, %s, %s, %s, %s, %s, %s)>' % (
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
23 changes: 13 additions & 10 deletions src/maimai_DX_CN_probe/plugins/music_genre.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import requests
from lxml import etree

from maimai_DX_CN_probe.models.maimai import musicInfo_2021
from maimai_DX_CN_probe.models.maimai import musicInfo_2022

session = requests.Session()

Expand Down Expand Up @@ -182,8 +182,8 @@ def get_music_info(raw, music_genre):
music_word = None
music_version = None

ver = 'Ver.CH1.11-F'
new_maimai_Record = musicInfo_2021(name, level_img_s, dx_img_s, music_genre, music_word, music_level,
ver = 'Ver.CH1.20-H'
new_maimai_Record = musicInfo_2022(name, level_img_s, dx_img_s, music_genre, music_word, music_level,
music_version, ver)
r = new_maimai_Record.save()
print(r)
Expand All @@ -207,16 +207,16 @@ def update_music_info_musicWord(raw, music_word):
if (name == 'Link') & (level_img_s == 'diff_advanced'):
if not flag:
flag = True
old_maimai_Record = musicInfo_2021.query.filter_by(name=name, level_img_s=level_img_s,
old_maimai_Record = musicInfo_2022.query.filter_by(name=name, level_img_s=level_img_s,
dx_img_s=dx_img_s,
music_level=music_level).first()
else:
old_maimai_Record = \
musicInfo_2021.query.filter_by(name=name, level_img_s=level_img_s, dx_img_s=dx_img_s,
musicInfo_2022.query.filter_by(name=name, level_img_s=level_img_s, dx_img_s=dx_img_s,
music_level=music_level).all()[1]
# Bug need fixed
else:
old_maimai_Record = musicInfo_2021.query.filter_by(name=name, level_img_s=level_img_s, dx_img_s=dx_img_s,
old_maimai_Record = musicInfo_2022.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
Expand Down Expand Up @@ -247,20 +247,23 @@ def update_music_info_musicVersion(raw, music_version, music_diff):
if (name == 'Link') & (level_img_s == 'diff_advanced'):
if not flag:
flag = True
old_maimai_Record = musicInfo_2021.query.filter_by(name=name, level_img_s=level_img_s,
old_maimai_Record = musicInfo_2022.query.filter_by(name=name, level_img_s=level_img_s,
dx_img_s=dx_img_s,
music_level=music_level).first()
else:
old_maimai_Record = \
musicInfo_2021.query.filter_by(name=name, level_img_s=level_img_s, dx_img_s=dx_img_s,
musicInfo_2022.query.filter_by(name=name, level_img_s=level_img_s, dx_img_s=dx_img_s,
music_level=music_level).all()[1]
# Bug need fixed
else:
old_maimai_Record = musicInfo_2021.query.filter_by(name=name, level_img_s=level_img_s, dx_img_s=dx_img_s,
old_maimai_Record = musicInfo_2022.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
r = old_maimai_Record.update()
print(r)
else:
raise Exception('404')
# raise Exception('404')
print(f'{name},{level_img_s},{dx_img_s},{music_level} not found?')
# Technicians High,diff_basic,music_dx,4 not found?
# Technicians High,diff_advanced,music_dx,7+ not found?
7 changes: 0 additions & 7 deletions src/maimai_DX_CN_probe/templates/maimai/record/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ <h2>quick_record</h2>
<th>clear</th>
<th>vs</th>
<th>play_dt</th>
<th>cache_dt</th>
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -222,12 +221,6 @@ <h2>quick_record</h2>
{% else %}
{% endif %}
</td>
<td {% if data.cache_dt %}data-tooltip="{{ data.cache_dt }}" data-inverted=""{% endif %}>
{% if data.cache_dt %}
{{ data.cache_dt | my_split(' ', 0) }}
{% else %}
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
Expand Down
34 changes: 19 additions & 15 deletions src/maimai_DX_CN_probe/views/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"""
import flask

from maimai_DX_CN_probe.models.maimai import HOME, PlayerData, album, Record, playlogDetail, musicInfo_2021, musicInfo
from maimai_DX_CN_probe.models.maimai import HOME, PlayerData, album, Record, playlogDetail, musicInfo_2022
from maimai_DX_CN_probe.plugins.wechat_saver import save_home, save_playerData, save_playerData_album, save_record, \
save_record_playlogDetail, save_to_aqua

Expand Down Expand Up @@ -202,8 +202,12 @@ def record():
Record.play_dt <= _play_dt).order_by(
Record.achievement.desc()).all()

_lv = musicInfo_2021.query.filter_by(name=_name, level_img_s=_level_img_s,
dx_img_s=_dx_img_s).first().music_level
_lv = musicInfo_2022.query.filter_by(name=_name, level_img_s=_level_img_s,
dx_img_s=_dx_img_s).first()
if _lv:
_lv = _lv.music_level
else:
_lv = 'ζœͺηŸ₯'
# https://web.archive.org/web/20210802143823/https://stackoverflow.com/questions/8542343/object-does-not-support-item-assignment-error
for each in _record_data:
setattr(each, 'music_level', _lv)
Expand All @@ -229,34 +233,34 @@ def info():
filters = []
name = flask.request.form.get('name')
if name:
filters.append(musicInfo_2021.name.like('%' + name + '%'))
filters.append(musicInfo_2022.name.like('%' + name + '%'))
level_img_s = flask.request.form.get('level_img_s')
if level_img_s:
filters.append(musicInfo_2021.level_img_s == level_img_s)
filters.append(musicInfo_2022.level_img_s == level_img_s)
dx_img_s = flask.request.form.get('dx_img_s')
if dx_img_s:
filters.append(musicInfo_2021.dx_img_s == dx_img_s)
filters.append(musicInfo_2022.dx_img_s == dx_img_s)

music_genre = flask.request.form.get('music_genre')
if music_genre:
filters.append(musicInfo_2021.music_genre == music_genre)
filters.append(musicInfo_2022.music_genre == music_genre)
music_word = flask.request.form.get('music_word')
if music_word:
filters.append(musicInfo_2021.music_word == music_word)
filters.append(musicInfo_2022.music_word == music_word)
music_level = flask.request.form.get('music_level')
if music_level:
filters.append(musicInfo_2021.music_level == music_level)
filters.append(musicInfo_2022.music_level == music_level)
music_version = flask.request.form.get('music_version')
if music_version:
filters.append(musicInfo_2021.music_version == music_version)
filters.append(musicInfo_2022.music_version == music_version)

ver = flask.request.form.get('ver')
if ver:
filters.append(musicInfo_2021.ver == ver)
filters.append(musicInfo_2022.ver == ver)
filters_fmt = [str(each) for each in filters]
flask.flash(f'η­›ι€‰οΌš{filters_fmt}', 'success')

record_musicGenre_data = musicInfo_2021.query.filter(*filters).order_by(musicInfo_2021.id.asc()).all()
record_musicGenre_data = musicInfo_2022.query.filter(*filters).order_by(musicInfo_2022.id.asc()).all()
return flask.render_template('maimai/info/list.html', record_musicGenre_data=record_musicGenre_data,
size=len(record_musicGenre_data))

Expand All @@ -278,7 +282,7 @@ def rating():
for music_record in music_record_data:
if music_record.name == 'FREEDOM DiVE (tpz Overcute Remix)':
continue
_music_info = musicInfo_2021.query.filter_by(name=music_record.name,
_music_info = musicInfo_2022.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)
Expand Down Expand Up @@ -310,7 +314,7 @@ def rating():
if music_dx_record.id in [279, 313, 521, 568, 622]:
# ζ‰‹εŠ¨εŽ»ι‡
continue
_music_dx_info = musicInfo_2021.query.filter_by(name=music_dx_record.name,
_music_dx_info = musicInfo_2022.query.filter_by(name=music_dx_record.name,
level_img_s=music_dx_record.level_img_s,
dx_img_s='music_dx').first()
# TODOοΌšζ›²εζœ‰ι‡ε€
Expand All @@ -330,7 +334,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_2021.query.filter_by(name=music_standard_record.name,
_music_standard_info = musicInfo_2022.query.filter_by(name=music_standard_record.name,
level_img_s=music_standard_record.level_img_s,
dx_img_s='music_standard').first()
# TODOοΌšζ›²εζœ‰ι‡ε€
Expand Down

0 comments on commit 82ed391

Please sign in to comment.