Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] File name contains \n cannot be filtered during download #612

Closed
PAINCLOWN opened this issue May 9, 2024 · 5 comments
Closed

[Bug] File name contains \n cannot be filtered during download #612

PAINCLOWN opened this issue May 9, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@PAINCLOWN
Copy link

Describe the bug

File name contains \n cannot be filtered during download,
--template "{{ replace .FileName \\n _ / _ \ _ : _ * _ ? _ < _ > _ | _ _ }}"
or
--template "{{ replace .FileName \n _ / _ \ _ : _ * _ ? _ < _ > _ | _ _ }}"
When I download using cmd, it causes the file name to contain a newline and the file cannot be created

image

image
image

To Reproduce

--template "{{ replace .FileName \\n _ / _ \ _ : _ * _ ? _ < _ > _ | _ _ }}"
or
--template "{{ replace .FileName \n _ / _ \ _ : _ * _ ? _ < _ > _ | _ _ }}"

Expected behavior

Unable to filter \n

Version

Version: 0.17.0
Commit: 95120c0
Date: 2024-04-21T14:07:16Z

go1.21.9 windows/amd64

Which OS are you running tdl on?

Windows

Additional context

No response

@PAINCLOWN PAINCLOWN added the bug Something isn't working label May 9, 2024
@iyear
Copy link
Owner

iyear commented Jun 3, 2024

Try --template '{{ replace .FileName "\n" "_" }}'. Be careful of quotation.

@iyear iyear closed this as completed Jun 3, 2024
@PAINCLOWN
Copy link
Author

尝试一下--template '{{ replace .FileName "\n" "_" }}'。注意引用。

`PS D:\tg_down> tdl -n quickstart dl -f 1526240073.json -t 8 -s 524288 -l 4 --skip-same --continue -i mp4,flv,f4v,webm,m4v,mov,3gp,3g2,rm,rmvb,mpg,mpeg,mpe,ts,mpg,mpeg,mpe,ts,vob,dat,mkv,lavf,cpk,dirac,ram,qt,fli,flc,mod --template '{{ replace .FileName "\n" "_" }}'
Error: callback:
github.com/gotd/td/telegram.(*Client).Run.func3
github.com/gotd/[email protected]/telegram/connect.go:151

  • parse template:
    github.com/iyear/tdl/app/dl.newIter
    github.com/iyear/tdl/app/dl/iter.go:65
  • template: dl:1: unexpected "\" in operand`

The above error occurred after using the template you provided
please check

@PAINCLOWN
Copy link
Author

But I use "-f "Media.Name not contains '\n' " " to filter out all conversations that contain"\n ", which works fine. I don't know if that helps solve the problem.

@PAINCLOWN
Copy link
Author

PS D:\tg_down> tdl -n quickstart dl -f 1877648258.json -t 8 -s 524288 -l 4 --skip-same --continue -i mp4,flv,f4v,webm,m4v,mov,3gp,3g2,rm,rmvb,mpg,mpeg,mpe,ts,mpg,mpeg,mpe,ts,vob,dat,mkv,lavf,cpk,dirac,ram,qt,fli,flc,mod --template "{{ replace .FileName '\n' '' '/' '' ':' '' '*' '' '?' '' '<' '' '>' '' '|' '' ' ' '_' }}"
Found unfinished download, continue from '70/1549'
All files will be downloaded to 'downloads' dir
Error: callback:
github.com/gotd/td/telegram.(*Client).Run.func3
github.com/gotd/[email protected]/telegram/connect.go:151

  • iter:
    github.com/iyear/tdl/pkg/downloader.(*Downloader).Download
    github.com/iyear/tdl/pkg/downloader/downloader.go:59
  • execute template:
    github.com/iyear/tdl/app/dl.(*iter).process
    github.com/iyear/tdl/app/dl/iter.go:186
  • template: dl:1:21: executing "dl" at <'\n'>: expected string; found '\n'

PS D:\tg_down> tdl -n quickstart dl -f 1877648258.json -t 8 -s 524288 -l 4 --skip-same --continue -i mp4,flv,f4v,webm,m4v,mov,3gp,3g2,rm,rmvb,mpg,mpeg,mpe,ts,mpg,mpeg,mpe,ts,vob,dat,mkv,lavf,cpk,dirac,ram,qt,fli,flc,mod --template "{{ replace .FileName '' '' '/' '' ':' '' '*' '' '?' '' '<' '' '>' '' '|' '' ' ' '_' }}"
Error: callback:
github.com/gotd/td/telegram.(*Client).Run.func3
github.com/gotd/[email protected]/telegram/connect.go:151

  • parse template:
    github.com/iyear/tdl/app/dl.newIter
    github.com/iyear/tdl/app/dl/iter.go:65
  • template: dl:1: malformed character constant: '' '

@PAINCLOWN
Copy link
Author

Try --template '{{ replace .FileName "\n" "_" }}'. Be careful of quotation.

I noticed that the template uses the inverted single quote "`" instead of the single quote "'" and the double quote " " ”

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants