Skip to content

Commit f66e55d

Browse files
committed
Add option to disable downloading files (--no-files)
1 parent f8004ae commit f66e55d

4 files changed

Lines changed: 12 additions & 2 deletions

File tree

PatreonDownloader.App/Models/CommandLineOptions.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ class CommandLineOptions
88
{
99
[Option("url", Required = true, HelpText = "Url of the creator's page")]
1010
public string Url { get; set; }
11+
12+
[Option("no-files", Required = false, HelpText = "Do not download files (images, attachments, media, etc.). Useful when only post metadata like descriptions is needed.", Default = false)]
13+
public bool NoFiles { get; set; }
14+
1115
[Option("descriptions", Required = false, HelpText = "Save post descriptions", Default = false)]
1216
public bool SaveDescriptions { get; set; }
1317
[Option("embeds", Required = false, HelpText = "Save embedded content metadata", Default = false)]

PatreonDownloader.App/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ private static async Task<PatreonDownloaderSettings> InitializeSettings(CommandL
153153
UrlBlackList = (_configuration["UrlBlackList"] ?? "").ToLowerInvariant().Split("|").ToList(),
154154
UserAgent = "Patreon/126.9.0.15 (Android; Android 14; Scale/2.10)",
155155
CookieContainer = null,
156+
NoFiles = commandLineOptions.NoFiles,
156157
SaveAvatarAndCover = commandLineOptions.SaveAvatarAndCover,
157158
SaveDescriptions = commandLineOptions.SaveDescriptions,
158159
SaveEmbeds = commandLineOptions.SaveEmbeds,

PatreonDownloader.Implementation/Models/PatreonDownloaderSettings.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ public record PatreonDownloaderSettings : UniversalDownloaderPlatformSettings, I
1919

2020
public bool SaveAvatarAndCover { get; init; }
2121

22+
/// <summary>
23+
/// If true, do not download remote files (images, attachments, media, etc.)
24+
/// </summary>
25+
public bool NoFiles { get; init; }
26+
2227
/// <summary>
2328
/// Create a new directory for every post and store files of said post in that directory
2429
/// </summary>

PatreonDownloader.Implementation/PatreonPageCrawler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public async Task<List<ICrawledUrl>> Crawl(ICrawlTargetInfo crawlTargetInfo)
6363
List<ICrawledUrl> crawledUrls = new List<ICrawledUrl>();
6464
Random rnd = new Random(Guid.NewGuid().GetHashCode());
6565

66-
if (_patreonDownloaderSettings.SaveAvatarAndCover)
66+
if (_patreonDownloaderSettings.SaveAvatarAndCover && !_patreonDownloaderSettings.NoFiles)
6767
{
6868
_logger.Debug("Adding avatar and cover...");
6969
if(!string.IsNullOrWhiteSpace(patreonCrawlTargetInfo.AvatarUrl))
@@ -87,7 +87,7 @@ await File.WriteAllTextAsync(Path.Combine(_patreonDownloaderSettings.DownloadDir
8787

8888
ParsingResult result = await ParsePage(json);
8989

90-
if(result.CrawledUrls.Count > 0)
90+
if(!_patreonDownloaderSettings.NoFiles && result.CrawledUrls.Count > 0)
9191
crawledUrls.AddRange(result.CrawledUrls);
9292

9393
nextPage = result.NextPage;

0 commit comments

Comments
 (0)