This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository minilauncher-for-slippi.

View the commit online.

commit 77be294f2abecc3b9d069a97b670d18af3fd9843
Author: Nekobit <m...@ow.nekobit.net>
AuthorDate: Sun Sep 17 15:42:15 2023 -0400

    File2c, some queries
---
 .gitignore                                         |  6 +-
 Makefile                                           | 12 +++-
 file-to-c/main.c                                   | 55 ++++++++++++++++
 gg.c                                               | 38 +++++++----
 ...r4slippi.cfg => minilauncher4slippi.cfg.COPY_ME |  2 +-
 static/tourney_query.json                          | 75 ++++++++++++++++++++++
 6 files changed, 174 insertions(+), 14 deletions(-)

diff --git a/.gitignore b/.gitignore
index 5180efd..a7924b1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@
 replays
 dolphin-emu
 minilauncher4slippi
+minilauncher4slippi.cfg
 *.core
 portable.txt
 traversal_server
@@ -9,7 +10,10 @@ User
 Sys
 *.iso
 *.ciso
-*.json
+play.json
+static/sample.json
+static/*.h
+filec
 scripts/build.log
 scripts/Ishiiruka
 scripts/work
diff --git a/Makefile b/Makefile
index f8f6dbf..d370cc0 100644
--- a/Makefile
+++ b/Makefile
@@ -2,9 +2,19 @@ CC=cc
 CFLAGS=--std=c99 -g `pkg-config --cflags efl ecore elementary libusb-1.0` `sdl2-config --cflags` 
 LDFLAGS=`pkg-config --libs efl ecore elementary libusb-1.0` `sdl2-config --libs` -lcjson
 OBJS=main.o replay.o home.o input.o http.o gg.o
+CHEAD=static/tourney_query.json
+CHEAD_C=static/tourney_query.json.h
+
+all: filec $(CHEAD_C) minilauncher4slippi
+
+filec: file-to-c/main.o
+	$(CC) -o filec file-to-c/main.o
+	
+$(CHEAD_C): $(CHEAD)
+	./filec static/tourney_query.json data_tourney_query_tt > $@
 
 minilauncher4slippi: $(OBJS)
 	$(CC) -o minilauncher4slippi $(OBJS) $(LDFLAGS)
 
 clean:
-	rm minilauncher4slippi *.o
+	rm minilauncher4slippi filec *.o static/*.h
diff --git a/file-to-c/main.c b/file-to-c/main.c
new file mode 100644
index 0000000..a95b672
--- /dev/null
+++ b/file-to-c/main.c
@@ -0,0 +1,55 @@
+// I can and WILL segfault
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+enum args
+{
+    ARG_FILENAME = 1,
+    ARG_VARIABLE
+};
+
+long filesize(FILE* file)
+{
+    long orig = ftell(file);
+    fseek(file, 0, SEEK_END);
+    long size = ftell(file);
+    fseek(file, orig, SEEK_SET);
+    return size;
+}
+
+int main(int argc, char** argv)
+{
+    char* buf;
+    FILE* file = fopen(argv[ARG_FILENAME], "rb");
+
+    long size = filesize(file);
+
+    if (!(buf = malloc(size)))
+    {
+        perror("malloc");
+        return 1;
+    }
+
+    if (fread(buf, 1, size, file) != size)
+    {
+        fputs("Didn't read correctly!", stderr);
+        free(buf);
+        return 1;
+    }
+
+    fclose(file);
+
+    printf("#ifndef __%s\n", argv[ARG_VARIABLE]);
+    printf("#define __%s\n", argv[ARG_VARIABLE]);
+    printf("static size_t %s_size = %ld;\n", argv[ARG_VARIABLE], size);
+    printf("static const char %s[] = {", argv[ARG_VARIABLE]);
+    for (size_t i = 0; i < size; ++i)
+    {
+        printf("0X%hhX,", buf[i]);
+    }
+    puts("0};\n#endif");
+    
+    free(buf);
+    return 0;
+}
diff --git a/gg.c b/gg.c
index 98d66c2..02fe076 100644
--- a/gg.c
+++ b/gg.c
@@ -2,11 +2,18 @@
 #include "gg.h"
 #include "http.h"
 
+// Static
+#include "static/tourney_query.json.h"
+
 Evas_Object* tab_gg = NULL;
 static Evas_Object* tab_gg_sidebar;
 static Evas_Object* tab_gg_content;
 extern char* start_gg_api;
 
+static int player_id;
+
+#define UserTourneysQuery 
+
 static void
 _gg_sidebar_cb(void *_data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
 {
@@ -31,9 +38,6 @@ _gg_scrape_result(void *data EINA_UNUSED, int type EINA_UNUSED, void *event_info
 		return EINA_FALSE;
 	*end_json = '\0';
 #undef magiccode
-
-	puts(start_json);
-
 	// Data required is scraped now!
 	cJSON* json = cJSON_Parse(start_json);
 	if (!json)
@@ -47,12 +51,30 @@ _gg_scrape_result(void *data EINA_UNUSED, int type EINA_UNUSED, void *event_info
 	cJSON* currentUserFetchSpec = cJSON_GetObjectItemCaseSensitive(
 	                                  pageProps, "currentUserFetchSpec");
 	cJSON* entities = cJSON_GetObjectItemCaseSensitive(currentUserFetchSpec, "entities");
-	cJSON* tournament = cJSON_GetObjectItemCaseSensitive(entities, "tournament");
+	cJSON* users = cJSON_GetObjectItemCaseSensitive(entities, "users");
+	
+	cJSON* jplayer_id = cJSON_GetObjectItemCaseSensitive(users, "id");
+	if (jplayer_id)
+		player_id = jplayer_id->valueint;
+	
+	// Now attempt another request
+	
+#if 0
 	int i = 0;
 	for (cJSON* c = tournament->child; c->next != NULL; (++i, c = c->next))
 	{
 		printf("name: %s\n", cJSON_GetObjectItemCaseSensitive(c, "name")->valuestring);
 	}
+#endif
+}
+
+static void
+_gg_set_token(Ecore_Con_Url* ec_url, char* token)
+{
+	Eina_Strbuf* sesh = eina_strbuf_new();
+	eina_strbuf_append_printf(sesh, "gg_session=%s;", token);
+	ecore_con_url_additional_header_add(ec_url, "Cookie", eina_strbuf_string_get(sesh));
+	free(eina_strbuf_release(sesh));
 }
 
 static void
@@ -63,13 +85,7 @@ _gg_scrape_homepage(char* token)
 	ecore_event_handler_add(ECORE_CON_EVENT_URL_DATA, memory_chunk_data, NULL);
 	ecore_event_handler_add(ECORE_CON_EVENT_URL_COMPLETE, _gg_scrape_result, NULL);
 	ecore_con_url_additional_header_add(ec_url, "User-Agent", ":^)'); DROP TABLE users; --");
-	ecore_con_url_additional_header_add(ec_url, "Accept", "*/*");
-
-	// "API" Token
-	Eina_Strbuf* sesh = eina_strbuf_new();
-	eina_strbuf_append_printf(sesh, "gg_session=%s;", token);
-	ecore_con_url_additional_header_add(ec_url, "Cookie", eina_strbuf_string_get(sesh));
-	free(eina_strbuf_release(sesh));
+	_gg_set_token(ec_url, token);
 
 	ecore_con_url_get(ec_url);
 }
