iyear / tdl

📥 A Telegram tookit written in Golang

Home Page:https://docs.iyear.me/tdl

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feat] Batch Download using .TXT file containing URLs

ArgX11 opened this issue · comments

Proposal

It would be great if you kindly implement the Batch Download option similar to YT-DLP.

Suppose I have 5 Telegram URLs,
https://t.me/tdl/1
https://t.me/tdl/2
https://t.me/tdl/3
https://t.me/tdl/4
https://t.me/tdl/5

And I put them in a URLs.txt file then I should be able to download them using Batch Download command something like this,
tdl dl --batch-download URLs.txt

Background

Suppose a channel has 10 messages and I want every second message from that channel like this,
https://t.me/tdl/2
https://t.me/tdl/4
https://t.me/tdl/6
https://t.me/tdl/8
https://t.me/tdl/10

Presently there is no way to select them using the Chat Export command

Workarounds

Currently, I have to manually put each URL individually and download them which is a very tedious process.

Currently, you can use Export Messages and edit the tdl-export.json manually as a workaround.

Or you can try the bash command below:

while read -r line
do
  tdl dl "$line"
done < URLs.txt

as another workaround.

Currently, you can use Export Messages and edit the tdl-export.json manually as a workaround.

Thanks for the suggestion. Generally, the JSON file consists of code blocks like this,

{
  "id": 12345,
  "messages": [
      {
          "id": 101,
          "type": "message",
          "file": "photo1.jpg"
      },
      {
          "id": 102,
          "type": "message",
          "file": "video1.mp4"
      },
      {
          "id": 103,
          "type": "message",
          "file": "photo2.jpg"
      },
      {
          "id": 104,
          "type": "message",
          "file": "video2.mp4"
      },
  ]
}

Could you kindly tell me how to batch remove similar code blocks inside the Curly Bracket in VS Code?
Suppose I want to remove all .mp4 type blocks, is there any command for that?

@ArgX11 , I am glad to help.

The easiest way is using filter to ignore file with .mp4 file extension.

For instance, tdl chat export -c $YOUR_CHAT -f "Media.Name not endsWith '.mp4'"

@XMLHexagram Yes, I use the filter command extensively (for example tdl dl -f export.json -i mp4). It is very useful.
But is there any way that I can filter out blocks from a JSON file based on a particular criteria using Powershell or cmd?

@ArgX11, I believe this has already exceeded the scope of what TDL is responsible for.

Also I think editing json in cmd is a bad idea. Maybe you can give jj a try.

Or just write some scripts to process the tdl-export.json.

Proposal

It would be great if you kindly implement the Batch Download option similar to YT-DLP.

Suppose I have 5 Telegram URLs, https://t.me/tdl/1 https://t.me/tdl/2 https://t.me/tdl/3 https://t.me/tdl/4 https://t.me/tdl/5

And I put them in a URLs.txt file then I should be able to download them using Batch Download command something like this, tdl dl --batch-download URLs.txt

Background

Suppose a channel has 10 messages and I want every second message from that channel like this, https://t.me/tdl/2 https://t.me/tdl/4 https://t.me/tdl/6 https://t.me/tdl/8 https://t.me/tdl/10

Presently there is no way to select them using the Chat Export command

Workarounds

Currently, I have to manually put each URL individually and download them which is a very tedious process.

tdl chat export -c CHAT -T id -i 1,5

This will only export he messages from 1-5 in the json
and you can use that to download the selected range of messages

tdl chat export -c CHAT -T id -i 1,5

@bolavefasfas Did you happen to read my question carefully? If yes then solve this (without manually modifying the JSON file)

Suppose a channel has 10 messages and I want every second message from that channel like this,

https://t.me/tdl/2
https://t.me/tdl/4
https://t.me/tdl/6
https://t.me/tdl/8
https://t.me/tdl/10

tdl chat export -c CHAT -T id -i 1,5

@bolavefasfas Did you happen to read my question carefully? If yes then solve this (without manually modifying the JSON file)

Suppose a channel has 10 messages and I want every second message from that channel like this,

https://t.me/tdl/2 https://t.me/tdl/4 https://t.me/tdl/6 https://t.me/tdl/8 https://t.me/tdl/10

use a bash script with loop

I too think these features inside tdl are not that necessary, i wrote python/bash scripts to loop over the exported files and the -f filter combination to get the messages I need and dump them to a new json, then use tdl to perform up/down/fwd operations on the resulting new json.

This feature won't be supported for now. I aim to keep the input part of tdl as simple and stable as possible. Currently, it supports two methods: -u and -f. You can use any external tool to convert the file format to the target format.

i wrote python/bash scripts to loop over the exported files

@phanirithvij Would you like to share such scripts? That would help me greatly, saving my time.

@Vlavitz contact me via email. I don't know your use case. Let's not pollute this issue any further.