Compare commits
No commits in common. "e977bed5a55e9ef6eccb24bfb12498bcb8f7e8a5" and "15fc3672631b7aa3418212ca7eea074f34c307bf" have entirely different histories.
e977bed5a5
...
15fc367263
@ -58,8 +58,7 @@ public abstract class Connector
|
||||
/// </summary>
|
||||
/// <param name="publication">Publication that contains Chapter</param>
|
||||
/// <param name="chapter">Chapter with Images to retrieve</param>
|
||||
/// <param name="parentTask">Will be used for progress-tracking</param>
|
||||
public abstract void DownloadChapter(Publication publication, Chapter chapter, TrangaTask parentTask);
|
||||
public abstract void DownloadChapter(Publication publication, Chapter chapter);
|
||||
|
||||
/// <summary>
|
||||
/// Copies the already downloaded cover from cache to downloadLocation
|
||||
@ -100,7 +99,7 @@ public abstract class Connector
|
||||
new XElement("Title", chapter.name),
|
||||
new XElement("Writer", publication.author),
|
||||
new XElement("Volume", chapter.volumeNumber),
|
||||
new XElement("Number", chapter.chapterNumber)
|
||||
new XElement("Number", chapter.chapterNumber) //TODO check if this is correct at some point
|
||||
);
|
||||
return comicInfo.ToString();
|
||||
}
|
||||
@ -129,7 +128,6 @@ public abstract class Connector
|
||||
/// <param name="imageUrl"></param>
|
||||
/// <param name="fullPath"></param>
|
||||
/// <param name="requestType">RequestType for Rate-Limit</param>
|
||||
/// <param name="referrer">referrer used in html request header</param>
|
||||
private void DownloadImage(string imageUrl, string fullPath, byte requestType, string? referrer = null)
|
||||
{
|
||||
DownloadClient.RequestResult requestResult = downloadClient.MakeRequest(imageUrl, requestType, referrer);
|
||||
@ -147,11 +145,9 @@ public abstract class Connector
|
||||
/// </summary>
|
||||
/// <param name="imageUrls">List of URLs to download Images from</param>
|
||||
/// <param name="saveArchiveFilePath">Full path to save archive to (without file ending .cbz)</param>
|
||||
/// <param name="parentTask">Used for progress tracking</param>
|
||||
/// <param name="comicInfoPath">Path of the generate Chapter ComicInfo.xml, if it was generated</param>
|
||||
/// <param name="requestType">RequestType for RateLimits</param>
|
||||
/// <param name="referrer">Used in http request header</param>
|
||||
protected void DownloadChapterImages(string[] imageUrls, string saveArchiveFilePath, byte requestType, TrangaTask parentTask, string? comicInfoPath = null, string? referrer = null)
|
||||
protected void DownloadChapterImages(string[] imageUrls, string saveArchiveFilePath, byte requestType, string? comicInfoPath = null, string? referrer = null)
|
||||
{
|
||||
logger?.WriteLine("Connector", $"Downloading Images for {saveArchiveFilePath}");
|
||||
//Check if Publication Directory already exists
|
||||
@ -171,9 +167,8 @@ public abstract class Connector
|
||||
{
|
||||
string[] split = imageUrl.Split('.');
|
||||
string extension = split[^1];
|
||||
logger?.WriteLine("Connector", $"Downloading Image {chapter + 1:000}/{imageUrls.Length:000} {(parentTask.publication?.sortName)![..25],-25} {(parentTask.publication?.internalId)![..25],-25} Total Task Progress: {parentTask.progress:00.0}%");
|
||||
logger?.WriteLine("Connector", $"Downloading Image {chapter + 1}/{imageUrls.Length} {imageUrl}");
|
||||
DownloadImage(imageUrl, Path.Join(tempFolder, $"{chapter++}.{extension}"), requestType, referrer);
|
||||
parentTask.tasksFinished++;
|
||||
}
|
||||
|
||||
if(comicInfoPath is not null)
|
||||
@ -231,7 +226,6 @@ public abstract class Connector
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="requestType">For RateLimits: Same Endpoints use same type</param>
|
||||
/// <param name="referrer">Used in http request header</param>
|
||||
/// <returns>RequestResult with StatusCode and Stream of received data</returns>
|
||||
public RequestResult MakeRequest(string url, byte requestType, string? referrer = null)
|
||||
{
|
||||
|
@ -204,7 +204,7 @@ public class MangaDex : Connector
|
||||
return chapters.OrderBy(chapter => Convert.ToSingle(chapter.chapterNumber, chapterNumberFormatInfo)).ToArray();
|
||||
}
|
||||
|
||||
public override void DownloadChapter(Publication publication, Chapter chapter, TrangaTask parentTask)
|
||||
public override void DownloadChapter(Publication publication, Chapter chapter)
|
||||
{
|
||||
logger?.WriteLine(this.GetType().ToString(), $"Downloading Chapter-Info {publication.sortName} {publication.internalId} {chapter.volumeNumber}-{chapter.chapterNumber}");
|
||||
//Request URLs for Chapter-Images
|
||||
@ -228,7 +228,7 @@ public class MangaDex : Connector
|
||||
File.WriteAllText(comicInfoPath, GetComicInfoXmlString(publication, chapter, logger));
|
||||
|
||||
//Download Chapter-Images
|
||||
DownloadChapterImages(imageUrls.ToArray(), GetArchiveFilePath(publication, chapter), (byte)RequestType.AtHomeServer, parentTask, comicInfoPath);
|
||||
DownloadChapterImages(imageUrls.ToArray(), GetArchiveFilePath(publication, chapter), (byte)RequestType.AtHomeServer, comicInfoPath);
|
||||
}
|
||||
|
||||
private string? GetCoverUrl(string publicationId, string? posterId)
|
||||
|
@ -162,7 +162,7 @@ public class Manganato : Connector
|
||||
return ret.ToArray();
|
||||
}
|
||||
|
||||
public override void DownloadChapter(Publication publication, Chapter chapter, TrangaTask parentTask)
|
||||
public override void DownloadChapter(Publication publication, Chapter chapter)
|
||||
{
|
||||
logger?.WriteLine(this.GetType().ToString(), $"Downloading Chapter-Info {publication.sortName} {publication.internalId} {chapter.volumeNumber}-{chapter.chapterNumber}");
|
||||
string requestUrl = chapter.url;
|
||||
@ -176,7 +176,7 @@ public class Manganato : Connector
|
||||
string comicInfoPath = Path.GetTempFileName();
|
||||
File.WriteAllText(comicInfoPath, GetComicInfoXmlString(publication, chapter, logger));
|
||||
|
||||
DownloadChapterImages(imageUrls, GetArchiveFilePath(publication, chapter), (byte)1, parentTask, comicInfoPath, "https://chapmanganato.com/");
|
||||
DownloadChapterImages(imageUrls, GetArchiveFilePath(publication, chapter), (byte)1, comicInfoPath, "https://chapmanganato.com/");
|
||||
}
|
||||
|
||||
private string[] ParseImageUrlsFromHtml(Stream html)
|
||||
|
@ -19,9 +19,6 @@ public abstract class TrangaTask
|
||||
public Publication? publication { get; }
|
||||
public string? language { get; }
|
||||
[JsonIgnore]public ExecutionState state { get; set; }
|
||||
[JsonIgnore] public float progress => (tasksFinished != 0f ? tasksFinished / tasksCount : 0f);
|
||||
[JsonIgnore]public float tasksCount { get; set; }
|
||||
[JsonIgnore]public float tasksFinished { get; set; }
|
||||
|
||||
public enum ExecutionState
|
||||
{
|
||||
@ -38,8 +35,6 @@ public abstract class TrangaTask
|
||||
this.connectorName = connectorName;
|
||||
this.task = task;
|
||||
this.language = language;
|
||||
this.tasksCount = 1;
|
||||
this.tasksFinished = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -18,14 +18,13 @@ public class DownloadNewChaptersTask : TrangaTask
|
||||
if(!Directory.Exists(publicationFolder))
|
||||
Directory.CreateDirectory(publicationFolder);
|
||||
List<Chapter> newChapters = UpdateChapters(connector, pub, language!, ref taskManager.chapterCollection);
|
||||
this.tasksCount = newChapters.Count;
|
||||
|
||||
connector.CopyCoverFromCacheToDownloadLocation(pub, taskManager.settings);
|
||||
|
||||
pub.SaveSeriesInfoJson(connector.downloadLocation);
|
||||
|
||||
foreach(Chapter newChapter in newChapters)
|
||||
connector.DownloadChapter(pub, newChapter, this);
|
||||
connector.DownloadChapter(pub, newChapter);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Loading…
Reference in New Issue
Block a user