3bl3gamer / tg_history_dumper

Exports messages and media from Telegram dialogs, groups and channels
MIT License
69 stars 13 forks source link

Pictures are not displayed in the Preview #36

Closed tangor86 closed 1 month ago

tangor86 commented 2 months ago

When go to the chat preview, images are not displayed, I think there is an issue with image path encoding.

image
tangor86 commented 2 months ago

@3bl3gamer

sorry for reopening, I did git clone + build, downloaded again my chats but i am still facing the same URL and image is not shown in "preview": http://127.0.0.1:9000/files%5c2194400374_%d0%90%d1%80%d1%82%d1%83%d1%80%20%d0%a1%d0%b8%d0%bb%d0%b0%20%d0%a3%d0%bc%d0%b0%5c63_Media_photo.jpg

P.S: %5c is not converted to /

3bl3gamer commented 1 month ago

That's strange. Actually, it should not convert %5c to / but convert back slashes (\) to / before writing the path to HTML template. I've tested it in Windows and it worked (you have also run the dumper on Windows, haven't you?).

I've pushed an update where fpathSeparatorsToURL is replaced by build-in filepath.ToSlash. But they both should do the same so there is a little chance this will help.

If the error is still here, can you please add a

fmt.Println(relPath, filepath.ToSlash(relPath))

just after

relPath, _ := filepath.Rel(s.saver.Dirpath, file.FPath)

then open chat preview and check the output? It should print original and converted paths like

files\12_name\34_Media.jpg files/12_name/34_Media.jpg
tangor86 commented 1 month ago

I took a new version of the code, rebuilt and re-fetched all the chats... actually i have seen this file beeing downloaded in the logs: image

I also added these 2 lines as you suggested in preview.go image

But I didn't see any output neither in console nor in the browser (screens attached) image

so I wonder if this code ever reached :) or am i checking in the wrong place?

3bl3gamer commented 1 month ago

loadChatFiles() is responsible for searching for previously saved files. If was not called, there would be no files in preview. But there are some (though with broken paths).

Are you 100%-sure you are building and running correct files in correct directory? Maybe there is tg_history_dumper and tg_history_dumper.exe for example?

tangor86 commented 1 month ago

you are right... i started like tg_history_dumper XXX

instead of ./tg_history_dumper XXX so it was taking some old version which i installed earlier with "go install" New version i installed with git clone because i don't know how to update with "go"

Anyway, the output is like: files\2194400374_Артур Сила Ума\63_Media_photo.jpg files/2194400374_Артур Сила Ума/63_Media_photo.jpg

and the image is shown now!

I've tested it in Windows and it worked (you have also run the dumper on Windows, haven't you?).

yes win 11