Skip to content

Commit

Permalink
Merge pull request #114 from 4censord/4c/decode-urls-before-writing-t…
Browse files Browse the repository at this point in the history
…o-file

Decode the urls before writing to outputfile
  • Loading branch information
KoalaBear84 authored Jun 13, 2022
2 parents 446743d + a25ae99 commit e538c15
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/OpenDirectoryDownloader/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Net;
using TextCopy;

namespace OpenDirectoryDownloader;
Expand Down Expand Up @@ -196,8 +197,7 @@ private static void SaveSessionText(OpenDirectoryIndexer openDirectoryIndexer)
Logger.Info("Saving URL list to file..");
Console.WriteLine("Saving URL list to file..");

IEnumerable<string> distinctUrls = OpenDirectoryIndexer.Session.Root.AllFileUrls.Distinct();

IEnumerable<string> distinctUrls = OpenDirectoryIndexer.Session.Root.AllFileUrls.Distinct().Select(i => WebUtility.UrlDecode(i));
string urlsPath = Library.GetOutputFullPath(OpenDirectoryIndexer.Session, openDirectoryIndexer.OpenDirectoryIndexerSettings, "txt");
File.WriteAllLines(urlsPath, distinctUrls);

Expand Down
4 changes: 2 additions & 2 deletions src/OpenDirectoryDownloader/OpenDirectoryIndexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ public async void StartIndexingAsync()
Session.TotalFiles = Session.Root.TotalFiles;
Session.TotalFileSizeEstimated = Session.Root.TotalFileSize;

IEnumerable<string> distinctUrls = Session.Root.AllFileUrls.Distinct();
IEnumerable<string> distinctUrls = Session.Root.AllFileUrls.Distinct().Select(i => WebUtility.UrlDecode(i));

if (Session.TotalFiles != distinctUrls.Count())
{
Expand All @@ -392,8 +392,8 @@ public async void StartIndexingAsync()
try
{
string urlsPath = Library.GetOutputFullPath(Session, OpenDirectoryIndexerSettings, "txt");

File.WriteAllLines(urlsPath, distinctUrls);

Logger.Info($"Saved URL list to file: {urlsPath}");
Console.WriteLine($"Saved URL list to file: {urlsPath}");

Expand Down

0 comments on commit e538c15

Please sign in to comment.