7 Commits

Author SHA1 Message Date
Lost-MSth
941a79ccc7 Update to v2.3.2 2021-04-09 14:42:14 +08:00
Lost-MSth
62902a561c Add an option 2021-04-05 14:45:50 +08:00
Lost-MSth
1660bc5899 Merge branch 'master' of https://github.com/Lost-MSth/Arcaea-server 2021-04-05 13:20:42 +08:00
Lost-MSth
d577246d28 Revert "Revert "Fix some bugs""
This reverts commit 9fd626468e.
2021-04-05 13:20:36 +08:00
Lost-MSth
9fd626468e Revert "Fix some bugs"
This reverts commit c51a1b4e85.
2021-04-05 13:19:32 +08:00
Lost-MSth
c51a1b4e85 Fix some bugs
Fix the fanmade cloud save (add a switch in setting)

Add SSL switch

Fix 'my rank' in game, if there is not enough people behind you, now it will show 20 people as expected
2021-04-05 13:02:56 +08:00
Lost-MSth
0e42123417 Update README.md
Well, it is not 4.1 now.
2021-04-02 22:03:35 +08:00
11 changed files with 1145 additions and 1003 deletions

View File

@@ -40,6 +40,7 @@ This procedure is mainly used for study and research, and shall not be used for
没有以下 We don't have 没有以下 We don't have
- 服务器安全性保证 Server security assurance - 服务器安全性保证 Server security assurance
- 世界模式下的搭档升级、觉醒,以及某些奖励的获取 Partner upgrading, uncapping, and receiving some rewards in the world mode
可能有问题 There may be problems 可能有问题 There may be problems
- Recent 30 - Recent 30
@@ -59,16 +60,18 @@ It is just so interesting. What it can do is under exploration.
## 更新日志 Update log ## 更新日志 Update log
只保留最新版本 Only keep the latest version. 只保留最新版本 Only keep the latest version.
> 提醒:更新时请注意保留原先的数据库,以防数据丢失 > 提醒:更新时请注意保留原先的数据库,以防数据丢失。使用前请先运行**database_initialize.py**以获得初始数据库。
> >
> Tips: When updating, please keep the original database in case of data loss. > Tips: When updating, please keep the original database in case of data loss.
> Before using, please run **database_initialize.py** to get the initial database.
### Version 2.3.1 ### Version 2.3.2
- **不**适用于Arcaea 3.5.3版本 **Not** for Arcaea 3.5.3 - 适用于Arcaea 3.5.4版本 For Arcaea 3.5.4
- **新增**了一些Bug **Add** some bugs. - 更新了歌曲数据库 Update the song database.
- 新增运行前关键性文件检查 Add checking critical files before running.
> Happy April Fool's Day! - 新增可下载数据的客户端校验更新 Add client verification update of downloadable data.
- 新增歌曲成绩的谱面校验 Add checking chart file when submitting the song score.
- 修复了一些Bug Fix some bugs.
## 运行环境与依赖 Running environment and requirements ## 运行环境与依赖 Running environment and requirements
- Windows/Linux/Mac OS/Android - Windows/Linux/Mac OS/Android

Binary file not shown.

View File

