1
0
mirror of https://github.com/fabianonline/telegram_backup.git synced 2024-12-25 14:25:35 +00:00

Added max_file_age to download only newer files.

This commit is contained in:
Fabian Schlenz 2018-03-15 06:48:37 +01:00
parent 6276651b84
commit 968ee831f0
5 changed files with 10 additions and 0 deletions

View File

@ -52,6 +52,7 @@ internal class CommandLineDownloadProgress : DownloadProgressInterface {
println("'.' - Previously downloaded file 'e' - Empty file")
println("' ' - Ignored media type (weblinks or contacts, for example)")
println("'x' - File skipped because of errors - will be tried again at next run")
println("'_' - Message is older than max_file_age")
println("" + count + " Files to check / download")
}
@ -75,6 +76,8 @@ internal class CommandLineDownloadProgress : DownloadProgressInterface {
showNewLine()
println("Done.")
}
override fun onMediaTooOld() = show("_")
private fun show(letter: String) {
print(letter)

View File

@ -326,6 +326,8 @@ class DownloadManager(internal var client: TelegramClient?, p: DownloadProgressI
prog!!.onMediaDownloadedEmpty()
} else if (m.downloaded) {
prog!!.onMediaAlreadyPresent(m)
} else if (IniSettings.max_file_age!=null && (System.currentTimeMillis() / 1000) - msg.date > IniSettings.max_file_age * 24 * 60 * 60) {
prog!!.onMediaTooOld()
} else {
try {
val result = m.download()

View File

@ -29,4 +29,5 @@ interface DownloadProgressInterface {
fun onMediaSkipped()
fun onMediaAlreadyPresent(file_manager: AbstractMediaFileManager)
fun onMediaDownloadFinished()
fun onMediaTooOld()
}

View File

@ -82,4 +82,5 @@ object IniSettings {
get() = getStringList("whitelist_channels")
val blacklist_channels: List<String>?
get() = getStringList("blacklist_channels")
val max_file_age = getInt("max_file_age")
}

View File

@ -18,6 +18,9 @@
## Download media files
# download_media = true
## Only download media files from messages that are never than x days.
## Leave unset to download all media files.
# max_file_age = 7
## Downloads of channels and supergroups