Improve credit line in image list

- When author is not uploader, show both.
- When failing to parse author from HTML, use structured data.
This commit is contained in:
Yusuke Matsubara 2025-03-15 16:39:09 +09:00
parent 30762971db
commit f6350f0969
21 changed files with 363 additions and 81 deletions

View file

@ -53,6 +53,7 @@ class Media constructor(
*/
var author: String? = null,
var user: String? = null,
var creatorName: String? = null,
/**
* Gets the categories the file falls under.
* @return file categories as an ArrayList of Strings
@ -66,6 +67,7 @@ class Media constructor(
var captions: Map<String, String> = emptyMap(),
var descriptions: Map<String, String> = emptyMap(),
var depictionIds: List<String> = emptyList(),
var creatorIds: List<String> = emptyList(),
/**
* This field was added to find non-hidden categories
* Stores the mapping of category title to hidden attribute
@ -130,6 +132,7 @@ class Media constructor(
* returns user
* @return Author or User
*/
@Deprecated("Use user for uploader username. Use attributedAuthor() for attribution. Note that the uploader may not be the creator/author.")
fun getAuthorOrUser(): String? {
return if (!author.isNullOrEmpty()) {
author
@ -138,6 +141,19 @@ class Media constructor(
}
}
/**
* Returns author if it's not null or empty, otherwise
* returns creator name
* @return name of author or creator
*/
fun getAttributedAuthor(): String? {
return if (!author.isNullOrEmpty()) {
author
} else{
creatorName
}
}
/**
* Gets media display title
* @return Media title