Skip to content

Commit

Permalink
2.4.0.1: fix duplicate chapter bug (#64)
Browse files Browse the repository at this point in the history
* fix duplicate chapter bug
* upd frontend version
  • Loading branch information
bubuntoid authored Jun 25, 2023
1 parent e6a8fe3 commit c6457e1
Show file tree
Hide file tree
Showing 11 changed files with 650 additions and 1,170 deletions.
5 changes: 4 additions & 1 deletion frontend/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,8 @@
}
}
},
"defaultProject": "ethereal"
"defaultProject": "ethereal",
"cli": {
"analytics": false
}
}
1,741 changes: 589 additions & 1,152 deletions frontend/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion frontend/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
">

<div style="position: absolute; bottom: 0; right: 0; width: 100px; text-align:right;">
<p style="color: white">2.4.0.0 &nbsp; &nbsp;</p>
<p style="color: white">2.4.0.1 &nbsp; &nbsp;</p>
</div>

<div class="valign" style="width:100%;">
Expand Down
49 changes: 38 additions & 11 deletions src/Ethereal.Application.UnitTests/Tests/VideoDescriptionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,64 +23,91 @@ public class VideoDescriptionTests
5. Cutting Crew - (I Just) Died in Your Arms 03:17:21
6. Roxy Music - More Than This 03:21:40
7. Toto - Africa 03:28:00";
7. Toto - Africa 03:28:00
7. Toto - Africa 04:30:00
7. Toto - Africa 05:30:00";

private readonly VideoChapter[] expectedChapters =
{
new VideoChapter
new()
{
Original = "1. (0:00) KOPI / KOBASOLO – Swayed in Spring Reiniscence",
Name = "1. KOPI KOBASOLO – Swayed in Spring Reiniscence",
UniqueName = "1. KOPI KOBASOLO – Swayed in Spring Reiniscence",
StartTimespan = new TimeSpan(00, 00, 00),
EndTimespan = new TimeSpan(00, 09, 13)
EndTimespan = new TimeSpan(00, 09, 13),
},

new VideoChapter
new()
{
Original = "2. (09:13) Memai Siren -Nisemono no Utage",
Name = "2. Memai Siren -Nisemono no Utage",
UniqueName = "2. Memai Siren -Nisemono no Utage",
StartTimespan = new TimeSpan(00, 09, 13),
EndTimespan = new TimeSpan(00, 34, 36)
},

new VideoChapter
new()
{
Original = "3. (34:36) Vivid Undress – Sayonara Dilemma",
Name = "3. Vivid Undress – Sayonara Dilemma",
UniqueName = "3. Vivid Undress – Sayonara Dilemma",
StartTimespan = new TimeSpan(00, 34, 36),
EndTimespan = new TimeSpan(01, 23, 31)
},

new VideoChapter
new()
{
Original = "4. (1:23:31) Vivid Undress – Yours",
Name = "4. Vivid Undress – Yours",
UniqueName = "4. Vivid Undress – Yours",
StartTimespan = new TimeSpan(01, 23, 31),
EndTimespan = new TimeSpan(03, 17, 21)
},

new VideoChapter
new()
{
Original = "5. Cutting Crew - (I Just) Died in Your Arms 03:17:21",
Name = "5. Cutting Crew - (I Just) Died in Your Arms",
UniqueName = "5. Cutting Crew - (I Just) Died in Your Arms",
StartTimespan = new TimeSpan(03, 17, 21),
EndTimespan = new TimeSpan(03, 21, 40)
},

new VideoChapter
new()
{
Original = "6. Roxy Music - More Than This 03:21:40",
Name = "6. Roxy Music - More Than This",
UniqueName = "6. Roxy Music - More Than This",
StartTimespan = new TimeSpan(03, 21, 40),
EndTimespan = new TimeSpan(03, 28, 00)
},

new VideoChapter
new()
{
Original = "7. Toto - Africa 03:28:00",
Name = "7. Toto - Africa",
StartTimespan = new TimeSpan(03, 28, 00)
}
UniqueName = "7. Toto - Africa",
StartTimespan = new TimeSpan(03, 28, 00),
EndTimespan = new TimeSpan(04, 30, 00)
},

new()
{
Original = "7. Toto - Africa 04:30:00",
Name = "7. Toto - Africa",
UniqueName = "7. Toto - Africa (2)",
StartTimespan = new TimeSpan(04, 30, 00),
EndTimespan = new TimeSpan(05, 30, 00)
},

new()
{
Original = "7. Toto - Africa 05:30:00",
Name = "7. Toto - Africa",
UniqueName = "7. Toto - Africa (3)",
StartTimespan = new TimeSpan(05, 30, 00)
},
};

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Ethereal.Application.UnitTests;

public class WithInMemoryDatabaseTestBase
public abstract class WithInMemoryDatabaseTestBase
{
protected TestSettings Settings;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public async Task ExecuteAsync(Guid jobId)

var cts = new CancellationTokenSource();
var timeoutDate = DateTime.UtcNow.Add(settings.DownloadingTimeout);
// todo: refactor this
var thread = new Thread(async () =>
{
while (true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static string GetArchivePath(this ProcessingJob job)

public static string GetChapterLocalFilePath(this ProcessingJob job, VideoChapter chapter)
{
return Path.Combine(job.LocalPath, $"{chapter.Name.RemoveIllegalCharacters()}.mp4");
return Path.Combine(job.LocalPath, $"{chapter.UniqueName.RemoveIllegalCharacters()}.mp4");
}

public static string GetChapterLocalThumbnailFilePath(this ProcessingJob job, VideoChapter chapter, IEtherealSettings settings)
Expand Down
2 changes: 2 additions & 0 deletions src/Ethereal.Application/VideoChapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public VideoChapter(string original, string name, TimeSpan timespan)

public string Name { get; set; }

public string UniqueName { get; set; }

public TimeSpan StartTimespan { get; set; }

public TimeSpan? EndTimespan { get; set; }
Expand Down
10 changes: 10 additions & 0 deletions src/Ethereal.Application/VideoDescription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,20 @@ public IReadOnlyCollection<VideoChapter> ParseChapters()
StartTimespan = timespan,
Name = line.RemoveTimespan().RemoveIllegalCharacters()
};

chapter.UniqueName = chapter.Name;

var duplicatesCount = chapters.Count(s => s.Name == chapter.Name);
if (duplicatesCount > 0)
{
chapter.UniqueName += $" ({duplicatesCount + 1})";
}

chapters.Add(chapter);
}
catch
{
// ignored
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Ethereal.WebAPI/Frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@


<!--Import Google Icon Font-->
<style type="text/css">@font-face{font-family:'Material Icons';font-style:normal;font-weight:400;src:url(https://fonts.gstatic.com/s/materialicons/v139/flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ.woff2) format('woff2');}.material-icons{font-family:'Material Icons';font-weight:normal;font-style:normal;font-size:24px;line-height:1;letter-spacing:normal;text-transform:none;display:inline-block;white-space:nowrap;word-wrap:normal;direction:ltr;-webkit-font-feature-settings:'liga';-webkit-font-smoothing:antialiased;}</style>
<style type="text/css">@font-face{font-family:'Material Icons';font-style:normal;font-weight:400;src:url(https://fonts.gstatic.com/s/materialicons/v140/flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ.woff2) format('woff2');}.material-icons{font-family:'Material Icons';font-weight:normal;font-style:normal;font-size:24px;line-height:1;letter-spacing:normal;text-transform:none;display:inline-block;white-space:nowrap;word-wrap:normal;direction:ltr;-webkit-font-feature-settings:'liga';-webkit-font-smoothing:antialiased;}</style>
<!-- Compiled and minified CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<!-- Compiled and minified JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<link rel="stylesheet" href="styles.6949409c5ad074bbe80e.css" media="print" onload="this.media='all'"><noscript><link rel="stylesheet" href="styles.6949409c5ad074bbe80e.css"></noscript></head>
<body>
<app-root></app-root>
<script src="runtime.2fe89b821ea142064af8.js" defer></script><script src="polyfills.48cf29e797506ffaa378.js" defer></script><script src="main.063182d3141acc9f2552.js" defer></script>
<script src="runtime.2fe89b821ea142064af8.js" defer></script><script src="polyfills.48cf29e797506ffaa378.js" defer></script><script src="main.c701f9a37cf8a995727e.js" defer></script>

</body></html>

Large diffs are not rendered by default.

0 comments on commit c6457e1

Please sign in to comment.