Skip to content

Commit

Permalink
Исправлено определение структуры акомикса.
Browse files Browse the repository at this point in the history
Конвертирование теперь не гоняется повторно без нужды.
  • Loading branch information
MonkAlex committed Apr 17, 2015
1 parent 6cd3a37 commit d8d6ef9
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 34 deletions.
4 changes: 2 additions & 2 deletions MangaReader/Manga/Acomic/Acomics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public override List<Compression.CompressionMode> AllowedCompressionModes
get
{
return base.AllowedCompressionModes
.Where(m => this.HasVolumes && Equals(m, Compression.CompressionMode.Volume) ||
this.HasChapters && Equals(m, Compression.CompressionMode.Chapter) ||
.Where(m => this.HasVolumes && (Equals(m, Compression.CompressionMode.Volume) || Equals(m, Compression.CompressionMode.Chapter)) ||
this.HasChapters && Equals(m, Compression.CompressionMode.Volume) ||
Equals(m, Compression.CompressionMode.Manga))
.ToList();
}
Expand Down
37 changes: 16 additions & 21 deletions MangaReader/Manga/Acomic/Getter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
Expand Down Expand Up @@ -52,7 +51,7 @@ public static void UpdateContentType(Acomics manga)
var document = new HtmlDocument();
document.LoadHtml(Page.GetPage(new Uri(manga.Uri.OriginalString + @"/content"), Getter.GetAdultClient(manga.Uri)));
manga.HasVolumes = document.DocumentNode.SelectNodes("//h2[@class=\"serial-chapters-head\"]") != null;
manga.HasChapters = document.DocumentNode.SelectNodes("//div[@class=\"chapters\"]//li") != null;
manga.HasChapters = document.DocumentNode.SelectNodes("//div[@class=\"chapters\"]//a") != null;
}
catch (Exception){}
}
Expand All @@ -73,19 +72,28 @@ public static void UpdateContent(Acomics manga)

var volumeNodes = document.DocumentNode.SelectNodes("//h2[@class=\"serial-chapters-head\"]");
if (volumeNodes != null)
for (int i = 0; i < volumeNodes.Count; i++)
for (var i = 0; i < volumeNodes.Count; i++)
{
var desc = volumeNodes[i].InnerText;
var volume = volumeNodes[i];
var desc = volume.InnerText;
var newVolume = new Volume(desc, volumes.Count + 1);
var subVolumeNodes = volumeNodes[i].ParentNode.ChildNodes[i * 2 + 1].ChildNodes;
AddChapters(subVolumeNodes, newVolume.Chapters);
var skipped = volume.ParentNode.ChildNodes
.SkipWhile(cn => cn.PreviousSibling != volume);
var volumeChapterNodes = skipped
.TakeWhile(cn => cn.Name != "h2");
var volumeChapters = volumeChapterNodes
.Select(cn => cn.SelectNodes(".//a"))
.SelectMany(cn => cn)
.Select(cn => new Chapter(new Uri(cn.Attributes[0].Value), (cn.Attributes.Count > 1 ? cn.Attributes[1].Value : cn.InnerText)));
newVolume.Chapters.AddRange(volumeChapters);
volumes.Add(newVolume);
}

if (volumeNodes == null || !volumes.Any())
{
var chapterNodes = document.DocumentNode.SelectNodes("//div[@class=\"chapters\"]//li");
AddChapters(chapterNodes, chapters);
var nodes = document.DocumentNode.SelectNodes("//div[@class=\"chapters\"]//a");
if (nodes != null)
chapters.AddRange(nodes.Select(cn => new Chapter(new Uri(cn.Attributes[0].Value), (cn.Attributes.Count > 1 ? cn.Attributes[1].Value : cn.InnerText))));
}

var allPages = GetMangaPages(manga.Uri);
Expand All @@ -108,19 +116,6 @@ public static void UpdateContent(Acomics manga)
manga.Pages.AddRange(pages);
}

