mirror of
https://github.com/fabianonline/telegram_backup.git
synced 2024-11-22 16:56:16 +00:00
More JSON stuff. Still work in progress.
This commit is contained in:
parent
ef03deb31e
commit
f250f40e5e
@ -22,6 +22,7 @@ import de.fabianonline.telegram_backup.StickerConverter;
|
|||||||
import de.fabianonline.telegram_backup.DownloadProgressInterface;
|
import de.fabianonline.telegram_backup.DownloadProgressInterface;
|
||||||
import de.fabianonline.telegram_backup.mediafilemanager.FileManagerFactory;
|
import de.fabianonline.telegram_backup.mediafilemanager.FileManagerFactory;
|
||||||
import de.fabianonline.telegram_backup.mediafilemanager.AbstractMediaFileManager;
|
import de.fabianonline.telegram_backup.mediafilemanager.AbstractMediaFileManager;
|
||||||
|
import de.fabianonline.telegram_backup.models.Message;
|
||||||
|
|
||||||
import com.github.badoualy.telegram.api.TelegramClient;
|
import com.github.badoualy.telegram.api.TelegramClient;
|
||||||
import com.github.badoualy.telegram.api.Kotlogram;
|
import com.github.badoualy.telegram.api.Kotlogram;
|
||||||
@ -263,10 +264,10 @@ public class DownloadManager {
|
|||||||
downloadMessages(ids);
|
downloadMessages(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
LinkedList<TLMessage> messages = this.db.getMessagesWithMedia();
|
LinkedList<Message> messages = this.db.getMessagesWithMedia();
|
||||||
logger.debug("Database returned {} messages with media", messages.size());
|
logger.debug("Database returned {} messages with media", messages.size());
|
||||||
prog.onMediaDownloadStart(messages.size());
|
prog.onMediaDownloadStart(messages.size());
|
||||||
for (TLMessage msg : messages) {
|
for (Message msg : messages) {
|
||||||
AbstractMediaFileManager m = FileManagerFactory.getFileManager(msg);
|
AbstractMediaFileManager m = FileManagerFactory.getFileManager(msg);
|
||||||
logger.trace("message {}, {}, {}, {}, {}",
|
logger.trace("message {}, {}, {}, {}, {}",
|
||||||
msg.getId(),
|
msg.getId(),
|
||||||
|
@ -29,6 +29,7 @@ import de.fabianonline.telegram_backup.Utils;
|
|||||||
import de.fabianonline.telegram_backup.UserManager;
|
import de.fabianonline.telegram_backup.UserManager;
|
||||||
import de.fabianonline.telegram_backup.mediafilemanager.AbstractMediaFileManager;
|
import de.fabianonline.telegram_backup.mediafilemanager.AbstractMediaFileManager;
|
||||||
import de.fabianonline.telegram_backup.mediafilemanager.FileManagerFactory;
|
import de.fabianonline.telegram_backup.mediafilemanager.FileManagerFactory;
|
||||||
|
import de.fabianonline.telegram_backup.models.Message;
|
||||||
|
|
||||||
class TelegramUpdateHandler implements UpdateCallback {
|
class TelegramUpdateHandler implements UpdateCallback {
|
||||||
private UserManager user = null;
|
private UserManager user = null;
|
||||||
@ -136,22 +137,19 @@ class TelegramUpdateHandler implements UpdateCallback {
|
|||||||
private void processUpdate(TLAbsUpdate update, TelegramClient client) {
|
private void processUpdate(TLAbsUpdate update, TelegramClient client) {
|
||||||
if (update instanceof TLUpdateNewMessage) {
|
if (update instanceof TLUpdateNewMessage) {
|
||||||
TLAbsMessage abs_msg = ((TLUpdateNewMessage)update).getMessage();
|
TLAbsMessage abs_msg = ((TLUpdateNewMessage)update).getMessage();
|
||||||
TLVector<TLAbsMessage> vector = new TLVector<TLAbsMessage>(TLAbsMessage.class);
|
Message msg = new Message(abs_msg);
|
||||||
vector.add(abs_msg);
|
msg.save();
|
||||||
db.saveMessages(vector, Kotlogram.API_LAYER, gson);
|
|
||||||
System.out.print('.');
|
System.out.print('.');
|
||||||
if (abs_msg instanceof TLMessage) {
|
AbstractMediaFileManager fm = FileManagerFactory.getFileManager(msg);
|
||||||
AbstractMediaFileManager fm = FileManagerFactory.getFileManager((TLMessage)abs_msg, user, client);
|
|
||||||
if (fm != null && !fm.isEmpty() && !fm.isDownloaded()) {
|
if (fm != null && !fm.isEmpty() && !fm.isDownloaded()) {
|
||||||
try {
|
try {
|
||||||
fm.download();
|
fm.download(client);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("We got an exception while downloading media, but we're going to ignore it.");
|
System.out.println("We got an exception while downloading media, but we're going to ignore it.");
|
||||||
System.out.println("Here it is anyway:");
|
System.out.println("Here it is anyway:");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// ignore everything else...
|
// ignore everything else...
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ import de.fabianonline.telegram_backup.models.Message;
|
|||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
import com.github.badoualy.telegram.api.TelegramClient;
|
import com.github.badoualy.telegram.api.TelegramClient;
|
||||||
|
import com.github.badoualy.telegram.tl.exception.RpcErrorException;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -27,6 +27,7 @@ import com.google.gson.JsonObject;
|
|||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
|
|
||||||
import com.github.badoualy.telegram.api.TelegramClient;
|
import com.github.badoualy.telegram.api.TelegramClient;
|
||||||
|
import com.github.badoualy.telegram.tl.exception.RpcErrorException;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -27,6 +27,7 @@ import com.google.gson.JsonObject;
|
|||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
|
|
||||||
import com.github.badoualy.telegram.api.TelegramClient;
|
import com.github.badoualy.telegram.api.TelegramClient;
|
||||||
|
import com.github.badoualy.telegram.tl.exception.RpcErrorException;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
Loading…
Reference in New Issue
Block a user