@@ -12,10 +12,10 @@
"items": [{ "items": [{
"id": "dataerror", "id": "dataerror",
"type": "single", "type": "single",
"_id": "6046bab736651a07ebc537f3", "_id": "606f9f5636651a07ebc541f3",
"is_available": true "is_available": true
}], }],
"price": 50, "price": 100,
"orig_price": 100, "orig_price": 100,
"discount_from": 1615248000000, "discount_from": 1615248000000,
"discount_to": 1615852799000 "discount_to": 1615852799000
@@ -24,10 +24,10 @@
"items": [{ "items": [{
"id": "yourvoiceso", "id": "yourvoiceso",
"type": "single", "type": "single",
"_id": "6046bab736651a07ebc53800", "_id": "606f9f5636651a07ebc54201",
"is_available": true "is_available": true
}], }],
"price": 50, "price": 100,
"orig_price": 100, "orig_price": 100,
"discount_from": 1615248000000, "discount_from": 1615248000000,
"discount_to": 1615852799000 "discount_to": 1615852799000
@@ -36,10 +36,10 @@
"items": [{ "items": [{
"id": "crosssoul", "id": "crosssoul",
"type": "single", "type": "single",
"_id": "6046bab736651a07ebc5380d", "_id": "606f9f5636651a07ebc5420e",
"is_available": true "is_available": true
}], }],
"price": 50, "price": 100,
"orig_price": 100, "orig_price": 100,
"discount_from": 1615248000000, "discount_from": 1615248000000,
"discount_to": 1615852799000 "discount_to": 1615852799000
@@ -48,10 +48,10 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "impurebird", "id": "impurebird",
"_id": "6046bab736651a07ebc53801", "_id": "606f9f5636651a07ebc541f4",
"is_available": true "is_available": true
}], }],
"price": 50, "price": 100,
"orig_price": 100, "orig_price": 100,
"discount_from": 1615248000000, "discount_from": 1615248000000,
"discount_to": 1615852799000 "discount_to": 1615852799000
@@ -60,7 +60,7 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "auxesia", "id": "auxesia",
"_id": "6046bab736651a07ebc5380e", "_id": "606f9f5636651a07ebc5420f",
"is_available": true "is_available": true
}], }],
"price": 100, "price": 100,
@@ -72,10 +72,10 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "modelista", "id": "modelista",
"_id": "6046bab736651a07ebc537f4", "_id": "606f9f5636651a07ebc54202",
"is_available": true "is_available": true
}], }],
"price": 50, "price": 100,
"orig_price": 100, "orig_price": 100,
"discount_from": 1615248000000, "discount_from": 1615248000000,
"discount_to": 1615852799000 "discount_to": 1615852799000
@@ -84,10 +84,10 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "yozakurafubuki", "id": "yozakurafubuki",
"_id": "6046bab736651a07ebc53802", "_id": "606f9f5636651a07ebc541f5",
"is_available": true "is_available": true
}], }],
"price": 50, "price": 100,
"orig_price": 100, "orig_price": 100,
"discount_from": 1615248000000, "discount_from": 1615248000000,
"discount_to": 1615852799000 "discount_to": 1615852799000
@@ -96,10 +96,10 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "surrender", "id": "surrender",
"_id": "6046bab736651a07ebc5380f", "_id": "606f9f5636651a07ebc54210",
"is_available": true "is_available": true
}], }],
"price": 50, "price": 100,
"orig_price": 100, "orig_price": 100,
"discount_from": 1615248000000, "discount_from": 1615248000000,
"discount_to": 1615852799000 "discount_to": 1615852799000
@@ -108,7 +108,7 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "metallicpunisher", "id": "metallicpunisher",
"_id": "6046bab736651a07ebc537f5", "_id": "606f9f5636651a07ebc54203",
"is_available": true "is_available": true
}], }],
"price": 100, "price": 100,
@@ -118,7 +118,7 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "carminescythe", "id": "carminescythe",
"_id": "6046bab736651a07ebc53803", "_id": "606f9f5636651a07ebc541f6",
"is_available": true "is_available": true
}], }],
"price": 100, "price": 100,
@@ -128,10 +128,10 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "bethere", "id": "bethere",
"_id": "6046bab736651a07ebc53810", "_id": "606f9f5636651a07ebc54211",
"is_available": true "is_available": true
}], }],
"price": 50, "price": 100,
"orig_price": 100, "orig_price": 100,
"discount_from": 1615248000000, "discount_from": 1615248000000,
"discount_to": 1615852799000 "discount_to": 1615852799000
@@ -140,10 +140,10 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "callmyname", "id": "callmyname",
"_id": "6046bab736651a07ebc537e9", "_id": "606f9f5636651a07ebc5421c",
"is_available": true "is_available": true
}], }],
"price": 50, "price": 100,
"orig_price": 100, "orig_price": 100,
"discount_from": 1615248000000, "discount_from": 1615248000000,
"discount_to": 1615852799000 "discount_to": 1615852799000
@@ -152,10 +152,10 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "fallensquare", "id": "fallensquare",
"_id": "6046bab736651a07ebc537de", "_id": "606f9f5636651a07ebc541e9",
"is_available": true "is_available": true
}], }],
"price": 50, "price": 100,
"orig_price": 100, "orig_price": 100,
"discount_from": 1615248000000, "discount_from": 1615248000000,
"discount_to": 1615852799000 "discount_to": 1615852799000
@@ -164,10 +164,10 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "dropdead", "id": "dropdead",
"_id": "6046bab736651a07ebc53804", "_id": "606f9f5636651a07ebc541f7",
"is_available": true "is_available": true
}], }],
"price": 50, "price": 100,
"orig_price": 100, "orig_price": 100,
"discount_from": 1615248000000, "discount_from": 1615248000000,
"discount_to": 1615852799000 "discount_to": 1615852799000
@@ -176,10 +176,10 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "alexandrite", "id": "alexandrite",
"_id": "6046bab736651a07ebc53811", "_id": "606f9f5636651a07ebc54212",
"is_available": true "is_available": true
}], }],
"price": 50, "price": 100,
"orig_price": 100, "orig_price": 100,
"discount_from": 1615248000000, "discount_from": 1615248000000,
"discount_to": 1615852799000 "discount_to": 1615852799000
@@ -188,10 +188,10 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "astraltale", "id": "astraltale",
"_id": "6046bab736651a07ebc537f7", "_id": "606f9f5636651a07ebc54205",
"is_available": true "is_available": true
}], }],
"price": 50, "price": 100,
"orig_price": 100, "orig_price": 100,
"discount_from": 1615248000000, "discount_from": 1615248000000,
"discount_to": 1615852799000 "discount_to": 1615852799000
@@ -200,7 +200,7 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "phantasia", "id": "phantasia",
"_id": "6046bab736651a07ebc537df", "_id": "606f9f5636651a07ebc541ea",
"is_available": true "is_available": true
}], }],
"price": 100, "price": 100,
@@ -210,7 +210,7 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "empireofwinter", "id": "empireofwinter",
"_id": "6046bab736651a07ebc53805", "_id": "606f9f5636651a07ebc541f8",
"is_available": true "is_available": true
}], }],
"price": 100, "price": 100,
@@ -220,10 +220,10 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "libertas", "id": "libertas",
"_id": "6046bab736651a07ebc537eb", "_id": "606f9f5636651a07ebc5421e",
"is_available": true "is_available": true
}], }],
"price": 50, "price": 100,
"orig_price": 100, "orig_price": 100,
"discount_from": 1615248000000, "discount_from": 1615248000000,
"discount_to": 1615852799000 "discount_to": 1615852799000
@@ -232,10 +232,10 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "dottodot", "id": "dottodot",
"_id": "6046bab736651a07ebc537e0", "_id": "606f9f5636651a07ebc541eb",
"is_available": true "is_available": true
}], }],
"price": 50, "price": 100,
"orig_price": 100, "orig_price": 100,
"discount_from": 1615248000000, "discount_from": 1615248000000,
"discount_to": 1615852799000 "discount_to": 1615852799000
@@ -244,10 +244,10 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "dreadnought", "id": "dreadnought",
"_id": "6046bab736651a07ebc537ec", "_id": "606f9f5636651a07ebc5421f",
"is_available": true "is_available": true
}], }],
"price": 50, "price": 100,
"orig_price": 100, "orig_price": 100,
"discount_from": 1615248000000, "discount_from": 1615248000000,
"discount_to": 1615852799000 "discount_to": 1615852799000
@@ -256,10 +256,10 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "mirzam", "id": "mirzam",
"_id": "6046bab736651a07ebc537e1", "_id": "606f9f5636651a07ebc541ec",
"is_available": true "is_available": true
}], }],
"price": 50, "price": 100,
"orig_price": 100, "orig_price": 100,
"discount_from": 1615248000000, "discount_from": 1615248000000,
"discount_to": 1615852799000 "discount_to": 1615852799000
@@ -268,10 +268,10 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "heavenlycaress", "id": "heavenlycaress",
"_id": "6046bab736651a07ebc53807", "_id": "606f9f5636651a07ebc541fa",
"is_available": true "is_available": true
}], }],
"price": 50, "price": 100,
"orig_price": 100, "orig_price": 100,
"discount_from": 1615248000000, "discount_from": 1615248000000,
"discount_to": 1615852799000 "discount_to": 1615852799000
@@ -280,10 +280,10 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "filament", "id": "filament",
"_id": "6046bab736651a07ebc53814", "_id": "606f9f5636651a07ebc54215",
"is_available": true "is_available": true
}], }],
"price": 50, "price": 100,
"orig_price": 100, "orig_price": 100,
"discount_from": 1615248000000, "discount_from": 1615248000000,
"discount_to": 1615852799000 "discount_to": 1615852799000
@@ -292,7 +292,7 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "avantraze", "id": "avantraze",
"_id": "6046bab736651a07ebc537ed", "_id": "606f9f5636651a07ebc54220",
"is_available": true "is_available": true
}], }],
"price": 100, "price": 100,
@@ -302,10 +302,10 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "battlenoone", "id": "battlenoone",
"_id": "6046bab736651a07ebc537fa", "_id": "606f9f5636651a07ebc54208",
"is_available": true "is_available": true
}], }],
"price": 50, "price": 100,
"orig_price": 100, "orig_price": 100,
"discount_from": 1615248000000, "discount_from": 1615248000000,
"discount_to": 1615852799000 "discount_to": 1615852799000
@@ -314,7 +314,7 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "saikyostronger", "id": "saikyostronger",
"_id": "6046bab736651a07ebc537e2", "_id": "606f9f5636651a07ebc541ed",
"is_available": true "is_available": true
}], }],
"price": 100, "price": 100,
@@ -324,10 +324,10 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "izana", "id": "izana",
"_id": "6046bab736651a07ebc53808", "_id": "606f9f5636651a07ebc541fb",
"is_available": true "is_available": true
}], }],
"price": 50, "price": 100,
"orig_price": 100, "orig_price": 100,
"discount_from": 1615248000000, "discount_from": 1615248000000,
"discount_to": 1615852799000 "discount_to": 1615852799000
@@ -336,10 +336,10 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "einherjar", "id": "einherjar",
"_id": "6046bab736651a07ebc53815", "_id": "606f9f5636651a07ebc54216",
"is_available": true "is_available": true
}], }],
"price": 50, "price": 100,
"orig_price": 100, "orig_price": 100,
"discount_from": 1615248000000, "discount_from": 1615248000000,
"discount_to": 1615852799000 "discount_to": 1615852799000
@@ -348,10 +348,10 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "laqryma", "id": "laqryma",
"_id": "6046bab736651a07ebc537ee", "_id": "606f9f5636651a07ebc54221",
"is_available": true "is_available": true
}], }],
"price": 50, "price": 100,
"orig_price": 100, "orig_price": 100,
"discount_from": 1615248000000, "discount_from": 1615248000000,
"discount_to": 1615852799000 "discount_to": 1615852799000
@@ -360,10 +360,10 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "amygdata", "id": "amygdata",
"_id": "6046bab736651a07ebc537fb", "_id": "606f9f5636651a07ebc54209",
"is_available": true "is_available": true
}], }],
"price": 50, "price": 100,
"orig_price": 100, "orig_price": 100,
"discount_from": 1615248000000, "discount_from": 1615248000000,
"discount_to": 1615852799000 "discount_to": 1615852799000
@@ -372,10 +372,10 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "altale", "id": "altale",
"_id": "6046bab736651a07ebc537e3", "_id": "606f9f5636651a07ebc541ee",
"is_available": true "is_available": true
}], }],
"price": 50, "price": 100,
"orig_price": 100, "orig_price": 100,
"discount_from": 1615248000000, "discount_from": 1615248000000,
"discount_to": 1615852799000 "discount_to": 1615852799000
@@ -384,10 +384,10 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "feelssoright", "id": "feelssoright",
"_id": "6046bab736651a07ebc537ef", "_id": "606f9f5636651a07ebc54222",
"is_available": true "is_available": true
}], }],
"price": 50, "price": 100,
"orig_price": 100, "orig_price": 100,
"discount_from": 1615248000000, "discount_from": 1615248000000,
"discount_to": 1615852799000 "discount_to": 1615852799000
@@ -396,7 +396,7 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "scarletcage", "id": "scarletcage",
"_id": "6046bab736651a07ebc537fc", "_id": "606f9f5636651a07ebc5420a",
"is_available": true "is_available": true
}], }],
"price": 100, "price": 100,
@@ -406,7 +406,7 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "teriqma", "id": "teriqma",
"_id": "6046bab736651a07ebc537e4", "_id": "606f9f5636651a07ebc541ef",
"is_available": true "is_available": true
}], }],
"price": 100, "price": 100,
@@ -416,10 +416,10 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "mahoroba", "id": "mahoroba",
"_id": "6046bab736651a07ebc5380a", "_id": "606f9f5636651a07ebc541fd",
"is_available": true "is_available": true
}], }],
"price": 50, "price": 100,
"orig_price": 100, "orig_price": 100,
"discount_from": 1615248000000, "discount_from": 1615248000000,
"discount_to": 1615852799000 "discount_to": 1615852799000
@@ -428,10 +428,10 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "badtek", "id": "badtek",
"_id": "6046bab736651a07ebc537f0", "_id": "606f9f5636651a07ebc54223",
"is_available": true "is_available": true
}], }],
"price": 50, "price": 100,
"orig_price": 100, "orig_price": 100,
"discount_from": 1615248000000, "discount_from": 1615248000000,
"discount_to": 1615852799000 "discount_to": 1615852799000
@@ -440,7 +440,7 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "maliciousmischance", "id": "maliciousmischance",
"_id": "6046bab736651a07ebc53817", "_id": "606f9f5636651a07ebc54218",
"is_available": true "is_available": true
}], }],
"price": 100, "price": 100,
@@ -450,7 +450,7 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "buchigireberserker", "id": "buchigireberserker",
"_id": "6046bab736651a07ebc537e5", "_id": "606f9f5636651a07ebc541f0",
"is_available": true "is_available": true
}], }],
"price": 100, "price": 100,
@@ -460,10 +460,10 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "galaxyfriends", "id": "galaxyfriends",
"_id": "6046bab736651a07ebc5380b", "_id": "606f9f5636651a07ebc541fe",
"is_available": true "is_available": true
}], }],
"price": 50, "price": 100,
"orig_price": 100, "orig_price": 100,
"discount_from": 1615248000000, "discount_from": 1615248000000,
"discount_to": 1615852799000 "discount_to": 1615852799000
@@ -472,7 +472,7 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "xeraphinite", "id": "xeraphinite",
"_id": "6046bab736651a07ebc53818", "_id": "606f9f5636651a07ebc54219",
"is_available": true "is_available": true
}], }],
"orig_price": 100, "orig_price": 100,
@@ -482,7 +482,7 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "xanatos", "id": "xanatos",
"_id": "6046bab736651a07ebc537f1", "_id": "606f9f5636651a07ebc54224",
"is_available": true "is_available": true
}], }],
"price": 100, "price": 100,
@@ -492,7 +492,7 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "attraqtia", "id": "attraqtia",
"_id": "6046bab736651a07ebc537ff", "_id": "606f9f5636651a07ebc5420d",
"is_available": true "is_available": true
}], }],
"orig_price": 100, "orig_price": 100,
@@ -502,7 +502,17 @@
"items": [{ "items": [{
"type": "single", "type": "single",
"id": "gimmedablood", "id": "gimmedablood",
"_id": "6046bab736651a07ebc537e7", "_id": "606f9f5636651a07ebc541f2",
"is_available": true
}],
"orig_price": 100,
"price": 100
}, {
"name": "bassline",
"items": [{
"type": "single",
"id": "bassline",
"_id": "606f9f5636651a07ebc54200",
"is_available": true "is_available": true
}], }],
"orig_price": 100, "orig_price": 100,

