File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
app/src/main/java/fr/free/nrw/commons Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 1212import org .wikipedia .gallery .ExtMetadata ;
1313import org .wikipedia .gallery .ImageInfo ;
1414import org .wikipedia .page .PageTitle ;
15- import org .wikipedia .util .StringUtil ;
1615
1716import java .text .ParseException ;
1817import java .util .ArrayList ;
@@ -160,7 +159,7 @@ public static Media from(MwQueryPage page) {
160159 0 ,
161160 safeParseDate (metadata .dateTime ()),
162161 safeParseDate (metadata .dateTime ()),
163- StringUtil . fromHtml (metadata . artist ()). toString ( )
162+ getArtist (metadata )
164163 );
165164
166165 if (!StringUtils .isBlank (imageInfo .getThumbUrl ())) {
@@ -186,6 +185,21 @@ public static Media from(MwQueryPage page) {
186185 return media ;
187186 }
188187
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+
189203 public String getThumbUrl () {
190204 return thumbUrl ;
191205 }
You can’t perform that action at this time.
0 commit comments