File tree 1 file changed +16
-2
lines changed
app/src/main/java/fr/free/nrw/commons
1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 12
12
import org .wikipedia .gallery .ExtMetadata ;
13
13
import org .wikipedia .gallery .ImageInfo ;
14
14
import org .wikipedia .page .PageTitle ;
15
- import org .wikipedia .util .StringUtil ;
16
15
17
16
import java .text .ParseException ;
18
17
import java .util .ArrayList ;
@@ -160,7 +159,7 @@ public static Media from(MwQueryPage page) {
160
159
0 ,
161
160
safeParseDate (metadata .dateTime ()),
162
161
safeParseDate (metadata .dateTime ()),
163
- StringUtil . fromHtml (metadata . artist ()). toString ( )
162
+ getArtist (metadata )
164
163
);
165
164
166
165
if (!StringUtils .isBlank (imageInfo .getThumbUrl ())) {
@@ -186,6 +185,21 @@ public static Media from(MwQueryPage page) {
186
185
return media ;
187
186
}
188
187
188
+ /**
189
+ * This method extracts the Commons Username from the artist HTML information
190
+ * @param metadata
191
+ * @return
192
+ */
193
+ private static String getArtist (ExtMetadata metadata ) {
194
+ try {
195
+ String artistHtml = metadata .artist ();
196
+ return artistHtml .substring (artistHtml .indexOf ("title=\" " ), artistHtml .indexOf ("\" >" ))
197
+ .replace ("title=\" User:" , "" );
198
+ } catch (Exception ex ) {
199
+ return "" ;
200
+ }
201
+ }
202
+
189
203
public String getThumbUrl () {
190
204
return thumbUrl ;
191
205
}
You can’t perform that action at this time.
0 commit comments