Browse Source

Improve manga autofill

Eva 5 years 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
   }
78
   }
79
 
79
 
80
   $title = html_entity_decode($json['title'], ENT_QUOTES);
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
   $title_jp = html_entity_decode($json['title_jpn'], ENT_QUOTES);
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
   $json_str = [
98
   $json_str = [
88
     'id'          => $gid,
99
     'id'          => $gid,
89
     'title'       => $title,
100
     'title'       => $title,
101
+    'title_rj'    => $title_rj,
90
     'title_jp'    => $title_jp,
102
     'title_jp'    => $title_jp,
91
     'artists'     => $artists,
103
     'artists'     => $artists,
92
     'circle'      => $circle,
104
     'circle'      => $circle,

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

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

Loading…
Cancel
Save