Nekmo / telegram-upload

Upload and download files from Telegram up to 4 GiB using your account
MIT License
1.07k stars 233 forks source link

Add support for variables in the caption argument #115

Closed tissole closed 1 year ago

tissole commented 3 years ago

How do I imagine this enhancement? Let's say we have a folder called Photos 2020 and inside are subfolders named 1. January, 2. February, 3. March ...12. December. The app detects the name of the root folder (Photos 2020) and creates a text message with that name in the destination channel before starting uploading files.

Then go recursively and takes the name of the first subfolder and creates again a text message, then start uploading files from that folder (1. January), then creates a message with the name of the second subfolder (2. February) before uploading files from that folder, and so on till the last folder.

Now all the uploaded files have a logical structure that mimics the folder hierarchy. Photos 2020

  1. January Photo 1 Photo 2 Photo 3
  2. February Photo 1 Photo 2 ..
  3. December Photo 1 Photo 2

Can this be done?

Nekmo commented 3 years ago

It can be interesting although it solves a very specific problem. Perhaps it can be done in a more useful way for other cases.

tissole commented 3 years ago

Yeah, is not the most elegant solution :). I only mention it because I thought that Telegram can't be used with folders, but then I found these bots @FilesToCloudBot, @cloudy_files_bot, @foldersbot, @tenvsten_bot, @FilesToCloudBot. The implementation is rather crude but it can be done.

If folder structure can be replicated it could be very useful, for example for book collections, courses, and music collections. Now if all songs are organized in folders by artist and album name on PC, when uploaded to Telegram that order is lost, a user can't search by artist name doesn't know from which album the song is. Very cumbersome.

Yury-MonZon commented 3 years ago

+1 to that!

tissole commented 3 years ago

Now if all songs are organized in folders by artist and album name on PC, when uploaded to Telegram that order is lost, a user can't search by artist name doesn't know from which album the song is.

At that time that batch of songs was untagged. Testing with a better source has given better results because of hachoir, but I also encounter problems with propper tagging.

I found an implementation that has resolved the issue with preserving folder structure while uploading. It works backward too, when users choose to download files from TG, uploaded with that specific program, the folder structure is remade, all files are put in their folder/subfolder structure. This is the project:

https://github.com/khrj/teledrive https://teledrive.khushrajrathod.com

Unfortunately, the program seems broken on Windows and the development has ended. The idea that makes it possible to maintain the folder hierarchy is to caption the files with path, like this

folder1/subfolder1/file1 folder1/subfolder1/file2 folder1/subfolder1/file...

folder1/subfolder2/file1 folder1/subfolder2/file2 ...

folder2/subfolder1/file1 folder2/subfolder1/file2 ... This structure, along with the file hashes is retained in a JSON file that is uploaded in Saved Messages. This file is updated when files are uploaded and based on hashes prevents duplicate files to be uploaded. It is also used when downloading to remake the folder structure.

Hope it helps!

Nekmo commented 1 year ago

The following caption variables are supported: https://github.com/Nekmo/telegram-upload/blob/issue-115/docs/caption_format.rst

Nekmo commented 1 year ago

Fixed in version v0.7.0. Thanks!