shawenguan 2 years ago
parent
commit
c4721efe93
1 changed files with 7 additions and 5 deletions
  1. 7 5
      Scripts/others/pixiv.js

+ 7 - 5
Scripts/others/pixiv.js

@@ -18,12 +18,13 @@ var request = {
 $task.fetch(request).then(response => {
     let obj = JSON.parse(response.body);
     console.log(response.body);
-    if (obj.code == 0) {
+    if (obj.data) {
         for (i = 0; i < obj.data.length; i++) {
-            let pictureURL = encodeURI(obj.data[i].urls["original"]);
-            let title = obj.data[i].title || '';
-            let author = obj.data[i].author || '';
-            if(obj.data[i].aiType == 2){
+            const setu = obj.data[i];
+            let pictureURL = encodeURI(setu.urls["original"]);
+            let title = setu.title || '';
+            let author = setu.author || '';
+            if(setu.aiType == 2){
                 title = title + '(AI)';
             }
             $notify("Pixiv", title, author, { "open-url": pictureURL, "media-url": pictureURL }); // Success
@@ -31,4 +32,5 @@ $task.fetch(request).then(response => {
     } else {
         $notify("Title", "Subtitle", reason.error); // Error!
     }
+    $done({});
 })