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