private static void AddChapters(HtmlNodeCollection collection, IList chapters)
{
if (collection == null)
return;

foreach (var chapter in collection)
{
var desc = chapter.InnerText;
var link = new Uri(chapter.ChildNodes[0].ChildNodes[0].Attributes[0].Value);
chapters.Add(new Chapter(link, desc));
}
}

/// <summary>
/// Получить страницы манги.
/// </summary>
Expand Down
9 changes: 6 additions & 3 deletions MangaReader/Mapping/Converting.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using MangaReader.Services;
using System;
using MangaReader.Services;

namespace MangaReader.Mapping
{
Expand All @@ -15,7 +16,8 @@ internal static void ConvertAll(ConverterProcess process)

private static void Convert24To27(ConverterProcess process)
{
if (process.Version.CompareTo(Settings.DatabaseVersion) > 0)
var version = new Version(1, 27, 5584);
if (version.CompareTo(Settings.DatabaseVersion) > 0 && process.Version.CompareTo(version) >= 0)
{
var readmangaHas = Environment.Session.CreateSQLQuery(@"update Mangas
set HasVolumes = 1, HasChapters = 1
Expand All @@ -31,7 +33,8 @@ private static void Convert24To27(ConverterProcess process)

internal static void ConvertBaseTo24(ConverterProcess process)
{
if (process.Version.CompareTo(Settings.DatabaseVersion) > 0)
var version = new Version(1, 24);
if (version.CompareTo(Settings.DatabaseVersion) > 0 && process.Version.CompareTo(version) >= 0)
{
var readmangaCompressionMode = Environment.Session.CreateSQLQuery(@"update Mangas
set CompressionMode = 'Volume'
Expand Down
3 changes: 2 additions & 1 deletion MangaReader/Services/Convert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ internal class ConverterProcess

static class Converter
{
public static ConverterProcess Process = new ConverterProcess() { Version = Assembly.GetExecutingAssembly().GetName().Version };
public static ConverterProcess Process = new ConverterProcess()
{ Version = new Version(Settings.AppVersion.Major, Settings.AppVersion.Minor, Settings.AppVersion.Build ) };

public static ConverterState State = ConverterState.None;

Expand Down
3 changes: 2 additions & 1 deletion MangaReader/Services/Library.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ internal static void Convert(ConverterProcess process)

private static void Convert24To27(ConverterProcess process)
{
if (process.Version.CompareTo(Settings.DatabaseVersion) > 0)
var version = new Version(1, 27, 5584);
if (version.CompareTo(Settings.DatabaseVersion) > 0 && process.Version.CompareTo(version) >= 0)
{
process.Percent = 0;
var acomics = Mapping.Environment.Session.Query<Acomics>().ToList();
Expand Down
7 changes: 6 additions & 1 deletion MangaReader/Services/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ public class Settings
/// </summary>
public static Version DatabaseVersion = new Version(1, 0, 0, 0);

/// <summary>
/// Версия приложения.
/// </summary>
public static Version AppVersion = Assembly.GetExecutingAssembly().GetName().Version;

/// <summary>
/// Папка программы.
/// </summary>
Expand Down Expand Up @@ -117,7 +122,7 @@ public static void Save()
new object[] {null, null},
MinimizeToTray,
AutoUpdateInHours,
DatabaseVersion.ToString(4)
DatabaseVersion.ToString()
};
Serializer<object[]>.Save(SettingsPath, settings);
}
Expand Down
7 changes: 2 additions & 5 deletions MangaReader/Update/VersionHistory.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
1.27.5584
+ Добавлена возможность поставить процесс обновления на паузу.
* Процесс конвертирования теперь сам определяет версию программы и базы данных.

1.27.5583
1.27.5585
* Улучшена поддержка сайта Acomics:
+ Добавлена поддержка глав и томов
+ Добавлена упаковка глав и томов, если они имеются у конкретного комикса
* Общие доработки по процессу скачивания.
+ Добавлена возможность поставить процесс обновления на паузу.

1.26.5548
* Исправлена работа с перемещённой мангой на ридманге\адультманге:
Expand Down

0 comments on commit d8d6ef9

Please sign in to comment.