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

Fix broken "special type formatter" \fT \fE \fM when running gallery-dl in Linux #2396

Closed
wants to merge 1 commit into from

Conversation

Tobi823
Copy link
Contributor

@Tobi823 Tobi823 commented Mar 13, 2022

I want to use the "Special Type Format Strings" but gallery-dl completely ignores these formatters.

It seems that \f in the parameter --filename is converted to \\f.

By calling gallery-dl -f "\fM test20220313:generate_text" https://some.web.site, the argument format_string in formatter.py:parse is set to \\fM test20220313:generate_text. This breaks the detection and extraction of the special type formatters.

This pull request is a quick fix for this problem. Feel free to improve it.

@Tobi823
Copy link
Contributor Author

Tobi823 commented Mar 13, 2022

screenshot

(This is an older screenshot. I later replaced the kind[2:] with kind[-1])

@mikf
Copy link
Owner

mikf commented Mar 14, 2022

The problem seems to be that bash doesn't interpret \f as form feed character (ASCII code 12 or 0xC). To type it in bash, hold Ctrl and press v followed by l and you will get something that looks like ^L, but it's actually just one character, not ^ + L.

JSON has no problem with \f, that's a bash issue.

@Tobi823
Copy link
Contributor Author

Tobi823 commented Mar 14, 2022

Using the Unicode character 'FORM FEED (FF)' aka \f is in my opinion a very odd choice. I did not expect that. The documentation should highlight this (see #2406).

And I found a workaround for the Linux Bash:

  • Print the format string with printf.
  • Printf will convert \f to the form feed character.
  • Pass the output to gallery-dl

This works for me: gallery-dl -f "$(printf '\fM my_module:generate_file_name')"

@Tobi823 Tobi823 mentioned this pull request Mar 14, 2022
@Tobi823
Copy link
Contributor Author

Tobi823 commented Mar 14, 2022

Here is my new pull-request (#2406)

Feel free to close this pull-request and merge my new one.

In my place I would have changed the code, but improving the documentation is good enough (to prevent this beginners trap).

@mikf mikf closed this Mar 19, 2022
mikf added a commit that referenced this pull request May 2, 2022
to make it easier to use special type format strings on command-line

(#2396)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants