mirror of
https://github.com/Kareadita/Kavita.git
synced 2026-06-05 22:35:17 -04:00
28f082b653
Co-authored-by: Ansh Raj <anshraj220109+github@proton.me> Co-authored-by: Amelia <77553571+Fesaa@users.noreply.github.com> Co-authored-by: Weblate (bot) <hosted@weblate.org> Co-authored-by: Adam Havránek <adamhavra@seznam.cz> Co-authored-by: Gregory.Open <gregory.open@proton.me> Co-authored-by: Lyrq <lyrq.ku@gmail.com> Co-authored-by: oxygen44k <iiccpp@outlook.com> Co-authored-by: Grez Kull <grezkull@users.noreply.hosted.weblate.org>
56 lines
2.2 KiB
C#
56 lines
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Kavita.Models.DTOs.Scrobbling;
|
|
using Kavita.Models.Entities.Enums;
|
|
|
|
namespace Kavita.Models.Extensions;
|
|
|
|
public static class PlusMediaFormatExtensions
|
|
{
|
|
public static PlusMediaFormat ConvertToPlusMediaFormat(this LibraryType libraryType, MangaFormat? seriesFormat = null)
|
|
{
|
|
// TODO: Amelia, let's rework this with v3/scrobbling
|
|
return libraryType switch
|
|
{
|
|
LibraryType.Manga => seriesFormat is MangaFormat.Epub ? PlusMediaFormat.LightNovel : PlusMediaFormat.Manga,
|
|
LibraryType.Comic => PlusMediaFormat.Comic,
|
|
LibraryType.LightNovel => PlusMediaFormat.LightNovel,
|
|
LibraryType.Book => PlusMediaFormat.Book,
|
|
LibraryType.Image => PlusMediaFormat.Manga,
|
|
LibraryType.ComicVine => PlusMediaFormat.Comic,
|
|
_ => throw new ArgumentOutOfRangeException(nameof(libraryType), libraryType, null)
|
|
};
|
|
}
|
|
|
|
public static IEnumerable<LibraryType> ConvertToLibraryTypes(this PlusMediaFormat plusMediaFormat)
|
|
{
|
|
return plusMediaFormat switch
|
|
{
|
|
PlusMediaFormat.Manga => [LibraryType.Manga, LibraryType.Image],
|
|
PlusMediaFormat.Comic => [LibraryType.Comic, LibraryType.ComicVine],
|
|
PlusMediaFormat.LightNovel => [LibraryType.LightNovel, LibraryType.Book, LibraryType.Manga],
|
|
PlusMediaFormat.Book => [LibraryType.LightNovel, LibraryType.Book],
|
|
_ => throw new ArgumentOutOfRangeException(nameof(plusMediaFormat), plusMediaFormat, null)
|
|
};
|
|
}
|
|
|
|
public static IList<MangaFormat> GetMangaFormats(this PlusMediaFormat? mediaFormat)
|
|
{
|
|
return mediaFormat.HasValue ? mediaFormat.Value.GetMangaFormats() : [MangaFormat.Archive];
|
|
}
|
|
|
|
public static IList<MangaFormat> GetMangaFormats(this PlusMediaFormat mediaFormat)
|
|
{
|
|
return mediaFormat switch
|
|
{
|
|
PlusMediaFormat.Manga => [MangaFormat.Archive, MangaFormat.Image],
|
|
PlusMediaFormat.Comic => [MangaFormat.Archive],
|
|
PlusMediaFormat.LightNovel => [MangaFormat.Epub, MangaFormat.Pdf],
|
|
PlusMediaFormat.Book => [MangaFormat.Epub, MangaFormat.Pdf],
|
|
_ => [MangaFormat.Archive]
|
|
};
|
|
}
|
|
|
|
|
|
}
|