forked from gabriel-kaam/chat-gpt-prompts-from-aiprm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.php
54 lines (43 loc) · 1.31 KB
/
update.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
function sanitize($string) {
$string = str_replace([
'&'
], [
'and'
], $string);
$string = preg_replace('/[^a-zA-Z0-9 \-,]/', '', $string);
$string = trim($string);
return $string;
}
function file_content_from_prompt($prompt) {
$prompt->Teaser = trim($prompt->Teaser);
return <<<EOF
AuthorName: {$prompt->AuthorName}
AuthorURL: {$prompt->AuthorURL}
Title: {$prompt->Title}
Category: {$prompt->Category}
Teaser: {$prompt->Teaser}
Community: {$prompt->Community}
CreationTime: {$prompt->CreationTime}
Help: {$prompt->Help}
ID: {$prompt->ID}
OwnPrompt: {$prompt->OwnPrompt}
PromptHint: {$prompt->PromptHint}
PromptPackageID: {$prompt->PromptPackageID}
PromptTypeNo": {$prompt->PromptTypeNo}
RevisionTime: {$prompt->RevisionTime}
Usages: {$prompt->Usages}
Views: {$prompt->Views}
Votes: {$prompt->Votes}
Prompt:
{$prompt->Prompt}
EOF;
}
$prompts = json_decode(file_get_contents('https://api.aiprm.com/api2/Prompts?Community=&Limit=10&Offset=0&OwnerExternalID=user-Sym2oNwW2gUBywbi1gqkKPyB&OwnerExternalSystemNo=1&SortModeNo=2'));
foreach ($prompts as $prompt) {
list($topic, ) = explode('-', $prompt->Community, 2);
$path = "prompts/$topic/{$prompt->Category}";
$name = strtolower(sanitize($prompt->Title));
@mkdir($path, 0777, true);
file_put_contents("$path/$name.txt", file_content_from_prompt($prompt));
}