Browse Source

Add studio and label to JDB autofill. Fix idols, year, and image.

xoru 3 years ago
parent
commit
7607f40a4d
1 changed files with 21 additions and 7 deletions
  1. 21
    7
      sections/ajax/autofill/jav.php

+ 21
- 7
sections/ajax/autofill/jav.php View File

@@ -110,19 +110,33 @@ if (!$debug && $Cache->get_value('jav_fill_json_'.$cn)) {
110 110
     if (!$title) {
111 111
       $title = substr($jdb->query('//h3')[0]->nodeValue, strlen($cn)+1);
112 112
     }
113
-    if (!idols) {
114
-      $idols_raw = $jdb->query("//div[@class='movieinfo']")[0]->childNodes[2]->childNodes[0]->childNodes;
115
-      foreach ($idols_raw as $key => $idol) {
116
-        if ($key % 2 != 0) {
117
-          $idols[] = $idol->nodeValue;
113
+    if (!$studio) {
114
+      $studio = $jdb->query("//b[contains(., 'Studio:')]")[0]->nextSibling->nodeValue;
115
+    }
116
+    if (!$label) {
117
+      $label = $jdb->query("//b[contains(., 'Label:')]")[0]->nextSibling->nodeValue;
118
+    }
119
+    if (!$idols) {
120
+      $idols_raw = $jdb->query("//b[contains(., 'Idol(s): ')]")[0]->nextSibling;
121
+
122
+      for ($i = 0; $i < 10; $i++) {
123
+        if ($idols_raw->tagName == "a") {
124
+          $idol_name = $idols_raw->nodeValue;
125
+          $idol_lower = strtolower(str_replace(' ', '-', $idol_name));
126
+          // ensure it's actually an idol name
127
+          if (strpos($idols_raw->attributes->item(0)->nodeValue, '.com/idols/' . $idol_lower) !== false) {
128
+            $idols[] = $idols_raw->nodeValue;
129
+          }
118 130
         }
131
+        $idols_raw = $idols_raw->nextSibling;
119 132
       }
120 133
     }
121 134
     if (!$year) {
122
-       $year = substr($jdb->query("//div[@class='movieinfo']")[0]->childNodes[1]->childNodes[0]->nodeValue, strlen("Release Date: "), 4);
135
+      // Assume year 2000+. JDB's oldest entry is from 2002.
136
+      $year = "20" . substr($jdb->query("//b[contains(., 'Release Date:')]")[0]->nextSibling->nodeValue, -2);
123 137
     }
124 138
     if (!$image) {
125
-      $image = $jdb->query('//*[@class="cover"]/a/img')->item(0)->getAttribute('src');
139
+      $image = $jdb->query("//img[contains(@alt, ' download or stream.')]")->item(0)->getAttribute('src');
126 140
     }
127 141
     if (substr($image, 0, 2) == '//') {
128 142
       $image = 'https:'.$image;

Loading…
Cancel
Save