From dfd714e481ec4cbde455a9eee3ae3b9aeed5595f Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Wed, 31 Aug 2016 07:03:49 +0200 Subject: [PATCH] Added command line option --no-media to skip downloading media files. --- .../telegram_backup/CommandLineController.java | 11 +++++++++-- .../telegram_backup/CommandLineOptions.java | 4 ++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/fabianonline/telegram_backup/CommandLineController.java b/src/main/java/de/fabianonline/telegram_backup/CommandLineController.java index 99b86c0..abf9d1b 100644 --- a/src/main/java/de/fabianonline/telegram_backup/CommandLineController.java +++ b/src/main/java/de/fabianonline/telegram_backup/CommandLineController.java @@ -154,8 +154,14 @@ public class CommandLineController { DownloadManager d = new DownloadManager(user, client, new CommandLineDownloadProgress()); logger.debug("Calling DownloadManager.downloadMessages with limit {}", CommandLineOptions.val_limit_messages); d.downloadMessages(CommandLineOptions.val_limit_messages); - logger.debug("Calling DownloadManager.downloadMedia"); - d.downloadMedia(); + + logger.debug("CommandLineOptions.cmd_no_media: {}", CommandLineOptions.cmd_no_media); + if (!CommandLineOptions.cmd_no_media) { + logger.debug("Calling DownloadManager.downloadMedia"); + d.downloadMedia(); + } else { + System.out.println("Skipping media download because --no-media is set."); + } } catch (Exception e) { e.printStackTrace(); } finally { @@ -219,6 +225,7 @@ public class CommandLineController { System.out.println(" --debug-telegram Shows lots of debug messages from the library used to access Telegram."); System.out.println(" -A, --list-accounts List all existing accounts "); System.out.println(" --limit-messages Downloads at most the most recent messages."); + System.out.println(" --no-media Do not download media files."); System.out.println(" -t, --target Target directory for the files."); System.out.println(" -e, --export Export the database. Valid formats are:"); System.out.println(" html - Creates HTML files."); diff --git a/src/main/java/de/fabianonline/telegram_backup/CommandLineOptions.java b/src/main/java/de/fabianonline/telegram_backup/CommandLineOptions.java index 451a605..6f96615 100644 --- a/src/main/java/de/fabianonline/telegram_backup/CommandLineOptions.java +++ b/src/main/java/de/fabianonline/telegram_backup/CommandLineOptions.java @@ -26,6 +26,7 @@ class CommandLineOptions { public static boolean cmd_version = false; public static boolean cmd_license = false; public static boolean cmd_daemon = false; + public static boolean cmd_no_media = false; public static String val_account = null; public static Integer val_limit_messages = null; @@ -93,6 +94,9 @@ class CommandLineOptions { case "-d": case "--daemon": cmd_daemon = true; break; + + case "--no-media": + cmd_no_media = true; break; default: throw new RuntimeException("Unknown command " + arg);