first commit
This commit is contained in:
commit
93cbf7c87b
1
.clang-format
Normal file
1
.clang-format
Normal file
@ -0,0 +1 @@
|
||||
BasedOnStyle: Microsoft
|
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
build/
|
||||
.vscode/
|
||||
.idea/
|
||||
.cache/
|
||||
build/
|
||||
.venv/
|
||||
venv/
|
47
CMakeLists.txt
Normal file
47
CMakeLists.txt
Normal file
@ -0,0 +1,47 @@
|
||||
cmake_minimum_required(VERSION 3.30)
|
||||
project(Live\ Parise C)
|
||||
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
add_compile_options(
|
||||
-Wall
|
||||
-Wextra
|
||||
-O2
|
||||
-g3
|
||||
-fsanitize=address
|
||||
-fsanitize=undefined
|
||||
-fno-omit-frame-pointer
|
||||
)
|
||||
|
||||
add_link_options(
|
||||
-fsanitize=address
|
||||
-fsanitize=undefined
|
||||
)
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
# For CURL
|
||||
set(BUILD_STATIC_LIBS ON)
|
||||
|
||||
# For cJSON
|
||||
set(BUILD_SHARED_AND_STATIC_LIBS ON)
|
||||
set(ENABLE_CUSTOM_COMPILER_FLAGS OFF)
|
||||
|
||||
FetchContent_Declare(
|
||||
cJSON
|
||||
GIT_REPOSITORY https://github.com/DaveGamble/cJSON.git
|
||||
GIT_TAG v1.7.18
|
||||
)
|
||||
|
||||
FetchContent_Declare(
|
||||
curl
|
||||
GIT_REPOSITORY https://github.com/curl/curl.git
|
||||
GIT_TAG curl-8_9_1
|
||||
)
|
||||
|
||||
FetchContent_MakeAvailable(cJSON curl)
|
||||
|
||||
add_executable(main main.c)
|
||||
target_include_directories(main PUBLIC ${cJSON_SOURCE_DIR})
|
||||
target_link_libraries(main cjson libcurl)
|
7
LICENCE
Normal file
7
LICENCE
Normal file
@ -0,0 +1,7 @@
|
||||
Copyright © 2024 Jeffrey Hsu
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
24
README.md
Normal file
24
README.md
Normal file
@ -0,0 +1,24 @@
|
||||
## Live Parise
|
||||
|
||||
### How to build
|
||||
|
||||
```bash
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --target main
|
||||
```
|
||||
|
||||
### Usage
|
||||
|
||||
```bash
|
||||
./main [thread number] # default is 4
|
||||
```
|
||||
|
||||
### Modify
|
||||
|
||||
Set these vars to you need
|
||||
|
||||
```c
|
||||
const char SUBROOMID[] = ""; // at line 43 in main.c
|
||||
const char SS[] = "";
|
||||
```
|
191
main.c
Normal file
191
main.c
Normal file
@ -0,0 +1,191 @@
|
||||
#include <cJSON.h>
|
||||
#include <curl/curl.h>
|
||||
#include <curl/easy.h>
|
||||
#include <pthread.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define REGEN_ENC_URL_F(u, timestamp) \
|
||||
{ \
|
||||
sprintf(u, ENC_URL, SUBROOMID, timestamp, SS); \
|
||||
}
|
||||
|
||||
#define REGEN_URL_F(u, enc, timestamp) \
|
||||
{ \
|
||||
sprintf(u, URL, SUBROOMID, enc, timestamp); \
|
||||
}
|
||||
|
||||
#ifdef Debug
|
||||
#define DPRINT(s, ...) \
|
||||
{ \
|
||||
printf(s, ...); \
|
||||
}
|
||||
#else
|
||||
#define DPRINT(s, ...)
|
||||
#endif
|
||||
|
||||
struct memory
|
||||
{
|
||||
char *response;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
CURLcode curl_get(const char *, struct memory *);
|
||||
long long current_timestamp();
|
||||
size_t cb(char *, size_t, size_t, void *);
|
||||
char *get_enc();
|
||||
void parise(void *);
|
||||
|
||||
const char ENC_URL[] = "https://lbapi-rk.chaoxing.com/lb/parise/enc/get?subRoomId=%s×tamp=%llu&ss=%s";
|
||||
const char URL[] = "https://zhibo.chaoxing.com/apis/live/setLivePariseCountByEnc?subroomId=%s&enc=%s×tamp=%llu";
|
||||
const char SUBROOMID[] = "381236458034402305";
|
||||
const char SS[] = "381237373432790016";
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int thread;
|
||||
|
||||
if (argc < 2)
|
||||
thread = 4;
|
||||
else
|
||||
thread = atoi(argv[1]);
|
||||
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
|
||||
printf("线程\t状态\t点赞量\n");
|
||||
|
||||
pthread_t **thread_pool = malloc(sizeof(pthread_t *) * thread);
|
||||
|
||||
for (int i = 0; i < thread; i++)
|
||||
{
|
||||
thread_pool[i] = malloc(sizeof(pthread_t));
|
||||
pthread_create(thread_pool[i], NULL, (void *)&parise, (void *)i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < thread; i++)
|
||||
{
|
||||
pthread_join(*thread_pool[i], NULL);
|
||||
}
|
||||
|
||||
curl_global_cleanup();
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
free(thread_pool[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
CURLcode curl_get(const char *const url, struct memory *chunk)
|
||||
{
|
||||
int status;
|
||||
CURL *curl = NULL;
|
||||
struct curl_slist *headers = NULL;
|
||||
|
||||
curl = curl_easy_init();
|
||||
|
||||
if (curl == NULL)
|
||||
return CURLE_FAILED_INIT;
|
||||
|
||||
headers = curl_slist_append(headers, "Accept: application/json, text/javascript, */*; q=0.01");
|
||||
headers = curl_slist_append(headers, "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like "
|
||||
"Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0");
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url);
|
||||
curl_easy_setopt(curl, CURLOPT_USE_SSL, true);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cb);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)chunk);
|
||||
|
||||
status = curl_easy_perform(curl);
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_slist_free_all(headers);
|
||||
return status;
|
||||
}
|
||||
|
||||
long long current_timestamp()
|
||||
{
|
||||
time_t timestamp = time(NULL);
|
||||
return timestamp * 1000;
|
||||
}
|
||||
|
||||
size_t cb(char *data, size_t size, size_t nmemb, void *clientp)
|
||||
{
|
||||
size_t realsize = size * nmemb;
|
||||
struct memory *mem = (struct memory *)clientp;
|
||||
|
||||
char *ptr = realloc(mem->response, mem->size + realsize + 1);
|
||||
if (!ptr)
|
||||
return 0; /* out of memory! */
|
||||
|
||||
mem->response = ptr;
|
||||
memcpy(&(mem->response[mem->size]), data, realsize);
|
||||
mem->size += realsize;
|
||||
mem->response[mem->size] = 0;
|
||||
|
||||
return realsize;
|
||||
}
|
||||
|
||||
char *get_enc()
|
||||
{
|
||||
char url[200];
|
||||
char *ret = NULL;
|
||||
struct memory data = {0};
|
||||
const cJSON *enc = NULL;
|
||||
|
||||
REGEN_ENC_URL_F(url, current_timestamp());
|
||||
curl_get(url, &data);
|
||||
|
||||
DPRINT("%s\n", data.response);
|
||||
|
||||
cJSON *data_json = cJSON_Parse(data.response);
|
||||
enc = cJSON_GetObjectItemCaseSensitive(data_json, "enc");
|
||||
|
||||
const size_t s = strlen(enc->valuestring);
|
||||
ret = malloc(s + 1);
|
||||
memcpy(ret, enc->valuestring, s + 1);
|
||||
|
||||
free(data.response);
|
||||
cJSON_Delete(data_json);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// {'data': 293687, 'msg': '操作成功', 'result': 1}
|
||||
void parise(void *arg)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
char url[200];
|
||||
const int idx = (int)arg;
|
||||
struct memory json_c = {0};
|
||||
const char *enc = get_enc();
|
||||
const cJSON *result = NULL;
|
||||
const cJSON *msg = NULL;
|
||||
const cJSON *data = NULL;
|
||||
const cJSON *errorMsg = NULL;
|
||||
cJSON *json = NULL;
|
||||
|
||||
REGEN_URL_F(url, enc, current_timestamp());
|
||||
curl_get(url, &json_c);
|
||||
|
||||
json = cJSON_Parse(json_c.response);
|
||||
result = cJSON_GetObjectItemCaseSensitive(json, "result");
|
||||
msg = cJSON_GetObjectItemCaseSensitive(json, "msg");
|
||||
data = cJSON_GetObjectItemCaseSensitive(json, "data");
|
||||
errorMsg = cJSON_GetObjectItemCaseSensitive(json, "errorMsg");
|
||||
|
||||
if (result->valueint == 1)
|
||||
printf("\rT%d\t%s\t%d", idx, msg->valuestring, data->valueint);
|
||||
else
|
||||
printf("\rT%d\t%s", idx, errorMsg->valuestring);
|
||||
fflush(stdout);
|
||||
|
||||
free((void *)enc);
|
||||
free(json_c.response);
|
||||
|
||||
cJSON_Delete(json);
|
||||
}
|
||||
}
|
61
main.py
Normal file
61
main.py
Normal file
@ -0,0 +1,61 @@
|
||||
import requests
|
||||
import datetime
|
||||
import time
|
||||
import threading
|
||||
|
||||
enc_url = "https://lbapi-rk.chaoxing.com/lb/parise/enc/get"
|
||||
url = "https://zhibo.chaoxing.com/apis/live/setLivePariseCountByEnc"
|
||||
sub_room_id = "381236458034402305"
|
||||
ss = "381237373432790016"
|
||||
|
||||
print(int(datetime.datetime.now().timestamp()) * 1000)
|
||||
|
||||
def parise(thread_name = 0):
|
||||
while (1):
|
||||
try:
|
||||
timestamp = int(datetime.datetime.now().timestamp()) * 1000
|
||||
|
||||
enc = requests.get(
|
||||
url=enc_url,
|
||||
params={
|
||||
"subRoomId": sub_room_id,
|
||||
"timestamp": timestamp,
|
||||
"ss": ss
|
||||
},
|
||||
cookies={
|
||||
"route": "fc156df5eb135d4b66fe10961ebe406f"
|
||||
},
|
||||
headers= {
|
||||
"Accept": "application/json, text/javascript, */*; q=0.01",
|
||||
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0"
|
||||
}
|
||||
).json()["enc"]
|
||||
|
||||
r = requests.get(
|
||||
url = url,
|
||||
params = {
|
||||
"subroomId": sub_room_id,
|
||||
"enc": enc,
|
||||
"timestamp": timestamp
|
||||
},
|
||||
cookies={
|
||||
"route": "fc156df5eb135d4b66fe10961ebe406f"
|
||||
},
|
||||
headers= {
|
||||
"Accept": "application/json, text/javascript, */*; q=0.01",
|
||||
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0"
|
||||
}
|
||||
)
|
||||
|
||||
print("\r{}\t{}\t{}".format(thread_name, r.status_code, r.json()["data"]), end="")
|
||||
print(r.json());
|
||||
except Exception as e:
|
||||
continue
|
||||
|
||||
thread_list = []
|
||||
for i in range(200):
|
||||
thread_list.append(threading.Thread(target=parise, args=(f"{i}", )))
|
||||
|
||||
print("线程号\t响应码\t点赞量")
|
||||
for i in thread_list:
|
||||
i.start()
|
Loading…
x
Reference in New Issue
Block a user