Browse Source

Improve manga autofill

Eva 1 year ago
parent
commit
c9e665f12b
2 changed files with 17 additions and 4 deletions
  1. 16
    4
      sections/ajax/autofill/manga.php
  2. 1
    0
      static/functions/upload.js

+ 16
- 4
sections/ajax/autofill/manga.php View File

@@ -78,15 +78,27 @@ if ($Cache->get_value('manga_fill_json_'.$gid)) {
78 78
   }
79 79
 
80 80
   $title = html_entity_decode($json['title'], ENT_QUOTES);
81
-  $title = preg_replace("/\(([^()]*+|(?R))*\)/","", $title);
82
-  $title = trim(preg_replace("/\[([^\[\]]*+|(?R))*\]/","", $title));
81
+  $title = preg_replace("/^((?: ?\(.*?\) ?| ?\[.*?\] ?)*)?(.*?)((?: ?\(.*?\)| ?\[.*?\]).*)?$/", "$2", $title);
82
+  $title = trim(str_replace("’", "'", $title), " ");
83
+  $title_rj = "";
83 84
   $title_jp = html_entity_decode($json['title_jpn'], ENT_QUOTES);
84
-  $title_jp = preg_replace("/\(([^()]*+|(?R))*\)/","", $title_jp);
85
-  $title_jp = trim(preg_replace("/\[([^\[\]]*+|(?R))*\]/","", $title_jp));
85
+  $title_jp = preg_replace("/^((?: ?\(.*?\) ?| ?\[.*?\] ?)*)?(.*?)((?: ?\(.*?\)| ?\[.*?\]).*)?$/", "$2", $title_jp);
86
+  $title_jp = trim($titljp, " ");
87
+
88
+  if(strpos($title, "|") !== false) {
89
+    $titles = explode("|", $title);
90
+    $title_rj = trim($titles[0], " ");
91
+    $title = trim($titles[1], " ");
92
+  }
93
+  if($title_rj == "" && trim(preg_replace("/xxx|sex|circle|dol|[bghkmnprjcl]{1,2}([auoei]|y[auo])|[sz]{1,2}[auoe]|[dft]{1,2}[aeo]|[vw]{1,2}[ao]|([fv]{1,2}|ts|t)u|(j{1,2}|[cs]h)(i|y[auo])|y{1,2}[auo]|[auoien]|cc|s[ht]|ssh/i", "", str_replace("vol", "", preg_replace("/[^A-Za-z]/", "", strtolower($title))))) == "") {
94
+    $title_rj = $title;
95
+    $title = "";
96
+  }
86 97
 
87 98
   $json_str = [
88 99
     'id'          => $gid,
89 100
     'title'       => $title,
101
+    'title_rj'    => $title_rj,
90 102
     'title_jp'    => $title_jp,
91 103
     'artists'     => $artists,
92 104
     'circle'      => $circle,

+ 1
- 0
static/functions/upload.js View File

@@ -476,6 +476,7 @@ function JavAutofill() {
476 476
 function MangaAutofill() {
477 477
   var map = {  artists: 'idols',
478 478
               title: 'title',
479
+              title_rj: 'title_rj',
479 480
               title_jp: 'title_jp',
480 481
               year: 'year',
481 482
               tags: 'tags',

Loading…
Cancel
Save