@@ -736,17 +736,21 @@ public List<Media> getCategoryImages(String categoryName) {
736736 @ NonNull
737737 public List <Media > searchImages (String query , int offset ) {
738738 List <CustomApiResult > imageNodes = null ;
739+ List <CustomApiResult > authorNodes = null ;
740+ CustomApiResult customApiResult ;
739741 try {
740- imageNodes = api .action ("query" )
742+ customApiResult = api .action ("query" )
741743 .param ("format" , "xml" )
742- .param ("list" , "search" )
743- .param ("srwhat" , "text" )
744- .param ("srnamespace" , "6" )
745- .param ("srlimit" , "25" )
746- .param ("sroffset" ,offset )
747- .param ("srsearch" , query )
748- .get ()
749- .getNodes ("/api/query/search/p/@title" );
744+ .param ("generator" , "search" )
745+ .param ("gsrwhat" , "text" )
746+ .param ("gsrnamespace" , "6" )
747+ .param ("gsrlimit" , "25" )
748+ .param ("gsroffset" ,offset )
749+ .param ("gsrsearch" , query )
750+ .param ("prop" , "imageinfo" )
751+ .get ();
752+ imageNodes = customApiResult .getNodes ("/api/query/pages/page/@title" );
753+ authorNodes = customApiResult .getNodes ("/api/query/pages/page/imageinfo/ii/@user" );
750754 } catch (IOException e ) {
751755 Timber .e ("Failed to obtain searchImages" , e );
752756 }
@@ -756,11 +760,13 @@ public List<Media> searchImages(String query, int offset) {
756760 }
757761
758762 List <Media > images = new ArrayList <>();
759- for (CustomApiResult imageNode : imageNodes ) {
760- String imgName = imageNode .getDocument ().getTextContent ();
761- images .add (new Media (imgName ));
762- }
763763
764+ for (int i =0 ; i < imageNodes .size ();i ++){
765+ String imgName = imageNodes .get (i ).getDocument ().getTextContent ();
766+ Media media = new Media (imgName );
767+ media .setCreator (authorNodes .get (i ).getDocument ().getTextContent ());
768+ images .add (media );
769+ }
764770 return images ;
765771 }
766772
0 commit comments