mirror of
https://github.com/C9Glax/tranga.git
synced 2025-10-16 10:20:46 +02:00
Implement #310 optional comicinfo.xml
Some checks failed
Docker Image CI / build (push) Has been cancelled
Some checks failed
Docker Image CI / build (push) Has been cancelled
This commit is contained in:
@@ -16,4 +16,6 @@ public struct Constants
|
||||
public static readonly int PostgresCommandTimeout = int.Parse(Environment.GetEnvironmentVariable("POSTGRES_COMMAND_TIMEOUT") ?? "60");
|
||||
|
||||
public static readonly bool UpdateChaptersDownloadedBeforeStarting = bool.Parse(Environment.GetEnvironmentVariable("CHECK_CHAPTERS_BEFORE_START") ?? "true");
|
||||
|
||||
public static readonly bool CreateComicInfoXml = bool.Parse(Environment.GetEnvironmentVariable("CREATE_COMICINFO_XML") ?? "true");
|
||||
}
|
@@ -120,10 +120,9 @@ public class DownloadChapterFromMangaconnectorWorker(MangaConnectorId<Chapter> c
|
||||
|
||||
await CopyCoverFromCacheToDownloadLocation(chapter.ParentManga);
|
||||
|
||||
Log.Debug($"Creating ComicInfo.xml {chapter}");
|
||||
Log.Debug($"Loading collections {chapter}");
|
||||
foreach (CollectionEntry collectionEntry in DbContext.Entry(chapter.ParentManga).Collections)
|
||||
await collectionEntry.LoadAsync(CancellationToken);
|
||||
string comicInfo = chapter.GetComicInfoXmlString();
|
||||
|
||||
if (File.Exists(saveArchiveFilePath))
|
||||
{
|
||||
@@ -137,10 +136,18 @@ public class DownloadChapterFromMangaconnectorWorker(MangaConnectorId<Chapter> c
|
||||
Log.Debug($"Creating archive: {saveArchiveFilePath}");
|
||||
//ZIP-it and ship-it
|
||||
using ZipArchive archive = ZipFile.Open(saveArchiveFilePath, ZipArchiveMode.Create);
|
||||
Log.Debug("Writing ComicInfo.xml");
|
||||
Stream comicStream = archive.CreateEntry("ComicInfo.xml").Open();
|
||||
await comicStream.WriteAsync(Encoding.UTF8.GetBytes(comicInfo), CancellationToken);
|
||||
await comicStream.DisposeAsync();
|
||||
|
||||
if (Constants.CreateComicInfoXml)
|
||||
{
|
||||
Log.Debug("Writing ComicInfo.xml");
|
||||
Stream comicStream = archive.CreateEntry("ComicInfo.xml").Open();
|
||||
string comicInfo = chapter.GetComicInfoXmlString();
|
||||
await comicStream.WriteAsync(Encoding.UTF8.GetBytes(comicInfo), CancellationToken);
|
||||
await comicStream.DisposeAsync();
|
||||
}
|
||||
else
|
||||
Log.Debug("Skipping ComicInfo.xml. CREATE_COMICINFO_XML is set to false");
|
||||
|
||||
for (int i = 0; i < images.Count; i++)
|
||||
{
|
||||
Log.Debug($"Packaging images to archive {chapter} , image {i}");
|
||||
|
Reference in New Issue
Block a user