diff --git a/minilauncher4slippi.cfg b/minilauncher4slippi.cfg.COPY_ME
similarity index 58%
rename from minilauncher4slippi.cfg
rename to minilauncher4slippi.cfg.COPY_ME
index dc12a9c..49fb9aa 100644
--- a/minilauncher4slippi.cfg
+++ b/minilauncher4slippi.cfg.COPY_ME
@@ -1,4 +1,4 @@
 SSBM.iso
 slippi-netplay-dolphin
 slippi-playback-dolphin
-37f23dbe87a3ed1abd77df833fbf6088
+[[ Your start.gg website token here ]]
diff --git a/static/tourney_query.json b/static/tourney_query.json
new file mode 100644
index 0000000..f2e4fe1
--- /dev/null
+++ b/static/tourney_query.json
@@ -0,0 +1,75 @@
+[{"operationName":"UserTournaments","variables":{"userId":%d,"upcomingQuery":{"perPage":3,"filter":{"upcoming":true},"sortBy":"startDate ASC"},"pastQuery":{"perPage":3,"filter":{"past":true},"sortBy":"startDate DESC"}},"query":"query UserTournaments($userId: ID!, $upcomingQuery: PlayerScheduleQuery, $pastQuery: PlayerScheduleQuery) {
+  user(id: $userId) {
+    ...userTournaments
+    __typename
+  }
+}
+
+fragment userTournaments on User {
+  id
+  player {
+    id
+    upcomingAdminSchedule: adminSchedule(query: $upcomingQuery) {
+      nodes {
+        id
+        entity {
+          ...tournamentInfo
+          __typename
+        }
+        __typename
+      }
+      __typename
+    }
+    pastAdminSchedule: adminSchedule(query: $pastQuery) {
+      nodes {
+        id
+        entity {
+          ...tournamentInfo
+          __typename
+        }
+        __typename
+      }
+      __typename
+    }
+    __typename
+  }
+  discriminator
+  __typename
+}
+
+fragment tournamentInfo on Tournament {
+  id
+  name
+  slug
+  images(type: \"profile\") {
+    id
+    type
+    url
+    __typename
+  }
+  startAt
+  endAt
+  isOnline
+  locationDisplayName
+  userIsAdmin(userId: $userId)
+  userParticipant(userId: $userId) {
+    id
+    events {
+      id
+      isCompleted
+      videogame {
+        id
+        name
+        __typename
+      }
+      __typename
+    }
+    entrants {
+      id
+      __typename
+    }
+    __typename
+  }
+  __typename
+}
+"}]

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to