mirror of
https://github.com/fabianonline/telegram_backup.git
synced 2024-11-22 08:46:15 +00:00
Added max_file_age to download only newer files.
This commit is contained in:
parent
6276651b84
commit
968ee831f0
@ -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")
|
||||
}
|
||||
|
||||
@ -76,6 +77,8 @@ internal class CommandLineDownloadProgress : DownloadProgressInterface {
|
||||
println("Done.")
|
||||
}
|
||||
|
||||
override fun onMediaTooOld() = show("_")
|
||||
|
||||
private fun show(letter: String) {
|
||||
print(letter)
|
||||
i++
|
||||
|
@ -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()
|
||||
|
@ -29,4 +29,5 @@ interface DownloadProgressInterface {
|
||||
fun onMediaSkipped()
|
||||
fun onMediaAlreadyPresent(file_manager: AbstractMediaFileManager)
|
||||
fun onMediaDownloadFinished()
|
||||
fun onMediaTooOld()
|
||||
}
|
||||
|
@ -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")
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user