Browse Source

Merge branch 'fix-jdb-autofill' of xoru/Gazelle into master

spaghetti 6 months ago
parent
commit
4946549497
1 changed files with 77 additions and 3 deletions
  1. 77
    3
      sections/ajax/autofill/jav.php

+ 77
- 3
sections/ajax/autofill/jav.php View File

@@ -108,7 +108,7 @@ if (!$debug && $Cache->get_value('jav_fill_json_'.$cn)) {
108 108
   }
109 109
   if ($jdb_page) {
110 110
     if (!$title) {
111
-      $title = trim(substr($jdb->query("//h1[contains(@class, 'entry-title')]")[0]->nodeValue, strlen($cn) + 3));
111
+      $title = trim($jdb->query("//b[contains(., 'Translated Title:')]")[0]->nextSibling->nodeValue);
112 112
     }
113 113
     if (!$studio) {
114 114
       $studio = $jdb->query("//b[contains(., 'Studio:')]")[0]->nextSibling->nodeValue;
@@ -125,7 +125,7 @@ if (!$debug && $Cache->get_value('jav_fill_json_'.$cn)) {
125 125
           $idol_lower = strtolower(str_replace(' ', '-', $idol_name));
126 126
           // ensure it's actually an idol name
127 127
           if (strpos($idols_raw->attributes->item(0)->nodeValue, '.com/idols/' . $idol_lower) !== false) {
128
-            $idols[] = $idols_raw->nodeValue;
128
+            $idols[] = implode(' ', array_reverse(explode(' ', $idols_raw->nodeValue)));
129 129
           }
130 130
         }
131 131
         $idols_raw = $idols_raw->nextSibling;
@@ -135,7 +135,7 @@ if (!$debug && $Cache->get_value('jav_fill_json_'.$cn)) {
135 135
       $year = substr($jdb->query("//b[contains(., 'Release Date:')]")[0]->nextSibling->nodeValue, 1, 4);
136 136
     }
137 137
     if (!$image) {
138
-      $image = $jdb->query("//img[contains(@alt, ' download or stream.')]")->item(0)->getAttribute('src');
138
+      $image = $jdb->query("//img[@alt='" . $cn . "']")->item(0)->getAttribute('src');
139 139
     }
140 140
     if (substr($image, 0, 2) == '//') {
141 141
       $image = 'https:'.$image;
@@ -144,6 +144,80 @@ if (!$debug && $Cache->get_value('jav_fill_json_'.$cn)) {
144 144
       //Shit neither of the sites have descriptions
145 145
       $desc = '';
146 146
     }
147
+    if (!$genres) {
148
+      // Mapping of JDB genres that are different to ours.
149
+      $jdb_genre_map = [
150
+        'Actress Best Compilation' => 'compilation',
151
+        'Adultery' => 'cheating',
152
+        'Anal Sex' => 'anal',
153
+        'Big Tits' => 'big.breasts:female',
154
+        'Big Tits Lover' => 'big.breasts:female',
155
+        'Big Vibrator' => 'sex.toys',
156
+        'Bunny Girl' => 'bunny.girl',
157
+        'Cat Cosplay' => 'catgirl',
158
+        'Cheating Wife' => 'cheating',
159
+        'Chinese Dress' => 'chinese.dress',
160
+        'Creampie' => 'nakadashi',
161
+        'Cross Dresser' => 'crossdressing',
162
+        'Cum Swallowing' => 'gokkun',
163
+        'Deep Throat' => 'deepthroat',
164
+        'Drunk Girl' => 'drunk',
165
+        'Egg Vibrator' => 'sex.toys',
166
+        'Face Sitting' => 'facesitting',
167
+        'Female Ninja' => 'ninja',
168
+        'Female Teacher' => 'teacher',
169
+        'Gal' => 'gyaru:female',
170
+        'Gay' => 'yaoi:male',
171
+        'Golden Shower' => 'urination',
172
+        'Huge Tits' => 'huge.breasts',
173
+        'Hypnotism' => 'hypnosis',
174
+        'Kiss Kiss' => 'kissing',
175
+        'Leotards' => 'leotard',
176
+        'Lesbian' => 'yuri:female',
177
+        'Lesbian Kissing' => ['yuri:female', 'kissing'],
178
+        'Lotion' => 'oil',
179
+        'Massage Parlor' => 'massage',
180
+        'MILF' => 'milf:female',
181
+        'Muscular' => 'muscle',
182
+        'Naked Apron' => 'apron',
183
+        'Non-nude Erotica' => 'nonnude',
184
+        'Office Lady' => 'office.lady:female',
185
+        'Older Sister' => ['oneesan:female', 'sister:female'],
186
+        'Orgy' => 'group',
187
+        'Pregnant' => 'pregnant:female',
188
+        'Private Tutor' => 'tutor',
189
+        'Race Queen' => 'race.queen',
190
+        'Relatives' => 'incest',
191
+        'Sailor Uniform' => 'schoolgirl.uniform:female',
192
+        'School Swimsuits' => 'school.swimsuit',
193
+        'School Uniform' => 'schoolgirl.uniform:female',
194
+        'Schoolgirl' => 'schoolgirl:female',
195
+        'Sex Toys' => 'sex.toys',
196
+        'Shaved Pussy' => 'shaved:female',
197
+        'Shotacon' => 'shotacon:male',
198
+        'Sister' => 'sister:female',
199
+        'Small Tits' => 'small.breasts:female',
200
+        'Substance Use' => 'drugs',
201
+        'Swimsuits' => 'swimsuit',
202
+        'Tall Girl' => 'tall.girl',
203
+        'Threesome / Foursome' => 'threesome',
204
+        'Titty Fuck' => 'paizuri',
205
+        'Vibrator' => 'sex.toys',
206
+        'Voyeur' => 'voyeurism',
207
+        'Waitress' => 'waiter',
208
+      ];
209
+      foreach ($jdb->query("//a[@rel='tag' and starts-with(@href, 'https://www.javdatabase.com/genres/')]") as $tag) {
210
+        if (array_key_exists($tag->nodeValue, $jdb_genre_map)) {
211
+          if (is_array($jdb_genre_map[$tag->nodeValue])) {
212
+            $genres = array_merge($genres, $jdb_genre_map[$tag->nodeValue]);
213
+          } else {
214
+            $genres[] = $jdb_genre_map[$tag->nodeValue];
215
+          }
216
+        } else {
217
+          $genres[] = strtolower($tag->nodeValue);
218
+        }
219
+      }
220
+    }
147 221
   }
148 222
 
149 223
   if (!($title || $idols || $year || $studio || $label || $genres)) {

Loading…
Cancel
Save