View File

@@ -13,6 +13,7 @@ import web.index
import server.arcworld import server.arcworld
import server.arcdownload import server.arcdownload
import server.arcpurchase import server.arcpurchase
import server.init
import os import os
import sys import sys
@@ -570,6 +571,11 @@ def main():
dictConfig(log_dict) dictConfig(log_dict)
if not server.init.check_before_run(app):
app.logger.error('Something wrong. The server will not run.')
input('Press ENTER key to exit.')
sys.exit()
app.logger.info("Start to initialize data in 'songfile' table...") app.logger.info("Start to initialize data in 'songfile' table...")
try: try:
error = server.arcdownload.initialize_songfile() error = server.arcdownload.initialize_songfile()
@@ -580,6 +586,10 @@ def main():
else: else:
app.logger.info('Complete!') app.logger.info('Complete!')
if Config.SSL_CERT and Config.SSL_KEY:
app.run(Config.HOST, Config.PORT, ssl_context=(
Config.SSL_CERT, Config.SSL_KEY))
else:
app.run(Config.HOST, Config.PORT) app.run(Config.HOST, Config.PORT)

View File

@@ -25,7 +25,24 @@ def get_file_md5(file_path):
return myhash.hexdigest() return myhash.hexdigest()
def get_one_song(c, user_id, song_id, file_dir='./database/songs'): def get_url(file_path, **kwargs):
# 获取下载地址
t = ''
if 't' in kwargs:
t = kwargs['t']
if Config.DOWNLOAD_LINK_PREFIX:
prefix = Config.DOWNLOAD_LINK_PREFIX
if prefix[-1] != '/':
prefix += '/'
return prefix + file_path + '?t=' + t
else:
return url_for('download', file_path=file_path, t=t, _external=True)
def get_one_song(c, user_id, song_id, file_dir='./database/songs', url_flag=True):
# 获取一首歌的下载链接,返回字典 # 获取一首歌的下载链接,返回字典
dir_list = os.listdir(os.path.join(file_dir, song_id)) dir_list = os.listdir(os.path.join(file_dir, song_id))
re = {} re = {}
@@ -37,7 +54,6 @@ def get_one_song(c, user_id, song_id, file_dir='./database/songs'):
if os.path.isfile(os.path.join(file_dir, song_id, i)) and i in ['0.aff', '1.aff', '2.aff', '3.aff', 'base.ogg']: if os.path.isfile(os.path.join(file_dir, song_id, i)) and i in ['0.aff', '1.aff', '2.aff', '3.aff', 'base.ogg']:
token = hashlib.md5( token = hashlib.md5(
(str(user_id) + song_id + i + str(now)).encode(encoding='UTF-8')).hexdigest() (str(user_id) + song_id + i + str(now)).encode(encoding='UTF-8')).hexdigest()
token = token[:8]
if i == 'base.ogg': if i == 'base.ogg':
c.execute( c.execute(
@@ -48,8 +64,12 @@ def get_one_song(c, user_id, song_id, file_dir='./database/songs'):
else: else:
checksum = get_file_md5(os.path.join( checksum = get_file_md5(os.path.join(
file_dir, song_id, 'base.ogg')) file_dir, song_id, 'base.ogg'))
re['audio'] = {"checksum": checksum,
"url": url_for('download', file_path=song_id+'/base.ogg', t=token, _external=True)} if url_flag:
re['audio'] = {"checksum": checksum, "url": get_url(
file_path=song_id+'/base.ogg', t=token)}
else:
re['audio'] = {"checksum": checksum}
else: else:
if 'chart' not in re: if 'chart' not in re:
re['chart'] = {} re['chart'] = {}
@@ -60,23 +80,28 @@ def get_one_song(c, user_id, song_id, file_dir='./database/songs'):
checksum = x[0] checksum = x[0]
else: else:
checksum = get_file_md5(os.path.join(file_dir, song_id, i)) checksum = get_file_md5(os.path.join(file_dir, song_id, i))
re['chart'][i[0]] = {"checksum": checksum,
"url": url_for('download', file_path=song_id+'/'+i, t=token, _external=True)}
if url_flag:
re['chart'][i[0]] = {"checksum": checksum, "url": get_url(
file_path=song_id+'/'+i, t=token)}
else:
re['chart'][i[0]] = {"checksum": checksum}
if url_flag:
c.execute('''insert into download_token values(:a,:b,:c,:d,:e)''', { c.execute('''insert into download_token values(:a,:b,:c,:d,:e)''', {
'a': user_id, 'b': song_id, 'c': i, 'd': token, 'e': now}) 'a': user_id, 'b': song_id, 'c': i, 'd': token, 'e': now})
return {song_id: re} return {song_id: re}
def get_all_songs(user_id, file_dir='./database/songs'): def get_all_songs(user_id, file_dir='./database/songs', url_flag=True):
# 获取所有歌的下载链接,返回字典 # 获取所有歌的下载链接,返回字典
dir_list = os.listdir(file_dir) dir_list = os.listdir(file_dir)
re = {} re = {}
with Connect() as c: with Connect() as c:
for i in dir_list: for i in dir_list:
if os.path.isdir(os.path.join(file_dir, i)): if os.path.isdir(os.path.join(file_dir, i)):
re.update(get_one_song(c, user_id, i, file_dir)) re.update(get_one_song(c, user_id, i, file_dir, url_flag))
return re return re

View File

@@ -3,6 +3,7 @@ import time
import json import json
import server.arcworld import server.arcworld
import hashlib import hashlib
from setting import Config
def b2int(x): def b2int(x):
@@ -129,9 +130,13 @@ def arc_score_me(user_id, song_id, difficulty, limit=20):
'user_id': user_id, 'song_id': song_id, 'difficulty': difficulty}) 'user_id': user_id, 'song_id': song_id, 'difficulty': difficulty})
x = c.fetchone() x = c.fetchone()
myrank = int(x[0]) + 1 myrank = int(x[0]) + 1
c.execute('''select count(*) from best_score where song_id=:a and difficulty=:b''',
{'a': song_id, 'b': difficulty})
amount = int(c.fetchone()[0])
if myrank <= 4: # 排名在前4 if myrank <= 4: # 排名在前4
return arc_score_top(song_id, difficulty, limit) return arc_score_top(song_id, difficulty, limit)
elif myrank >= 5 and myrank <= 9999 - limit + 4: # 万名内前面有4个人 elif myrank >= 5 and myrank <= 9999 - limit + 4 and amount >= 10000: # 万名内前面有4个人
c.execute('''select user_id from best_score where song_id = :song_id and difficulty = :difficulty order by score DESC, time_played DESC limit :limit offset :offset''', { c.execute('''select user_id from best_score where song_id = :song_id and difficulty = :difficulty order by score DESC, time_played DESC limit :limit offset :offset''', {
'song_id': song_id, 'difficulty': difficulty, 'limit': limit, 'offset': myrank - 5}) 'song_id': song_id, 'difficulty': difficulty, 'limit': limit, 'offset': myrank - 5})
x = c.fetchall() x = c.fetchall()
@@ -157,6 +162,17 @@ def arc_score_me(user_id, song_id, difficulty, limit=20):
y = get_score(c, user_id, song_id, difficulty) y = get_score(c, user_id, song_id, difficulty)
y['rank'] = -1 y['rank'] = -1
r.append(y) r.append(y)
elif amount - myrank < limit - 5: # 后方人数不足
c.execute('''select user_id from best_score where song_id = :song_id and difficulty = :difficulty order by score DESC, time_played DESC limit :limit offset :offset''', {
'song_id': song_id, 'difficulty': difficulty, 'limit': limit, 'offset': amount - limit})
x = c.fetchall()
if x != []:
rank = amount - limit
for i in x:
rank += 1
y = get_score(c, i[0], song_id, difficulty)
y['rank'] = rank
r.append(y)
else: else:
c.execute('''select user_id from best_score where song_id = :song_id and difficulty = :difficulty order by score DESC, time_played DESC limit :limit offset :offset''', { c.execute('''select user_id from best_score where song_id = :song_id and difficulty = :difficulty order by score DESC, time_played DESC limit :limit offset :offset''', {
'song_id': song_id, 'difficulty': difficulty, 'limit': limit, 'offset': 9998-limit}) 'song_id': song_id, 'difficulty': difficulty, 'limit': limit, 'offset': 9998-limit})
@@ -553,6 +569,14 @@ def arc_score_check(user_id, song_id, difficulty, score, shiny_perfect_count, pe
if abs(ascore - score) >= 5: if abs(ascore - score) >= 5:
return False return False
with Connect() as c: # 歌曲谱面MD5检查服务器没有谱面就不管了
c.execute('''select md5 from songfile where song_id=:a and file_type=:b''', {
'a': song_id, 'b': int(difficulty)})
x = c.fetchone()
if x:
if x[0] != song_hash:
return False
x = song_token + song_hash + song_id + str(difficulty) + str(score) + str(shiny_perfect_count) + str( x = song_token + song_hash + song_id + str(difficulty) + str(score) + str(shiny_perfect_count) + str(
perfect_count) + str(near_count) + str(miss_count) + str(health) + str(modifier) + str(clear_type) perfect_count) + str(near_count) + str(miss_count) + str(health) + str(modifier) + str(clear_type)
y = str(user_id) + song_hash y = str(user_id) + song_hash
@@ -579,10 +603,10 @@ def arc_all_get(user_id):
scores_data = [] scores_data = []
clearlamps_data = [] clearlamps_data = []
clearedsongs_data = [] clearedsongs_data = []
# unlocklist_data = [] unlocklist_data = []
installid_data = '' installid_data = ''
devicemodelname_data = '' devicemodelname_data = ''
# story_data = [] story_data = []
createdAt = 0 createdAt = 0
with Connect() as c: with Connect() as c:
@@ -594,17 +618,16 @@ def arc_all_get(user_id):
scores_data = json.loads(x[1])[""] scores_data = json.loads(x[1])[""]
clearlamps_data = json.loads(x[2])[""] clearlamps_data = json.loads(x[2])[""]
clearedsongs_data = json.loads(x[3])[""] clearedsongs_data = json.loads(x[3])[""]
# unlocklist_data = json.loads(x[4])[""] unlocklist_data = json.loads(x[4])[""]
installid_data = json.loads(x[5])["val"] installid_data = json.loads(x[5])["val"]
devicemodelname_data = json.loads(x[6])["val"] devicemodelname_data = json.loads(x[6])["val"]
# story_data = json.loads(x[7])[""] story_data = json.loads(x[7])[""]
if x[8]: if x[8]:
createdAt = int(x[8]) createdAt = int(x[8])
return { if Config.SAVE_FULL_UNLOCK:
"user_id": user_id, installid_data = "0fcec8ed-7b62-48e2-9d61-55041a22b123"
"story": { story_data = [{
"": [{
"ma": 1, "ma": 1,
"mi": 1, "mi": 1,
"c": True, "c": True,
@@ -920,16 +943,7 @@ def arc_all_get(user_id):
"c": True, "c": True,
"r": True "r": True
}] }]
}, unlocklist_data = [{
"devicemodelname": {
"val": devicemodelname_data
},
"installid": {
# installid_data 这里如果不固定可能会导致arcaea以为数据一样而不更新
"val": "0fcec8ed-7b62-48e2-9d61-55041a22b123"
},
"unlocklist": {
"": [{
"unlock_key": "worldvanquisher|2|0", "unlock_key": "worldvanquisher|2|0",
"complete": 1 "complete": 1
}, { }, {
@@ -1509,7 +1523,22 @@ def arc_all_get(user_id):
"unlock_key": "anokumene|1|0", "unlock_key": "anokumene|1|0",
"complete": 1 "complete": 1
}] }]
}, "clearedsongs": {
return {
"user_id": user_id,
"story": {
"": story_data
},
"devicemodelname": {
"val": devicemodelname_data
},
"installid": {
"val": installid_data
},
"unlocklist": {
"": unlocklist_data
},
"clearedsongs": {
"": clearedsongs_data "": clearedsongs_data
}, },
"clearlamps": { "clearlamps": {

View File

@@ -168,6 +168,7 @@ def auth_required(request):
user_id = None user_id = None
with Connect() as c: with Connect() as c:
headers = request.headers headers = request.headers
if 'Authorization' in headers:
token = headers['Authorization'] token = headers['Authorization']
token = token[7:] token = token[7:]
user_id = token_get_id(token) user_id = token_get_id(token)

View File

@@ -1,6 +1,7 @@
from server.sql import Connect from server.sql import Connect
import server.arcworld import server.arcworld
import server.arcpurchase import server.arcpurchase
import server.arcdownload
import time import time
from setting import Config from setting import Config
@@ -198,7 +199,7 @@ def get_value_0(c, user_id):
"max_stamina_ts": 1586274871917, "max_stamina_ts": 1586274871917,
"stamina": 12, "stamina": 12,
"world_unlocks": ["scenery_chap1", "scenery_chap2", "scenery_chap3", "scenery_chap4", "scenery_chap5"], "world_unlocks": ["scenery_chap1", "scenery_chap2", "scenery_chap3", "scenery_chap4", "scenery_chap5"],
"world_songs": ["babaroque", "shadesoflight", "kanagawa", "lucifer", "anokumene", "ignotus", "rabbitintheblackroom", "qualia", "redandblue", "bookmaker", "darakunosono", "espebranch", "blacklotus", "givemeanightmare", "vividtheory", "onefr", "gekka", "vexaria3", "infinityheaven3", "fairytale3", "goodtek3", "suomi", "rugie", "faintlight", "harutopia", "goodtek", "dreaminattraction", "syro", "diode", "freefall", "grimheart", "blaster", "cyberneciacatharsis", "monochromeprincess", "revixy", "vector", "supernova", "nhelv", "purgatorium3", "dement3", "crossover", "guardina", "axiumcrisis", "worldvanquisher", "sheriruth", "pragmatism", "gloryroad", "etherstrike", "corpssansorganes", "lostdesire", "blrink", "essenceoftwilight", "lapis", "solitarydream", "lumia3", "purpleverse", "moonheart3", "glow", "enchantedlove", "take"], "world_songs": ["babaroque", "shadesoflight", "kanagawa", "lucifer", "anokumene", "ignotus", "rabbitintheblackroom", "qualia", "redandblue", "bookmaker", "darakunosono", "espebranch", "blacklotus", "givemeanightmare", "vividtheory", "onefr", "gekka", "vexaria3", "infinityheaven3", "fairytale3", "goodtek3", "suomi", "rugie", "faintlight", "harutopia", "goodtek", "dreaminattraction", "syro", "diode", "freefall", "grimheart", "blaster", "cyberneciacatharsis", "monochromeprincess", "revixy", "vector", "supernova", "nhelv", "purgatorium3", "dement3", "crossover", "guardina", "axiumcrisis", "worldvanquisher", "sheriruth", "pragmatism", "gloryroad", "etherstrike", "corpssansorganes", "lostdesire", "blrink", "essenceoftwilight", "lapis", "solitarydream", "lumia3", "purpleverse", "moonheart3", "glow", "enchantedlove", "take", "lifeispiano"],
"singles": get_user_singles(c, user_id), "singles": get_user_singles(c, user_id),
"packs": get_user_packs(c, user_id), "packs": get_user_packs(c, user_id),
"characters": characters, "characters": characters,
@@ -226,7 +227,7 @@ def arc_aggregate_small(user_id):
def arc_aggregate_big(user_id): def arc_aggregate_big(user_id):
# 返回用户数据和地图歌曲信息 # 返回比较全的用户数据
r = {"success": False} r = {"success": False}
with Connect() as c: with Connect() as c:
r = {"success": True, r = {"success": True,
@@ -238,7 +239,7 @@ def arc_aggregate_big(user_id):
"value": server.arcpurchase.get_item(c, 'pack') "value": server.arcpurchase.get_item(c, 'pack')
}, { }, {
"id": 2, "id": 2,
"value": {} "value": server.arcdownload.get_all_songs(user_id, url_flag=False)
}, { }, {
"id": 3, "id": 3,
"value": { "value": {

View File

@@ -0,0 +1,29 @@
import os
def check_before_run(app):
# 运行前检查关键文件,返回布尔值,其实是因为有人经常忘了
f = True
if not os.path.exists('setting.py'):
app.logger.warning('File `setting.py` is missing.')
f = False
if not os.path.exists('database'):
app.logger.warning('Folder `database` is missing.')
f = False
if not os.path.exists('database/songs'):
app.logger.warning('Folder `database/songs` is missing.')
f = False
if not os.path.exists('database/arcaea_database.db'):
app.logger.warning('File `database/arcaea_database.db` is missing.')
f = False
if not os.path.exists('database/arcsong.db'):
app.logger.warning('File `database/arcsong.db` is missing.')
f = False
return f

View File

@@ -14,6 +14,19 @@ class Config():
-------------------- --------------------
''' '''
'''
--------------------
SSL证书路径
留空则使用HTTP
SSL certificate path
If left blank, use HTTP.
'''
SSL_CERT = '' # *.pem
SSL_KEY = '' # *.key
'''
--------------------
'''
''' '''
-------------------- --------------------
愚人节模式开关 愚人节模式开关
@@ -46,6 +59,17 @@ class Config():
-------------------- --------------------
''' '''
'''
--------------------
歌曲下载地址前缀,留空则自动获取
Song download address prefix
If left blank, it will be obtained automatically.
'''
DOWNLOAD_LINK_PREFIX = '' # http://***.com/download/
'''
--------------------
'''
''' '''
-------------------- --------------------
玩家歌曲下载的24小时次数限制每个文件算一次 玩家歌曲下载的24小时次数限制每个文件算一次
@@ -95,3 +119,13 @@ class Config():
''' '''
-------------------- --------------------
''' '''
'''
--------------------
是否强制使用全解锁云端存档
If forcing full unlocked cloud save is enabled
'''
SAVE_FULL_UNLOCK = False
'''
--------------------
'''