diff options
| author | Pinapelz <yukais@pinapelz.com> | 2025-05-25 01:45:14 -0700 |
|---|---|---|
| committer | Pinapelz <yukais@pinapelz.com> | 2025-05-25 01:45:14 -0700 |
| commit | bef905d2a9c159c954963541f53de69258689cb8 (patch) | |
| tree | e6e88e10e72338d89558a5e5d5d7ac48b9d7293c | |
| parent | cbb6a4a913f57711fe0e372b1f02b712ead27bcf (diff) | |
sdvx_eamuse: add option to auto pull date data with cookie header
| -rw-r--r-- | sdvx/eamuse_csv/README.md | 1 | ||||
| -rw-r--r-- | sdvx/eamuse_csv/sdvx_csv_to_tachi.py | 27 |
2 files changed, 28 insertions, 0 deletions
diff --git a/sdvx/eamuse_csv/README.md b/sdvx/eamuse_csv/README.md index 37b2486..c20be23 100644 --- a/sdvx/eamuse_csv/README.md +++ b/sdvx/eamuse_csv/README.md @@ -47,6 +47,7 @@ https://p.eagate.573.jp/game/sdvx/vi/playdata/profile/index.html | `--time` | `-t` | UNIX time (in milliseconds) that should be added to the scores. Defaults to current UNIX time | `None` | | `--date_file` | `-d` | SDVX e-amusement profile site saved HTML. See README in sdvx/eamuse_csv for instructions. Overrides with --time input if missing | — | | `--timezone` | `-tz` | Only needed if -d is used, specifies what timezone to convert to | — | +| `--cookie` | `-c` | Automatically pull profile data from e-amusement using cookie | — | ## `eamuse_merge_to_csv` diff --git a/sdvx/eamuse_csv/sdvx_csv_to_tachi.py b/sdvx/eamuse_csv/sdvx_csv_to_tachi.py index 2e92534..b6eb8fa 100644 --- a/sdvx/eamuse_csv/sdvx_csv_to_tachi.py +++ b/sdvx/eamuse_csv/sdvx_csv_to_tachi.py @@ -2,6 +2,7 @@ import csv import json import argparse import time +import requests DIFFICULTY_MAPPING = { "NOVICE": "NOV", @@ -23,6 +24,28 @@ LAMP_MAPPING = { "EXCESSIVE COMPLETE": "EXCESSIVE CLEAR" } +GAME_DATA = { + "EXCEED_GEAR": { + "PROFILE_URL": "https://p.eagate.573.jp/game/sdvx/vi/playdata/profile/index.html" + } +} + +def get_site_data_with_cookie(url, cookie_header): + cookies = {} + for cookie in cookie_header.split(";"): + name, value = cookie.strip().split("=", 1) + cookies[name] = value + headers = { + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36", + "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8", + "Accept-Language": "en-US,en;q=0.5", + "Connection": "keep-alive", + "Upgrade-Insecure-Requests": "1", + } + response = requests.get(url, cookies=cookies, headers=headers) + response.raise_for_status() + return response.text + def create_date_dict(game_ver:str, raw_site_data: str) -> dict: from bs4 import BeautifulSoup from datetime import datetime @@ -123,6 +146,7 @@ if __name__ == "__main__": parser.add_argument("-t", "--time", help="UNIX time (in milliseconds) that should be added to the scores. Defaults to current UNIX time", default=None) parser.add_argument("-d", "--date_file", help="SDVX e-amusement profile site saved HTML. See README in sdvx/eamuse_csv for instructions. Overrides with --time input if missing", required=False) parser.add_argument("-tz", "--timezone", help="Only needed if -d is used, specifies what timezone to convert to", required=False) + parser.add_argument("-c", "--cookie", help="Pass in a cookie header to automatically pull date data") args = parser.parse_args() assert args.game in ["EXCEED_GEAR"] curr_time = int(time.time() * 1000) if (args.time == "now" or args.time is None) else args.time @@ -136,6 +160,9 @@ if __name__ == "__main__": with open(args.date_file, "r") as file: site_data = file.read() date_data = create_date_dict(args.game, site_data) + elif args.cookie: + site_data = get_site_data_with_cookie(GAME_DATA[args.game]["PROFILE_URL"]) + date_data = create_date_dict(args.game, site_data) try: output_json = convert_sdvx_csv_to_tachi_json(args.csv_filename, "sdvx", "Single", args.service, curr_time, date_data) |
