]> 91.132.146.200 Git - bibliotheca-tools.git/commitdiff
some updates while working with a games import
authorBanana <mail@bananas-playground.net>
Sun, 25 Apr 2021 19:51:50 +0000 (21:51 +0200)
committerBanana <mail@bananas-playground.net>
Sun, 25 Apr 2021 19:51:50 +0000 (21:51 +0200)
data-crow/datacrowimport.class.php
data-crow/import/game/import-mapping.json
data-crow/run-import-to-bibliotheca.php

index dc88257b0ce3c10494db94e223377672fdc3eb17..52ccbed4e89df192ff6117ea64262b20eb72f769 100644 (file)
@@ -181,6 +181,13 @@ class Datacrowimport {
         curl_setopt($ch, CURLOPT_POST,1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
 
+        /** remove for debug
+               $fp = fopen(dirname(__FILE__).'/import-error.log', 'w+');
+               curl_setopt($ch, CURLOPT_VERBOSE, true);
+               curl_setopt($ch, CURLOPT_STDERR, $fp);
+               curl_setopt($ch, CURLINFO_HEADER_OUT, true);
+                */
+
         if(!empty($port)) {
             curl_setopt($ch, CURLOPT_PORT, $port);
         }
@@ -189,9 +196,12 @@ class Datacrowimport {
 
         if(is_string($do) === true) {
             $ret = $do;
+            // debug line
+                       //error_log(var_export(curl_getinfo($ch),true));
         }
         else {
             error_log(var_export(curl_error($ch),true));
+                       error_log(var_export(curl_getinfo($ch),true));
         }
 
         curl_close($ch);
index 311a40852266c3790c35cb00bc7a43e775141036..882d6504b940fef57528b0ef65758f4dcf24ba8e 100644 (file)
@@ -2,70 +2,67 @@
   "mapping": {
     "element": "software-item",
     "fields": {
+      "title": {
+        "into": "title"
+      },
       "categories": {
         "child": "category",
         "valuefield": "name",
         "into": "category"
       },
       "description": {
-        "into": "description"
-      },
-      "developers": {
-        "child": "developer",
-        "valuefield": "name",
-        "into": "directors"
-      },
-
-
-      "countries-list": {
-        "into": "country"
-      },
-      "created": {
-        "into": "date"
-      },
-      "description": {
-        "into": "body"
+        "into": "content"
       },
       "description-alternative": {
         "into": "description",
         "from": "description",
         "method": "firstSentence"
       },
-
-      "genres": {
-        "child": "genre",
+      "developers": {
+        "child": "developer",
         "valuefield": "name",
-        "into": "genres"
+        "into": "developer"
       },
-      "title": {
-        "into": "title"
-      },
-      "languages-list": {
-        "into": "languages"
+      "picture-front": {
+        "into": "coverimage",
+        "asset": "image"
       },
       "picture-back": {
-        "into": "file_picture-back",
+        "into": "attachment",
         "asset": "image"
       },
       "picture-cd": {
-        "into": "file_picture-cd",
+        "into": "attachment",
         "asset": "image"
       },
-      "picture-front": {
-        "into": "file_picture-front",
-        "asset": "image"
+      "publishers": {
+        "child": "publisher",
+        "valuefield": "name",
+        "into": "publisher"
+      },
+      "platform": {
+        "into": "platform"
       },
       "rating": {
         "into": "rating",
-        "method": "modifyRating"
+        "method": "modifyRatingTrim"
+      },
+      "screenshot-one": {
+        "into": "attachment",
+        "asset": "image"
       },
-      "playlength": {
-        "into": "runtime"
+      "screenshot-two": {
+        "into": "attachment",
+        "asset": "image"
+      },
+      "screenshot-three": {
+        "into": "attachment",
+        "asset": "image"
       },
       "tags": {
         "child": "tag",
         "valuefield": "name",
-        "into": "storage"
+        "into": "tag"
       },
       "year": {
         "into": "year"
index 7c96b5387010090f2676c69b3e3b5d439766a066..1a462b740e2643b044ba0012392a6385f663c760 100644 (file)
  */
 
 # where the data crow export data is located.
-define('IMPORT_FOLDER','import/movie');
+define('IMPORT_FOLDER','import/game');
 # the data crow xml filename within the IMPORT_FOLDER
-define('DATACROW_XML_FILENAME','movies-export.xml');
+define('DATACROW_XML_FILENAME','games-export.xml');
 # the data crow images folder within the IMPORT_FOLDER (optional)
-define('DATACROW_IMAGES_FOLDERNAME','movies-export_images');
-# the output folder where the generead MD content will be saved
+define('DATACROW_IMAGES_FOLDERNAME','games-export_images');
+# the output folder where the generated MD content will be saved
 define('OUTPUT_FOLDER','output');
 
 # the bibliotheca api endpoint
 define('API_ENDPOINT','http://localhost/bibliotheca/webclient/api.php?p=add');
 # the tolen to connect to the api.
 # created in bibliotheca use management
-define('API_TOKEN','c435168733c58b82d455d776990ff425');
+define('API_TOKEN','1e637832829255b453ce589b066b3c69');
 
 # the bibliotheca collection to store into
-define('BIB_COLLECTION_ID','1');
+define('BIB_COLLECTION_ID','2');
 
 
 define('DEBUG',true);
@@ -97,12 +97,12 @@ if(!empty($entries)) {
 
         // the resulting POST data array is key=>value (string) only
         // only the upload can be an array
-        $_data['actors'] = implode(',',$entry['actors']);
-        $_data['tag'] = implode(',',$entry['tag']);
-        $_data['genres'] = implode(',',$entry['genres']);
-        $_data['directors'] = implode(',',$entry['directors']);
-        $_data['countries'] = implode(',',$entry['countries']);
-        $_data['languages'] = implode(',',$entry['languages']);
+               // lookupmultiple fields
+               // change to match your import settings
+        if(isset($_data['category'])) $_data['category'] = implode(',',$entry['category']);
+               if(isset($_data['developer'])) $_data['developer'] = implode(',',$entry['developer']);
+               if(isset($_data['tag'])) $_data['tag'] = implode(',',$entry['tag']);
+               if(isset($_data['publisher'])) $_data['publisher'] = implode(',',$entry['publisher']);
 
         if(!empty($_data['coverimage'])) {
             $_data['coverimage'] = curl_file_create($_data['coverimage']);
@@ -123,16 +123,26 @@ if(!empty($entries)) {
             unset($_data['attachment']);
         }
 
-        var_dump($_data);
-        exit();
         $do = $ImportObj->curlPostCall($url,$_data);
         if(!empty($do)) {
-            echo "Created: ".$entry['title']."\n";
-            echo var_export($do, true)."\n";
+                       $retJson = json_decode($do,true);
+                       if(!empty($retJson) && isset($retJson['status']) && $retJson['status'] === 200) {
+                               echo "Created: ".$entry['title']."\n";
+                               echo "With data: ".var_export($entry,true)."\n";
+                               echo "Returndata: ".var_export($do, true)."\n";
+                       }
+                       else {
+                               echo "can not create: ".$entry['title']."\n";
+                               echo "With data: ".var_export($entry,true)."\n";
+                               echo "Returndata: ".var_export($do, true)."\n";
+                               exit(1);
+                       }
         }
         else {
             echo "can not create: ".$entry['title']."\n";
-            echo var_export($do, true)."\n";
+                       echo "invalid call return data\n";
+                       echo "With data: ".var_export($entry,true)."\n";
+            echo "Returndata: ".var_export($do, true)."\n";
             exit(1);
         }
     }