feat(starlight): add episode image support and improve image selection

- Add Image property to Episode model
- Update episode template call to include image parameter
- Implement SelectImage helper method for flexible image source selection
- Enhance image selection logic for both main content and episodes
This commit is contained in:
baliasnyifeliks 2026-01-14 09:31:09 +02:00
parent 60d7b15dc1
commit 58bb8d194c
3 changed files with 20 additions and 3 deletions

View File

@ -89,7 +89,7 @@ namespace StarLight.Controllers
string episodeName = string.IsNullOrEmpty(ep.Title) ? $"Епізод {index}" : ep.Title;
string callUrl = $"{host}/starlight/play?hash={HttpUtility.UrlEncode(ep.Hash)}&title={HttpUtility.UrlEncode(title ?? original_title)}";
episode_tpl.Append(episodeName, title ?? original_title, (s + 1).ToString(), index.ToString("D2"), accsArgs(callUrl), "call");
episode_tpl.Append(episodeName, title ?? original_title, (s + 1).ToString(), index.ToString("D2"), accsArgs(callUrl), "call", img: ep.Image);
index++;
}

View File

@ -24,6 +24,7 @@ namespace StarLight.Models
public string VideoSlug { get; set; }
public string Date { get; set; }
public string SeasonSlug { get; set; }
public string Image { get; set; }
}
public class ProjectInfo

View File

@ -119,7 +119,7 @@ namespace StarLight
{
Title = root.TryGetProperty("title", out var titleProp) ? titleProp.GetString() : null,
Description = root.TryGetProperty("description", out var descProp) ? descProp.GetString() : null,
Poster = NormalizeImage(root.TryGetProperty("image", out var imageProp) ? imageProp.GetString() : null),
Poster = NormalizeImage(SelectImage(root, "imageMob", "imageTab", "image", "logoImage")),
Hash = root.TryGetProperty("hash", out var hashProp) ? hashProp.GetString() : null,
Type = root.TryGetProperty("typeSlug", out var typeProp) ? typeProp.GetString() : null,
Channel = root.TryGetProperty("channelTitle", out var channelProp) ? channelProp.GetString() : null
@ -143,7 +143,8 @@ namespace StarLight
Hash = item.TryGetProperty("hash", out var eHash) ? eHash.GetString() : null,
VideoSlug = item.TryGetProperty("videoSlug", out var eSlug) ? eSlug.GetString() : null,
Date = item.TryGetProperty("dateOfBroadcast", out var eDate) ? eDate.GetString() : (item.TryGetProperty("timeUploadVideo", out var eDate2) ? eDate2.GetString() : null),
SeasonSlug = seasonSlug
SeasonSlug = seasonSlug,
Image = NormalizeImage(SelectImage(item, "imageMob", "image"))
});
}
}
@ -240,6 +241,21 @@ namespace StarLight
return $"{_init.host}{path}";
}
private static string SelectImage(JsonElement element, params string[] keys)
{
foreach (var key in keys)
{
if (element.TryGetProperty(key, out var prop))
{
var value = prop.GetString();
if (!string.IsNullOrEmpty(value))
return value;
}
}
return null;
}
public static TimeSpan cacheTime(int multiaccess, int home = 5, int mikrotik = 2, OnlinesSettings init = null, int rhub = -1)
{
if (init != null && init.rhub && rhub != -1)